Pages

Wednesday, January 18, 2012

Slackware package and patch server

With this article I want you to show how to setup a package and patch server for Slackware. When you have multiple Slackware servers running and you need to install updates then every single server has to download each update from the internet:


When you have a server that holds all patches then you have only to download each patch once from the internet:


The advantage is that you have all packages and patches directly in your own environment and that you don't have to download a single package to multiple hosts.
The article covers the following topics:

Create a package server via http
Add patches to the package server
Setup the clients with slackpkg or slapt-get

Create a package server via http

Creating a package server is very easy, just define a space where you can place the content of the DVD or the CD's and copy the content to it:

# mkdir -p /export/slackware/slackware64-13.1
# mount /dev/sr0 /mnt/dvd
# rsync -av /mnt/dvd/ /export/slackware/slackware64-13.1

Next make sure that your webserver supports symbolic links. I assume you are using the shipped Apache webserver.
If you have placed the packages under a directory that is accesable for your webserver then you can avoid this step.

# vi /etc/httpd/httpd.conf
...
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
...

And create a symbolic link in the root directory of your webserver that points to the locally stored packages:

# cd /var/www/htdocs
# ln -s /export/slackware slackware

Next start your webserver:

# chmod 755 /etc/rc.d/rc.httpd
# /etc/rc.d/rc.httpd start

Finally test if it works:

# cd
# wget http://192.168.56.4/slackware/slackware64-13.1/PACKAGES.TXT
--2012-01-11 15:18:13--  http://192.168.56.4/slackware/slackware64-13.1/PACKAGES.TXT
Connecting to 192.168.56.4:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 542310 (530K) [text/plain]
Saving to: "PACKAGES.TXT"
100%[==============================================================================>] 542,310     --.-K/s   in 0.006s
2012-01-11 15:18:13 (89.9 MB/s) - "PACKAGES.TXT" saved [542310/542310]

Add patches to the package server

Now you need to add the patches to your server. I use wget for this. Just go into the directory that holds the packages for your Slackware release:

# cd /export/slackware/slackware64-13.1

Then run the following wget command:

# wget --mirror --no-host-directories --passive-ftp --no-parent --cut-dirs=5 --output-file=/var/log/mirror.log ftp://ftp.heanet.ie/mirrors/ftp.slackware.com/pub/slackware/slackware64-13.1/

The command above will add the patches to your server. Here is short explaination of the options I use in the wget command:

--mirror: mirroring with time stamps etc
--no-host-directories: avoids to create the directory ftp.heanet.ie which would be normally done by wget
--passive-ftp: just passive ftp and not active
--no-parent: everything lower then ftp://ftp.heanet.ie/mirrors/ftp.slackware.com/pub/slackware/slackware64-13.1 will not be downloaded
--cut-dirs: avoids creating the 5 subdirectories mirrors/ftp.slackware.com/pub/slackware/slackware64-13.1

Depending on your internet connection and the amount of available patches the wget command could take some time. When the download finished you will have your own mirror. You can use the wget command to create the package server from above but then you have to download the the complete distribution and not just the packages. It also wise to put the wget command into a cronjob that runs daily at eg. 1AM:

# crontab -e
...
00 1 * * * cd /export/slackware/slackware64-13.1; wget --mirror --no-host-directories --passive-ftp --no-parent --cut-dirs=5 --output-file=/var/log/mirror.log ftp://ftp.heanet.ie/mirrors/ftp.slackware.com/pub/slackware/slackware64-13.1/

Setup the client: slackpkg

slackpkg is an apt-get like tool for Slackware packages. It is already shipped and should be installed on your system. Configuring slackpkg is extremely easy. You can leave the slackpkg.conf file as it is, just add your local package server to the mirror file:

# cd /etc/slackpkg
# mv mirrors mirrors.orig
# vi mirrors
http://192.168.1.73/slackware/slackware64-13.1/

Next run slackpkg with the update option to get a catalog of all available packages

# slackpkg update
Updating the package lists...
        Downloading...
...

The next 4 examples are for searching, installing, removing and upgrading a package with slackpkg:

Searching:

# slackpkg search libpng
Looking for libpng in package list. Please wait... DONE
The list below shows all packages with name matching "libpng".
[uninstalled] - libpng-1.4.2-x86_64-1_slack13.1
You can search specific files using "slackpkg file-search file".

