Share your knowledge at the LQ Wiki.
Go Back > Blogs > psionl0
User Name


Rate this Entry

Using Slackware's Package Management

Posted 08-19-2011 at 08:50 AM by psionl0
Updated 08-19-2011 at 12:03 PM by psionl0

Slackware's package management system is very simple and effective. Run installpkg and all the files in the package get installed in the right place, installation scripts get run and a record of the installation gets stored in /var/log/packages. The time stamp on the file in /var/log/packages also tells you when the package was installed (very handy sometimes).

Of course, if you no longer need the package then you can run removepkg and all of the package's files (not shared by other packages) get removed and a record of the removal is stored in /var/log/removed-packages. The lack of automatic dependency resolution is an advantage here because you can be sure that removing the package won't clobber another package.

But what about those times where you only need to install one or two files, create symlinks in the system directories or create a script or two? You can do these things without using the package management system but you lose the advantage of having a record of the system changes. In the long run, such files are likely to be forgotten and remain in the system taking up disk space long after they have served any useful purpose.

I recently needed to install nvidia on my PC because the noveau drivers would not work correctly on this mode. This wasn't hard. src2pkg made Slackware packages out of the nvidia-kernels and nvidia-drivers and both installed without incident.

In order to replace noveau with nvidia I needed to create two files: one was /etc/X11/xorg.conf (generated by running nvidia-xconfig) and the other was /etc/modprobe.d/disable-nouveau.conf which (you guessed it) prevents noveau from being loaded at boot time. When these two files are present then the PC boots up with nvidia. With the files removed, the PC boots up with noveau.

Although the installation was straight forward, the performance was not. This was the start of a lot of messing around and included such measures as changing the kernel from to (noveau actually works with the upgraded kernel). As part of this tomfoolery, I had to switch between nvidia and noveau many times. This meant removing then reinstalling the two files as mentioned above.

There is no problem with remembering where the two files are supposed to go - on the day. However, there is no guarantee that I would remember the precise location of the files a week later (unless I made very good notes). I could have gotten around this difficulty by creating two scripts - one to install the files and one to remove them. However, that does not help much with the documentation side of things and it also ignores the fact that Slackware's package management system can do the same thing and also take care of the documentation.

To make a package out of these two files is surprisingly easy (as is often the case when you do things the Slackware way). The first step is to create a directory for the packages files: I called mine nvidiaenabled-1.0-noarch-1_gs. Then I cd'd into it. I had to recreate parts of the root directory tree where the files are and I also needed an install directory for the "slack-desc" (the easiest way to create slack-desc is to copy one and edit it). Once the files are in place, you run makepkg to create the package and installpkg to install the files.

After creating the "slack-desc" in the root directory, these are the commands I used to make the package:
# mkdir nvidiaenabled-1.0-noarch-1_gs
# cd nvidiaenabled-1.0-noarch-1_gs
# mkdir install
# mkdir etc
# mkdir etc/X11
# mkdir etc/modprobe.d
# cp /root/slack-desc install/
# cp /etc/X11/xorg.conf etc/X11/
# cp /etc/modprobe.d/disable-nouveau.conf etc/modprobe.d/
# makepkg ../nvidiaenabled-1.0-noarch-1_gs.tgz (answer "n" to changing permissions)
Although the files were initially present, I ran "installpkg nvidiaenabled-1.0-noarch-1_gs.tgz" (after cd'ing to the /root directory) to ensure that a record was now present in /var/log/packages.

Now I have a simple way of switching between nvidia and noveau (just run installpkg or removepkg). I don't have to remember which files are involved nor when or even whether nvidia is enabled or not because Slackware has documented this for me. Since I have more work before either driver is working satisfactorily (but not until I know what else to do), this package is going to make life a lot easier for me.
Posted in Uncategorized
Views 843 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 04:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration