Source Packages

1. Source based packages systems

Tasks and goals; see presentation "Easy Software Installation on Linux, Solaris, NetBSD etc. using pkgsrc" (slides, paper).

Alternatives: SRPM, Debian, Gentoo portage, pkgsrc, ...

2. Example: pkgsrc

Originally a spinoff of FreeBSD, "pkgsrc" is NetBSD's native packages system today. The pkgsrc system allows to build packages from source through a set of simple commands. Besides supporting all the hardware platforms that NetBSD runs on, pkgsrc was extended to work on a number of other operating systems (Solaris, Linux, Irix, MacOS X, etc.).

List of packages: http://www.NetBSD.org/packages/

Installation happens with a few simple commands:

Usually only "make install" needs to be run, the other steps will be run automatically. If further packages need to be installed, they will be installed automatically in the process.

Exercises:

2.1 pkgsrc as a collection of construction manuals - Makefiles

The "construction manuals" for packages in pkgsrc are Makefile. The complete build process is controlled by variables:

Exercises:

2.2 Dependencies

As described earlier, dependencies in today's Open Source systems are both very important, and very complex. pkgsrc knows two ways to express dependencies, the "DEPENDS" variable and buildlink files:

  1. DEPENDS:
    rfhpc8317% cd /home1/NetBSD/cvs/pkgsrc/
    rfhpc8317% grep ^DEPEND meta-pkgs/kde3/Makefile
    DEPENDS+=       kdeartwork-3.1.4:../../misc/kdeartwork3
    DEPENDS+=       kdeaddons-3.1.4:../../misc/kdeaddons3
    DEPENDS+=       kdeadmin-3.1.4:../../misc/kdeadmin3
    DEPENDS+=       kdeedu-3.1.4:../../misc/kdeedu3
    DEPENDS+=       kdegames-3.1.4:../../games/kdegames3
    DEPENDS+=       kdegraphics-3.1.4:../../graphics/kdegraphics3
    DEPENDS+=       kdemultimedia-3.1.4:../../audio/kdemultimedia3
    DEPENDS+=       kdenetwork-3.1.4:../../net/kdenetwork3
    DEPENDS+=       kdepim-3.1.4:../../misc/kdepim3
    DEPENDS+=       kdetoys-3.1.4:../../games/kdetoys3
    DEPENDS+=       kdeutils-3.1.4:../../misc/kdeutils3
    DEPENDS+=       quanta-3.1.4:../../www/quanta3
    
    The variable DEPENDS is assigned pairs of the form "name-version:directory". "name-version" are the name and the version of the required package, "directory" is a path relative to the current package's directory which is the directory from which the package can be installed, if it is not already installed.

    Exercises:

  2. buildlink3.mk files:

    Packages which require information about a certain other package pull this information right from that other package, without storing redundant information like the current version number, etc.:

    The buildlink files contain other information, which are helpful when using the package, e.g.:

    With the help of a number of variables, information is passed to the pkgsrc system, containing the following information:

    Exercises:

3. Installing packages as root under NetBSD

Originally, pkgsrc was made to install packages on a system-wide base, i.e. with root permissions, on NetBSD.

Demo: compiling and installing the xteddy package.

4. Installing packages as non-root user on NetBSD

As no root permissions are available to install software during lecture or exercises, some adjustmends need to be made to install packages in the home directory.

Directory Layout:

