LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to remove a package I compiled and installed? (https://www.linuxquestions.org/questions/slackware-14/how-to-remove-a-package-i-compiled-and-installed-605598/)

JosephS 12-09-2007 10:11 AM

How to remove a package I compiled and installed?
 
I downloaded a program: units-1.74 from:
http://www.ee.surrey.ac.uk/Teaching/Unix/unix7.html

I configured and compiled the program. After that I ran
Code:

make install
I got the following package (I added the install directory and slack-desc file after):

Quote:

units174/:
bin info install man share

units174/bin:
units

units174/info:
units.info

units174/install:
slack-desc

units174/man:
man1

units174/man/man1:
units.1

units174/share:
units.dat
I then ran
Code:

makepkg
and got the folowing package:
units-1-i686-1js.tgz

which I installed in /usr/local:
Code:

ROOT=/usr/local installpkg units-1-i686-1js.tgz
Here is a copy of the slack-desc file I made:
Quote:

units: units-1-i686-1js
units:
units: This is a program to convert units of measurement
units:
units:
units:
units:
units:
units:
units:
units:
This is what was put into /usr/local/var/log/packages/units-1-i686-1js:

Quote:

PACKAGE NAME: units-1-i686-1js
COMPRESSED PACKAGE SIZE: 103 K
UNCOMPRESSED PACKAGE SIZE: 320 K
PACKAGE LOCATION: units-1-i686-1js.tgz
PACKAGE DESCRIPTION:
units: units-1-i686-1js
units:
units: This is a program to convert units of measurement
units:
units:
units:
units:
units:
units:
units:
units:
FILE LIST:
./
share/
share/units.dat
man/
man/man1/
man/man1/units.1
install/
install/slack-desc
info/
info/units.info
bin/
bin/units
This is the first package I compiled and made, I tried to follow the instructions on Building A Package from SlackWiki, but apparently I missed something, because I can't uninstall the package.

evilDagmar 12-09-2007 10:54 AM

Wow. You kinda made a mess of things.

Issue #1: `makepkg` should be issued from the top level of your staging directory. If you want a file named 'foo' to go into /usr/bin, then (for example) `mkdir -p /tmp/staging/usr/bin ; cp foo /tmp/staging/usr/bin/foo` and run makepkg from /tmp/staging. It looks like you ran makepkg from the usr subdirectory of your staging area.

Issue #2: The $ROOT variable does not do what you think it does for installpkg. You only pass $ROOT to installpkg when you want to install the package with somewhere other than / being treated as the root filesystem (like if you're booted up from the install media, and have all your disks mounted under /mnt, you'd use `ROOT=/mnt installpkg foo.tgz`. Doing what you did likely resulted in ugly things like /usr/local/var/log/packages/ being created.

Issue #3: Do not install files into the production filesystem when you're making a package. According to your post you did a plain `make install` which is why you have the package's files present at all. Most (but not all) GNU autoconf-generated packages recognize the DESTDIR variable, which is another way of changing the root of the filesystem for what the Makefile is about to do. Next time, create /tmp/staging for use as the root of your staging filesystem (also called the "staging root") and then do a `make DESTDIR=/tmp/staging install`. This will result in things like /tmp/staging/usr/bin/units being created. You can then cd into /tmp/staging and check things out, fix permissions, deploy any custom install/doinst.sh scripts, spellcheck your new install/slack-desc file and so on, and then run makepkg. Hint: If you don't know if a Makefile respects DESTDIR, open the thing in a text editor and search for it, or grep for it. If it doesn't, there's likely some other variable (or variables) you can use that will do the same thing.

shadowsnipes 12-09-2007 11:02 AM

Here is where you really went wrong...
Quote:

Originally Posted by JosephS (Post 2984974)
which I installed in /usr/local:
Code:

ROOT=/usr/local installpkg units-1-i686-1js.tgz

You should not use ROOT=anything installpkg because now the package db will now have "share" instead of "/usr/share" or "/usr/local/share" and so on. So, it should be obvious why you're package won't uninstall correctly.

Maybe if you use ROOT=/usr/local when you removepkg it will work.

If nothing else you know where the files are so you can remove them manually. If you can't remove the entry from the package db manually you could always upgrade the package with a proper one.

Before makepkg you should have moved all folders (except install) under "usr" or "usr/local" if that is really your preference.

I think the program you are trying to compile is the same one found at http://www.gnu.org/software/units/units.html. If so, you can simply use the SlackBuild to automate the build process for this program. You can find the SlackBuild at http://slackbuilds.org/repository/12.0/academic/units/.

After you get it take a look at the build script. It will show you a great method for making a good package.

Also, read this tutorial about making a Slackare build script and package.

agentc0re 12-09-2007 11:46 PM

If i were you, i'd give src2pkg a try. it will build your package for you.

gnashley 12-10-2007 01:09 AM

Naturally I'll second the vote to use src2pkg. To get rid of the original you may need to remove each file by hand, or you could remove them with 'make uninstall' if you haven't moved or removed the original sources. If you have moced them or removed them you could start again and configure the sources the same way you did at first, but after configuring, instead of running 'make install' run 'make uninstall'. You'll still have to clean up the other files which you created -the slack-desc, etc. As stated by others, packaged software should not be installed to /usr/local.

evilDagmar 12-12-2007 01:01 AM

If there's a Slackbuild script available on Slackbuilds.org, it would be preferable to src2pkg.

JosephS 12-20-2007 07:29 AM

Thanks for all the help. I got the program built and installed; and am able to remove it. I wasn't able to use DESTDIR, but used:
make prefix=/tmp/build/usr install.

what is the problem with using /usr/local?
I thought installing there would help me to keep track of programs I installed outside of the Slackware repository.

Does it matter if I build the program as root or a normal user; build in
/home/joe or in / ?

gnashley 12-20-2007 10:00 AM

If you are not making a package of the program, then /usr/local is indeed the correct place to put it. You can compile it as a normal user but install it as root. If you build it with a prefix to install in your users $HOME you could also install it as a normal user. When you configure, compile and install the program using --prefix=/usr/local, then the program will be installed as:
/usr/local/bin/units

The real disadvantage to installing software manually is that you need the configured sources in place in order to be able to run 'make uninstall' to remove the software. Not much of a problem if it only installs a few files, but if it installs many then you may want some way to easily and dependably remove them. hence, the need for 'make uninstall'.

If you did this:
make prefix=/tmp/build/usr install
Then you have the program installed to /tmp/build/usr/bin/units which is not a very good place to install software. It isn't in anyones' path so you can't run it without specifying the full path:
/tmp/build/usr/bin/units

Now, if you want to make a *package* of the program so that it can be properly installed and run, you could create a directory /tmp/build/install and create a slack-desc file for the package in that directory(after installing it as you described).
Then cd into the directory /tmp/build and run:
'makepkg units-1-i486-1.tgz'

Then run 'installpkg units-1-i686-1js.tgz'
That will then install the program as /usr/bin/units

'src2pkg units-1.74.tar.gz' will do all this for you very quickly and cleanly, placing the finished package under /tmp. Then 'installpkg /tmp/units-1.74-i486-1.tgz' will install it under /usr/bin.

You might go to the linuxpackages.net site and find their guide on creating packages in order to understand better what a package should look like inside and how to create one. And you might try 'exploding' a few regular slackware packages so you can see what they look like inside. Just create an empty directory, copy an already-made package in there, then cd into the directory and run:
'explodepkg ./*.tgz'

JosephS 12-20-2007 07:46 PM

Thanks for help. I looked at linuxpackages.net as well as some other web pages. I made a install dir with a slack-desc file and ran 'makepkg
units-1.74-i486-1.tgz'. The program works fine.

I originally thought /usr/local was a place to install packages, but now I see it wouldn't be as accessible.

I ran across this from "How to make a slackware package" at linuxpackages.net
Quote:

Ok now that we have the package all tidy in /work/builds lets go ahead and
make it. One mistake most folks make is not ensuring the build folder is owned
by root and has the correct perms. Remember this will be the root of the file
system the package is installed on. The best thing is to type chown root.root
. and chmod 755 . from inside the /work/builds directory. Next type "makepkg
name-version-arch-build.tgz" this will create a package based on what is in
that directory.
why does the build folder need to be owned by root; would this be so if I'm making the package in my home directory?

I'll take a look at src2pkg. I was also thinking of looking at checkinstall. How would these compare?

gnashley 12-21-2007 01:49 AM

When you create a package to install to the system directories all the files and directories usually should belong to root -otherwise regular users might not be able to access them. there are exceptions to this, but in no case should the files or dirs belong to a regular user.

src2pkg is a more complete replacement for checkinstall. It will do a much better job of creating packages for you and takes care of the whole process of unpacking, configuring, compiling and packaging. I'm the author, but you don't have to trust my judgement of it as there are lots of posts here on the forum where other users recommend it -some of them are quite advanced users perfectly capable of creating packages manually, but they find src2pkg to be very useful. checkinstall has some problems running correctly on Slackware-12 and may fail to correctly package your program.


All times are GMT -5. The time now is 02:29 AM.