<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>LinuxQuestions.org - Blogs - psionl0</title>
		<link>http://www.linuxquestions.org/questions/blog/psionl0-562723/</link>
		<description>LinuxQuestions.org offers a free Linux forum where Linux newbies can ask questions and Linux experts can offer advice. Topics include security, installation, networking and much more.</description>
		<language>en</language>
		<lastBuildDate>Thu, 23 May 2013 08:44:01 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>https://lqo-thequestionsnetw.netdna-ssl.com/questions/images/misc/rss.jpg</url>
			<title>LinuxQuestions.org - Blogs - psionl0</title>
			<link>http://www.linuxquestions.org/questions/blog/psionl0-562723/</link>
		</image>
		<item>
			<title><![CDATA[Automating Slackware's Package Management]]></title>
			<link>http://www.linuxquestions.org/questions/blog.php?b=35325</link>
			<pubDate>Wed, 20 Feb 2013 07:45:35 GMT</pubDate>
			<description>In my previous blog (http://www.linuxquestions.org/questions/blog/psionl0-562723/using-slackwares-package-management-4044/), I explained how even if...</description>
			<content:encoded><![CDATA[<div>In my <a href="http://www.linuxquestions.org/questions/blog/psionl0-562723/using-slackwares-package-management-4044/">previous blog</a>, I explained how even if you are only installing a couple of files on the system, there were advantages to creating a Slackware package to do so. The example I gave was the files I needed to disable nouveau and use nvidia instead. <br />
<br />
This policy paid dividends when I upgraded to Slackware 14.0. The nvidia drivers wouldn't work and I faced the task of upgrading them for 14.0 (which meant remembering stuff I had done 18 months ago). Before doing that, it seemed prudent to just remove the files I had installed for nvidia (where/what were they again?) and see if the new kernel was up to the task. All I had to do was enter the command: &quot;<font face="Courier New"><b>removepkg nvidiaenabled-1.0-noarch-1_gs.tgz</b></font>&quot; and it was done. The new kernel proved to be up to task so hours of work had been spared.<br />
<br />
The problem is that creating a Slackware package by hand can be an involved process (as shown by the steps in my previous blog). I had previously created a package called &quot;<b>moreicons</b>&quot; which added a couple of icons somewhere for use in <b>wbar</b> or <b>idesk</b>. It installed and worked but it wouldn't copy the &quot;slack-desc&quot; so <b>pkgtools</b> had no information to reveal about it (apart from the files). It turns out that &quot;<b>makepkg</b>&quot; is rather fussy about both the structure of the directory you are making a package out of and the name of the package. I couldn't see where I was going wrong so, since it was a minor package, I just left things as they were.<br />
<br />
Since that time, I have gained some experience in writing SlackBuild scripts so I decided it was time to make a proper &quot;<b>moreicons</b>&quot; package by writing a script to do so. <a href="http://www.slackwiki.com/Writing_A_SlackBuild_Script" target="_blank" rel="nofollow">Slackwiki</a> has a good tutorial on writing SlackBuild scripts to convert a source to a package and SlackBuilds.org has a number of <a href="http://www.slackbuilds.org/templates/" target="_blank" rel="nofollow">templates</a> you can use to make your own script. Of course, since the main reason for writing a SlackBuild script is that <b>src2pkg</b> has failed to create the package for you, it is not really a task for n00bs. However, for just installing a few files, writing a script is well within the realm of anybody who can use an editor and Slackware's package management tools.<br />
<br />
This is a breakdown of the script I wrote for moreicons. The first part just sets up some variables that the script will use. This makes it easy to use the script as a template for installing other files. The usual SlackBuild script uses the <b>/tmp</b> or <b>/tmp/SBo</b> directories to do its work but I saw no advantage of this for such a minor task and kept everything in the current working directory. Note that the build is 2 because it is fixing up build 1.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 242px;
		text-align: left;
		overflow: auto">#!/bin/sh

# Slackware build script for moreicons


PRGNAM=moreicons
VERSION=${VERSION:-1.0}
ARCH=noarch
BUILD=${BUILD:-2}
TAG=${TAG:-_gs}
CWD=$(pwd)
PKG=$CWD/package-$PRGNAM

set -e # Exit on most errors</pre>
</div>The next section is the main part of the script. It deletes the old package directory and creates a new directory structure where the files I want installed will be placed. Note that this script assumes that the icons are present in the current working directory.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 130px;
		text-align: left;
		overflow: auto">rm -rf $PKG
mkdir -p $PKG

# Create the subdirectories and copy the icons into the $PKG directory
mkdir -p $PKG/usr/share/pixmaps
cp -a $CWD/home.png $PKG/usr/share/pixmaps
cp -a $CWD/sw.png $PKG/usr/share/pixmaps</pre>
</div><b><u>DOCUMENTATION:</u></b> Since this package is only installing a couple of files, there is strictly no need for any documentation other than the slack-desc. If you are creating the package by hand it is tempting to skip the documentation altogether. However, it is no extra work for the script and by creating a directory for documentation, you avoid the need to hang on to the files you used when creating the script/package. It is usual to keep a copy of the SlackBuild in the documents folder and it is also a good idea to add a README file there too. The README file is basically just the slack-desc without the &quot;moreicons:&quot; bits but I also have the option of adding some extra instructions for my future self. The README is actually created within the script itself so no extra files are involved.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 274px;
		text-align: left;
		overflow: auto"># Copy program documentation into the package
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild &gt; $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

# Create a README file
cat &gt; $PKG/usr/doc/$PRGNAM-$VERSION/README &lt;&lt; _EOG
moreicons (extra icons) 

Puts a couple of extra icons into
/usr/share/pixmaps directory
sw.png, home.png 

Used in wbar, idesk etc.

SlackBuild created 19 Feb 2013
_EOG</pre>
</div>Just as the script creates a README file, it also creates the slack-desc. The use of the generic $PRGNAM variable makes this more useful as a template. <br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 258px;
		text-align: left;
		overflow: auto"># Create a slack-desc file and put it in the install directory
mkdir -p $PKG/install
cat &gt; $PKG/install/slack-desc &lt;&lt;_EOF
$PRGNAM: moreicons (extra icons) 
$PRGNAM:
$PRGNAM: Puts a couple of extra icons into
$PRGNAM: /usr/share/pixmaps directory
$PRGNAM: sw.png, home.png
$PRGNAM:
$PRGNAM: Used in wbar, idesk etc.
$PRGNAM:
$PRGNAM:
$PRGNAM: SlackBuild created 19 Feb 2013
$PRGNAM:
_EOF</pre>
</div>Finally, we build the package.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 66px;
		text-align: left;
		overflow: auto"># Make the package
cd $PKG
/sbin/makepkg -l y -c n $CWD/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}</pre>
</div>I have included the moreicons.SlackBuild.txt as an attachment in case anybody would like to use it as a template.</div>


<!-- attachments -->
	<div style="margin-top:10px">

		
		
		
		
			<fieldset class="fieldset">
				<legend>Attached Files</legend>
				<table cellpadding="0" cellspacing="3" border="0">
				<tr>
	<td><img class="inlineimg" src="https://lqo-thequestionsnetw.netdna-ssl.com/questions/images/attach/txt.gif" alt="File Type: txt" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
	<td><a href="http://www.linuxquestions.org/questions/blog_attachment.php?attachmentid=88&amp;d=1361346256">moreicons.SlackBuild.txt</a> (1.2 KB, 3 views)</td>
</tr>
				</table>
			</fieldset>
		

	</div>
<!-- / attachments -->
]]></content:encoded>
			<dc:creator>psionl0</dc:creator>
			<guid isPermaLink="true">http://www.linuxquestions.org/questions/blog.php?b=35325</guid>
		</item>
		<item>
			<title><![CDATA[Using Slackware's Package Management]]></title>
			<link>http://www.linuxquestions.org/questions/blog.php?b=4044</link>
			<pubDate>Fri, 19 Aug 2011 13:50:10 GMT</pubDate>
			<description><![CDATA[Slackware's package management system is very simple and effective. Run *installpkg* and all the files in the package get installed in the right...]]></description>
			<content:encoded><![CDATA[<div>Slackware's package management system is very simple and effective. Run <b>installpkg</b> 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 <b>/var/log/packages</b>. The time stamp on the file in /var/log/packages also tells you <i>when</i> the package was installed (very handy sometimes). <br />
<br />
Of course, if you no longer need the package then you can run <b>removepkg</b> and all of the package's files (not shared by other packages) get removed and a record of the removal is stored in <b>/var/log/removed-packages</b>. The lack of automatic dependency resolution is an advantage here because you can be sure that removing the package won't clobber another package.<br />
<br />
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.<br />
<br />
I recently needed to install nvidia on my PC because the noveau drivers would not work correctly on this mode. This wasn't hard. <b>src2pkg</b> made Slackware packages out of the <b>nvidia-kernels</b> and <b>nvidia-drivers</b> and both installed without incident.<br />
<br />
In order to replace noveau with nvidia I needed to create two files: one was <b>/etc/X11/xorg.conf</b> (generated by running <b>nvidia-xconfig</b>) and the other was <b>/etc/modprobe.d/disable-nouveau.conf</b> 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.<br />
<br />
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 2.6.37.6 to 2.6.38.4 (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.<br />
<br />
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.<br />
<br />
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 <b>nvidiaenabled-1.0-noarch-1_gs</b>. Then I <b>cd</b>'d into it. I had to recreate parts of the root directory tree where the files are and I also needed an <b>install</b> directory for the &quot;slack-desc&quot; (the easiest way to create slack-desc is to copy one and edit it). Once the files are in place, you run <b>makepkg</b> to create the package and <b>installpkg</b> to install the files.<br />
<br />
After creating the &quot;slack-desc&quot; in the root directory, these are the commands I used to make the package:<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<pre class="bbcodeblock" dir="ltr" style="
		margin: 0px;
		margin-right: -99999px;
		padding: 3px;
		border: 1px inset;
		width: 98%;
		height: 178px;
		text-align: left;
		overflow: auto"># 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 &quot;n&quot; to changing permissions)</pre>
</div>Although the files were initially present, I ran &quot;<b>installpkg nvidiaenabled-1.0-noarch-1_gs.tgz</b>&quot; (after cd'ing to the /root directory) to ensure that a record was now present in <b>/var/log/packages</b>.<br />
<br />
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.</div>

]]></content:encoded>
			<dc:creator>psionl0</dc:creator>
			<guid isPermaLink="true">http://www.linuxquestions.org/questions/blog.php?b=4044</guid>
		</item>
	</channel>
</rss>