Procedure:

  1. Preparations:
    rfhpc8133% ssh shell.cs.stevens.edu
    murky% mkdir $HOME/OS
    murky% cd $HOME/OS
    murky% wget -q http://www.feyrer.de/OS/pkgsrc_env_no-root
    murky% setenv MAKECONF `pwd`/pkgsrc_env_no-root
    murky% ls -la $MAKECONF
    -rw-rw-r--  1 feyrer  cs  816 Oct  6 04:46 /usr/faculty/cs/feyrer/OS/pkgsrc_env_no-root
    murky% ln -s /usr/pkgsrc .
    
  2. Installing example package:
    murky% cd pkgsrc/misc/figlet/
    murky% make
    ...
    murky% make install
    ...
    
  3. Use pkg_* on our(!) packages:
    murky% setenv PKG_DBDIR $HOME/OS/OS-NetBSD/db/pkg
    murky% pkg_info
    murky% pkg_info figlet
    murky% pkg_info -qL figlet
    
  4. Set path and run program:
    murky% set path= ( $HOME/OS/OS-NetBSD/pkg/bin $path )
    murky% rehash
    murky% which figlet
    /net/rfhs8012/home3/bedienst/feyrer/OS/OS-NetBSD/pkg/bin/figlet
    murky% figlet Hello World
     _   _      _ _        __        __         _     _ 
    | | | | ___| | | ___   \ \      / /__  _ __| | __| |
    | |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` |
    |  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |
    |_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_|
                                                        
    
Übungen:

5. Using pkgsrc on other operating systems

Procedure:
  1. Build NetBSD tools according to instructions at http://pkgsrc.org/ as follows:
  2. Check out pkgsrc from anoncvs (or use/copy from /usr/pkgsrc on heineken.cs.stevens.edu):
    noon% ssh heineken.cs.stevens.edu
    heineken% cd $HOME/OS
    heineken% wget -q http://www.feyrer.de/OS/pkgsrc_env_no-root
    heineken% setenv MAKECONF `pwd`/pkgsrc_env_no-root
    heineken% ls -la $MAKECONF
    -rw-rw-r--  1 feyrer  cs  816 Oct  6 04:46 /usr/faculty/cs/feyrer/OS/pkgsrc_env_no-root
    heineken% 
    heineken% env CVS_RSH=ssh \
    ? cvs -d anoncvs@anoncvs.netbsd.org:/cvsroot co \
    ? pkgsrc/bootstrap \
    ? pkgsrc/pkgtools/libnbcompat \
    ? pkgsrc/net/tnftp \
    ? pkgsrc/pkgtools/digest \
    ? pkgsrc/archivers/pax \
    ? pkgsrc/pkgtools/mtree \
    ? pkgsrc/pkgtools/pkg_install
    U pkgsrc/bootstrap/README
    ...
    
  3. Bootstrap tools:
    heineken% cd pkgsrc/bootstrap/
    heineken% setenv MY_HOME $HOME/OS/OS-`uname -s`
    heineken% setenv LOCALBASE ${MY_HOME}/pkg
    heineken% setenv PKG_DBDIR ${MY_HOME}/db/pkg
    heineken% ./bootstrap \
    ?         --prefix=${LOCALBASE} \
    ?         --pkgdbdir=${PKG_DBDIR} \
    ?         --ignore-user-check
    ===> bootstrap command: ./bootstrap --prefix=/home/feyrer/OS/OS-Linux/pkg --pkgdbdir=/home/feyrer/OS/OS-Linux/db/pkg --ignore-user-check
    ===> bootstrap started: Mon Aug 15 23:38:05 EDT 2005
    Working directory is: work
    ===> running: /bin/sed -e 's|@DEFAULT_INSTALL_MODE@|'0755'|' files/install-sh.in > work/install-sh
    ===> running: /bin/chmod +x work/install-sh
    ===> building as unprivileged user feyrer/cs
    ===> Building libnbcompat
    .....
    ...
    .
    ...
    .....
    ===> Installing packages(7) man page
    ===> running: /bin/sh work/install-sh -c -m 444 files/packages.cat7 /home/feyrer/OS/OS-Linux/pkg/man/cat7/packages.0
    
    Please remember to add /home/feyrer/OS/OS-Linux/pkg/bin to your PATH environment variable 
    and /home/feyrer/OS/OS-Linux/pkg/man to your MANPATH environment variable, if necessary.  
    
    An example mk.conf file "work/mk.conf.example" with the settings you
    provided to "bootstrap" has been created for you.
    Please copy work/mk.conf.example to /home/feyrer/OS/OS-Linux/pkg/etc/mk.conf.
    
    You can find extensive documentation of the NetBSD Packages Collection
    in /home/feyrer/OS/pkgsrc/doc/pkgsrc.txt and packages(7).
    
    Hopefully everything is now complete.
    Thank you 
    ===> bootstrap started: Mon Aug 15 23:38:05 EDT 2005
    ===> bootstrap ended:   Mon Aug 15 23:41:00 EDT 2005
    heineken% 
    heineken% 
    heineken% cd $MY_HOME/pkg
    heineken% ls
    bin    lib    man    sbin   share
    heineken% ls *bin
    bin:
    bmake  cpio  digest  ftp  pax  tar
    
    sbin:
    linkfarm  mtree  pkg_add  pkg_admin  pkg_create  pkg_delete
    pkg_info  pkg_view
    
  4. Adjust paths etc., see above:
    heineken% cd $HOME/OS/OS-`uname -s`/pkg
    heineken% set path=( `pwd`/bin `pwd`/sbin $path )
    heineken% rehash
    heineken%
    heineken% cd $HOME/OS
    heineken% mv pkgsrc pkgsrc.bootstrap
    heineken% ln -s /usr/pkgsrc .
    heineken% 
    heineken% setenv MAKECONF `pwd`/pkgsrc_env_no-root
    heineken% setenv PKG_DBDIR $HOME/OS/OS-`uname -s`/db/pkg
    heineken% pkg_info
    digest-20050731     Message digest wrapper utility
    
  5. Compile packages etc. as above. Beware to use the BSD compatible "bmake" instead of "make"!

    heineken% cd $HOME/OS/pkgsrc/misc/figlet/
    heineken% bmake
    ...
    heineken% bmake install
    ...
    heineken% pkg_info
    digest-20050731     Message digest wrapper utility
    figlet-2.2.1nb2     Print text banners in fancy ASCII art characters
    heineken% rehash
    heineken% which figlet
    /usr/faculty/cs/feyrer/OS/OS-Linux/pkg/bin/figlet
    heineken% figlet Hello `uname -s`
     _   _      _ _         _     _                  
    | | | | ___| | | ___   | |   (_)_ __  _   ___  __
    | |_| |/ _ \ | |/ _ \  | |   | | '_ \| | | \ \/ /
    |  _  |  __/ | | (_) | | |___| | | | | |_| |>  < 
    |_| |_|\___|_|_|\___/  |_____|_|_| |_|\__,_/_/\_\
                                                         
    
Exercises:
(c) Copyright 2003-2005 Hubert Feyrer
$Id: srcpkg.html,v 1.2 2005/11/26 22:47:39 feyrer Exp $ Translated from: Id: srcpkg.html,v 1.12 2005/01/19 10:12:06 feyrer Exp