How can I modify a cabal package installed onto my computer - haskell

I'm trying to use wxHaskell to modify wxAsteroids. Every time I try to change something within the wxAsteroids1.1.0.1.tar.gz folder it does not affect the program. Is there a way to update the wxAsteroids.exe in order to use the code? Unzipping the .tar.gz gives me this error when trying to run Asteroids.lhs:
could not find module 'Paths_wxAsteroids'
Use -v to see a list of the files searched for.

tar xzf wxAstroids*
This will get your the package in a wxAstroids-<version> directory. Change to that directory and...
vi xAstroids.cabal
-- Edit the file, add Paths_wxAstroids to the other-modules: list.
Now the package should be fixed, so reinstall this fixed version
cabal install
Yay!

Related

Failing to install Sublime Text 3 in Ubuntu 16.04 using apt-get command

I had downloaded sublime previously directly from the browser as tarball and saved it in a folder (and of course extracted it).But this way I wasn't able to make Sublime my default editor and it didn't feature as an application when I tried to open a text file with a right-click.I read somewhere installing sublime text 3 using commands:
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
will solve my problem. So I directly deleted the Sublime_text3 folder saved in my Downloads directory and then used the given commands. But when I entered the 3rd command line I got the following error(just writing the error part):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:/var/cache/apt/archives/sublime-text-installer_3126-2~webupd8~1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Can anyone explain why this error is coming and suggest a way to solve this problem? Also if anyone can tell how I can set Sublime as my default text editor from the tarball downloaded from the sublime text 3 website. Thanks in advance!
you can try this command to install Sublime Text using Snap Store..
sudo snap install sublime-text --classic
I'm not sure overall how to fix that error or what's going on (I use Slackware and not Ubuntu/Debian), but for a long while there have been official Sublime repositories several different Linux distributions, including Ubuntu/Debian.
It's highly recommended that you use those if you want to go the package route and not use existing solutions such as the one referenced in your question or in the other response here, if for no other reason than only the official repository is guaranteed to contain an unmodified version of Sublime. Additionally the official repositories are always updated on release, which may or may not happen in a timely manner in other repositories.
The links referenced above contain instructions on how to set up and use Sublime from those repositories, and if you have any issues a good place to ask is the forum.
One thing to note which isn't mentioned explicitly in the above pages is that to use the official repositories, you should:
Choose only one of them (stable or dev, noting that you need a license to run a dev version) and not add both repositories or things will not work as expected
Ensure that other repositories that you've added (such as the one in your question) are removed to make sure that the package system definitely pulls the correct package
There are a couple of ways to go if you want to install Sublime from the tarball version. The easiest way would be to extract it, then manually set up launcher shortcuts and so on based on what falls out. How exactly you would register it as a text editor in that case, I'm not entirely sure since I don't use the same distribution as you.
Presuming that the process would be easier if Sublime was installed in a way similar to how the package manager would do it, the tarball comes with a desktop file and icons, so the following steps can be used to (presumably) do what the package installer would do.
The proviso here is that although these steps work on my non-Ubuntu machine, I don't know if all of the referenced tools are installed by default on an Ubuntu system, so so more setup work may be involved.
Note also that the files in the tarball are not entirely self-consistent, which makes this a little bit more work.
First, you need to extract the tarball (replace tarball filename as appropriate for location and build):
cd /opt
sudo tar xvf ~/Downloads/sublime_text_3_build_3176_x64.tar.bz2
This creates the folder /opt/sublime_text_3/ and fills it with the contents of the tarball.
Next, you want to install the icons contained in the tarball. As far as I have been able to tell, the icons in the tarball aren't in the correct directory structure, requiring each to be copied into place individually. We also need to update the icon cache to ensure that the new icon is noticed by the system:
cd /usr/share/icons/hicolor/
sudo cp /opt/sublime_text_3/Icon/16x16/sublime-text.png 16x16/apps/
sudo cp /opt/sublime_text_3/Icon/32x32/sublime-text.png 32x32/apps/
sudo cp /opt/sublime_text_3/Icon/48x48/sublime-text.png 48x48/apps/
sudo cp /opt/sublime_text_3/Icon/128x128/sublime-text.png 128x128/apps/
sudo cp /opt/sublime_text_3/Icon/256x256/sublime-text.png 256x256/apps/
sudo gtk-update-icon-cache -f -t .
Now we want to install the sublime_text.desktop file that is in the tarball. Note however that like the icons, it seems kind of broken; the tarball extracts to sublime_text_3 but the desktop file assumes that the application is actually in /opt/sublime_text instead.
As such, you either need to rename the folder that was extracted to sublime_text to match what is in the desktop file, or edit the desktop file to make the path correct.
The following steps assume that we want to keep the folder the same and rewrite the desktop file. These commands will generate a new file named sublime_text_3.desktop with the changes.
cd /opt/sublime_text_3/
sed -e "s^/sublime_text/^/sublime_text_3/^" sublime_text.desktop | sudo tee sublime_text_3.desktop
Now you can install the desktop file. You do that with desktop-file-install, passing it the name of the desktop file. For accessing Sublime from the command line, you also want to set up a subl link to the installed copy of Sublime.
Adjust the paths as appropriate here if you decided to rename the folder instead of editing the desktop file:
sudo desktop-file-install sublime_text_3.desktop --rebuild-mime-info-cache
sudo ln -s /opt/sublime_text_3/sublime_text /usr/bin/subl
At this point Sublime should show up as an installed application, or at least it does in my Window Manager; if not, executing sudo update-desktop-database may help refresh it.
You can try this once. i hope it will help
wget https://download.sublimetext.com/files/sublime-text_build-4126_amd64.deb
sudo dpkg -i sublime-text_build-4126_amd64.deb

dpkg-buildpackage error: missing files (usr/include/*)

I am trying to build a dev package out of some .so files - i.e libraries.
dh_make -f ../ mylibs.tar.gz
then I choose
-l
since I want a library package.
A debian folder is created which consists of among others the controlfile and the install file.
When I finally create the package with
dpkg-buildpackage
I get the following error message:
dh_install: mylibs-dev missing files (usr/include/*), aborting
I dont understand what is missing since the headers are copied to
usr/include
I have checked the directory and the headers are copied there. So why do I get this error message?
the install-file look like this:
usr/lib/lib*.so.*
So - may the path to usr/include be missing here? I've tried with
usr/include/h.*
but it does not work
The debian install files are most often used for source packages that produce several binary packages. In that case, dh_auto_install installs to the directory debian/tmp/ and dh_install moves the files from there to each package. However, when there is a single package, dh_auto_install takes a shortcut and installs directly to debian/package-name/. In that case, you only need to list in the install file the files that make install missed (usually none). If you list the regular, installed files, dh_install will get confused because it is still looking for them in debian/tmp/.
It is possible to override either the directory where dh_auto_install installs, or the directory where dh_install is looking, but you probably don't need either.

I cannot Uninstall Tcl from my linux system

I installed tcl to learn it, however, I installed all the files in the wrong location. I am trying to uninstall it, But the uninstall file does not work. I am trying to carry out the instructions form their website:
To uninstall ActiveTcl, run the "uninstall.tcl" script that is located in the directory where you extracted the ActiveTcl archive. Note that you must use the "wish" in the distribution you wish to uninstall. For example:
% /path/Tcl/bin/wish /path/Tcl/lib/ppm/log/ActiveTcl/uninstall_ActiveTcl.tcl
stored, by default, in the directory /lib/ppm/log/ActiveTcl. You must use the wish interpreter from the distribution you wish to uninstall. Ensure that you do not run the uninstall script from a directory that will be removed during the uninstallation.
For example:
% /path/Tcl/bin/wish /path/Tcl/lib/ppm/log/ActiveTcl/uninstall_ActiveTcl.tcl
Note: if you are uninstalling both ActiveTcl and Tcl Dev Kit, uninstall Tcl Dev Kit before uninstalling ActiveTcl.
There is no uninstall_ActiveTcl.tcl. I do see an "uninstall" file but it does not have an extension, and I do not know how to run it.
Any help is appreciated
Thank you
Try editing the file to a uninstall.tcl file and see if that works. Take a back-up first though. Because we might need that file later
I re-installed it in a new location, compared the files that were installed between the old and the new location and deleted the file sin the old location. Unfortunately I could not delete many of the hidden files, as I did not know if they were there originally or if they belonged to Tcl. I am really surprised and disappointed there is no easy way to uninstall tcl properly.
I strongly suspect that you should uninstall ActiveTcl as follows:
Open a command prompt
Change directory to where you found the install file - e.g.
$ cd path_to_Tcl_installation/bin
Run the file
$ ./uninstall
On linux systems, you don't need any particular file extension in order to be able to run a file.
I don't know CentOS but a little googling led me to a forum thread that describes how to open a command prompt.
Good luck

Run HAppStack app withot cabal

I'm trying out HAppStack. I installed HAppStack and created a project: happstack new project web. New folder 'web' created with project guestbook under it. So now I want to run it. The only way I could do it is run cabal install. But I want to run my app without installing with cabal! Executing run.sh errors: Could not find module 'Paths_guestbook'. How can I do it?
Edit:
In general, is there a way to run HAppStack app without rebuild like in Snap?
In general, you can always build Cabal projects without installing simply by doing:
$ cabal configure
$ cabal build
The resulting executable will usually be called dist/build/<project>/<project>.
The specific error you're getting is because the code must be built with Cabal to get the Paths_guestbook module, which will contain information about the location of data files used by it. (It may be the case that it's unable to find these data files if you run the executable without installing it; in that case, you'll need a more elaborate solution, such as cabal-dev.)
(I'm not a Happstack user, so I don't know if there's an official way to accomplish this, but this should work for basically any Cabal-based project in general. The repository shows that run.sh was last modified in 2009, so I suspect it has simply bit-rotten. It doesn't do anything special, though, so cabal build should work just fine.)
SHORT VERSION:
The run.sh seems to be missing an include paramater. Modify it to look like this:
#!/bin/sh
runghc -isrc -isrc-interactive-only src/Main.hs
I have update the run.sh in darcs to include this change.
LONG VERSION:
Normally that flag is not needed for Happstack applications. You can usually just do, runhaskell Main.hs. But in that particular example the Main.hs explicitly imports:
import Paths_guestbook (version)
which is used in the versionInfo function so that the server can report its own version number. Though version number in src-interactive-only is hardcoded and will generally be out of date. So it is only correct if you actually build with cabal.
The Paths_guestbook module is normally created automatically when cabal build is run. So, another fix would be to change the run.sh to:
#!/bin/sh
runghc -isrc -idist/build/autogen src/Main.hs
And run cabal configure && cabal build once. After that you will be able to use run.sh (until you do a cabal clean).
Another option would be to set a CPP flag in the .cabal file, and only import Paths_guestbook when the application is being built via cabal.
For example in the happstack.com source code:
http://patch-tag.com/r/stepcut/happstackDotCom/snapshot/current/content/pretty/Main.hs
In line 40 (or so) you will see an #ifdef __CABAL__. happstack.com needs to be able to know where to find the static content such as .css files. When doing runhaskell Main.hs in the local directory, it will look for the files in a sub-directory of the local directory. If you do cabal install it will instead look whever cabal installs the data files. Or, you can override the default location with command-line arguments. (Which is what the debian packaging for that app does).
Unfortunately, the happstack new project command is somewhat bitrotten because the author became a parent and has not had time to work on it in a long time. It will likely be removed from the upcoming Happstack release in order to reduce confusion.
In order to be truly useful, I think the command needs to prompt for a bunch of values and then generate a new project from a set of templates. Similar to how 'cabal init' works. But currently, no one has volunteered the time to make that happen.
To see changes to your source appear automatically with out restarting the server you can use the happstack-plugins library. There is an screencast of it here:
http://happstack.blogspot.com/2010/10/recompile-your-haskell-based-templates.html

Run time installation directory of debian package contents

I have a debian package that I built that contains a tar ball of the files, a control file, and a postinst file. Its built using dpkg-deb and it installs properly using dpkg.
The modification I would like to make is to have the installation directory of the files be determined at runtime based on an environment variable that will be set when dpkg -i is run on the deb file. I echo out the environment variable in the postinst script and I can see that its set properly.
My questions:
1) Is it possible to dynamically determine the installation directory at runtime?
2) If its possible how would I go about this? I have read about the rules file and the mypackage.install files but I don't know if either of these would allow me to accomplish this.
I could hack it by copying the files to the target location in the posinst script but I would prefer to do it the right way if possible.
Thanks in advance!
So this is what I found out about this problem over the past couple of weeks.
With prepackaged binaries you can't build a debian package with a destination directory dynamicall determined at runtime. I believe that this might be possible if installing a package that is built from source where you can set the install directory using configure. But in this case since these are embedded Ubuntu machines they don't have make so I didn't pursue such an option. I did work out a non traditional method (hack) for installing that did work. Since debian packages simply contain a tar ball relative to / simply build your package relative to a directory under /tmp. In the postinst script you can then determine where to copy the files from the archive into a permanent location.
I expected that after rebooting and the automatic deletion of the subdirectory under /tmp that dpkg might not know that the file package existed. This wasn't a problem. When I ran 'dpkg -l myapp' it showed as still installed. Updating the package using dpkg/apt-get also worked without a hitch.
What I did find is that if you attempted to remove the package using 'dpkg -r myapp' that dpkg would try and remove /tmp which wasn't good. However /tmp isn't easily removed so it never succeeded. Plus in our situation we never remove packages but instead simply upgrade them.
I eventually had to abandon the universal package due to code differences in the sources resulting in having to recompile per platform but I would have left it this way and it did work.
I tried using --instdir to change the install directory of the package and it does relocate the files but dpkg fails since the dpkg file can't be found relative to the new instdir. Using --instdir is sort of like a chroot. I also tried --admindir and --root in various combinations to see if I could use the dpkg system relative to / but install relocate the files but they didn't work. I guess rpm has a relocate option that works but not Ubuntu.
You can also write a script that runs dpkg-deb with a different environment for 6 times, generating 6 different packages. When you make a modification, you simply have to run your script, and all 6 packages gets generated and you can install them on your machines avoiding postinst hacking!
Why not install to a standard location, and simply use a postinst script to create symbolic links to the desired location? This is much cleaner, and shouldn't break anything in dpk -I.

Resources