Installing:

# slackpkg install libpng


Removing:

# slackpkg remove libpng


Package: libpng-1.4.8-x86_64-1_slack13.1
        Removing...
Removing package /var/log/packages/libpng-1.4.8-x86_64-1_slack13.1...
Removing files:
...

Upgrading:

# slackpkg upgrade libpng



...
        Upgrading libpng-1.4.8-x86_64-1_slack13.1...

+==============================================================================
| Upgrading libpng-1.4.2-x86_64-1 package using ./libpng-1.4.8-x86_64-1_slack13.1.txz
+==============================================================================

Pre-installing package libpng-1.4.8-x86_64-1_slack13.1...
...

Setup the client: slapt-get

Another apt-get like tool is slapt-get. It is not shipped within the DVD or CD's. You can download a precompiled package or compile the source. I will show you to compile the source here.
First go into the src directory and download the source:

# cd /usr/src
# wget http://software.jaos.org/source/slapt-get/slapt-get-0.10.2l.tar.gz
...

Then extract the source package and change into the new directory:

# tar xf slapt-get-0.10.2l.tar.gz
# cd slapt-get-0.10.2l

Compile the source and install the binaries etc:

# make
...
# make install
...

Next configure slapt-get by adding your local package server:

# cd /etc/slapt-get/
# mv slapt-getrc slapt-getrc.orig
# vi /etc/slapt-get/slapt-getrc
WORKINGDIR=/var/slapt-get
EXCLUDE=^aaa_elflibs,^devs,^glibc-.*,^kernel-.*,^udev,.*-[0-9]+dl$,i[3456]86
SOURCE=http://192.168.56.4/slackware/slackware64-13.1/
SOURCE=http://192.168.56.4/slackware/slackware64-13.1/patches/
SOURCE=http://192.168.56.4/slackware/slackware64-13.1/extra/

Then run slapt-get with the --update option to get a catalog of all available packages:

# slapt-get --update
Retrieving package data [http://192.168.56.4/slackware/slackware64-13.1/]...Done
Retrieving patch list [http://192.168.56.4/slackware/slackware64-13.1/]...Done
Retrieving checksum list [http://192.168.56.4/slackware/slackware64-13.1/]...Done
Retrieving checksum signature [http://192.168.56.4/slackware/slackware64-13.1/]...Done
Verifying checksum signature [http://192.168.56.4/slackware/slackware64-13.1/]...Verified
Retrieving ChangeLog.txt [http://192.168.56.4/slackware/slackware64-13.1/]...Done
...
Reading Package Lists...Done

The next 4 examples are for searching, installing, removing and upgrading a package with slackpkg:

Searching:

# slapt-get --search libpng
libpng-1.4.2-x86_64-1 [inst=no]: libpng (Portable Network Graphics library)

Installing:

# slapt-get --install libpng
Reading Package Lists... Done
The following NEW packages will be installed:
  libpng
0 upgraded, 0 reinstalled, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 524.0kB of archives.
After unpacking 3.3MB of additional disk space will be used.
...
Executing install script for libpng-1.4.2-x86_64-1.txz.
Package libpng-1.4.2-x86_64-1.txz installed.
Done

Removing:

# slapt-get --remove libpng
Reading Package Lists... Done
The following packages will be REMOVED:
  libpng
0 upgraded, 0 reinstalled, 0 newly installed, 1 to remove and 0 not upgraded.
After unpacking 3.3MB disk space will be freed.
Do you want to continue? [y/N] y
...
Removing package /var/log/packages/libpng-1.4.2-x86_64-1_slack13.1...
Removing files:
...
Done

Upgrading:

# slapt-get --upgrade
Reading Package Lists... Done
The following packages have been EXCLUDED:
...
The following packages will be upgraded:
  libpng
1 upgraded, 0 reinstalled, 0 newly installed, 0 to remove and 6 not upgraded.
Need to get 1.0kB/528.0kB of archives.
After unpacking 10.0kB of additional disk space will be used.
Do you want to continue? [y/N] y
Preparing to replace libpng-1.4.2-x86_64-1 with libpng-1.4.8-x86_64-1_slack13.1
...
Package libpng-1.4.2-x86_64-1 upgraded with new package /var/slapt-get/./patches/packages/libpng-1.4.8-x86_64-1_slack13.1.txz.
Done

No comments:

Post a Comment