Annotation of wikisrc/tutorials/pkgsrc/pkg_comp_pkg_chk.mdwn, revision 1.1

1.1     ! imil        1: ## Keeping packages up-to-date with pkg_comp and pkg_chk
        !             2: 
        !             3: *Pkgsrc* is a fantastic package management framework, but when it comes to upgrades, some usecases may lead to an unstable situation. Also, if by any chance you have 2 or more NetBSD machines to keep up-to-date, upgrading each one separately could be risky and a real waste of time. Well see how to flawlessly keep your packages up-to-date with minimal risks.
        !             4: 
        !             5: ### pkg_comp
        !             6: 
        !             7: Under *pkgsrc/pkgtools* you will find a great utility called *pkg_comp*. This script permits to handle packages manipulation in a *chroot*ed environment, thus keeping your real packages safe from any misakes.
        !             8: 
        !             9: Let's install *pkg_comp*
        !            10: 
        !            11:        # cd /usr/pkgsrc/pkgtools/pkg_comp
        !            12:        # make install clean
        !            13: 
        !            14: Once done, we will create the *chroot*ed environment:
        !            15: 
        !            16:        # mkdir -p /home/pkg_comp
        !            17:        # cd /home/pkg_comp
        !            18:        # pkg_comp -C test.conf maketemplate
        !            19: 
        !            20: This will create a template file, which will be used to build our fake NetBSD system, but first, we'll have to setup some informations. Using your favourite editor, change the following variables to suit your needs:
        !            21: 
        !            22: * DESTDIR, where the *chroot* will be built
        !            23: * DISTRIBDIR, where pkg_comp fill find your NetBSD binaries sets
        !            24: * SETS_X11 may be set to "no" if you do not intend to use the X Window system
        !            25: 
        !            26: This is my *pkg_comp* configuration:
        !            27:        ...
        !            28:        DESTDIR="/home/pkg_comp/test"
        !            29:        DISTRIBDIR="/home/pkg_comp/dist/NetBSD-5.0.1"
        !            30:        SETS_X11="no"
        !            31:        ...
        !            32: 
        !            33: If you don't yet have NetBSD's binary sets, download them from your favourite mirror and put them in */home/pkg_comp/dist/NetBSD-5.0.1/binary/sets*. Also note that NetBSD's source directory (*/usr/src* in most cases) must exist.
        !            34: 
        !            35: We can now build the *chroot* using the following command:
        !            36: 
        !            37:        # pkg_comp -C test makeroot
        !            38: 
        !            39: From now on, we can enter our *chroot* using the *chroot* target:
        !            40: 
        !            41:        # pkg_comp -C test chroot
        !            42:        PKG_COMP ==> Mounting sandboxed filesystems
        !            43:        PKG_COMP ==> Entering sandbox `/home/pkg_comp/test'
        !            44:        pkg_comp:test.conf# exit
        !            45:        PKG_COMP ==> Unmounting sandboxed filesystems
        !            46: 
        !            47: A very simple method to build a package in the *chroot* is to use the *build* target:
        !            48:        # pkg_comp -C test build pkgtools/pkgfind
        !            49: 
        !            50: But as we want to keep a good control on our packages freshness and build method, we will use another tool: *pkg_chk*.
        !            51: 
        !            52: ### pkg_chk
        !            53: 
        !            54: *pkg_chk* is another tool available under *pkgsrc/pkgtools*. This script reads the content of the *pkgsrc/pkgchk.conf* file and checks if every listed package is up to date. You will have to install *pkg_chk* on the *chroot* as well as in the host.
        !            55: 
        !            56: Let's create a */usr/pkgsrc/pkgchk.conf* file. Please note this must be done **outside** of the chroot, *pkg_comp* uses *pkgsrc*'s directory to read content, but it *mount*s it as a read only partition. Here's an output of the *mount* command inside of the *chroot*:
        !            57: 
        !            58:        /usr/src on /var/chroot/pkg_comp/default/usr/src type null (read-only, local)
        !            59:        /usr/pkgsrc on /var/chroot/pkg_comp/default/usr/pkgsrc type null (read-only, local)
        !            60:        /usr/pkgsrc/distfiles on /var/chroot/pkg_comp/default/pkg_comp/distfiles type null (local)
        !            61:        /usr/pkgsrc/packages on /var/chroot/pkg_comp/default/pkg_comp/packages type null (local)
        !            62: 
        !            63: As you can see, generated packages will be written to */usr/pkgsrc/packages* and we are allowed to *fetch distfiles* to */usr/pkgsrc/distfiles*, but */usr/pkgsrc* and */usr/src* are not writables.
        !            64: 
        !            65:        # pkg_chk -g
        !            66: 
        !            67: This command will generate an initial pkgchk.conf file based upon the packages installed on the host machine.
        !            68: 
        !            69: Now, enter the *chroot* as we must configure its *etc/mk.conf* file:
        !            70: 
        !            71:        # no X11
        !            72:        MKX11=no
        !            73:        # clean dependencies when the "clean" target is called
        !            74:        CLEANDEPENDS=yes
        !            75:        # everybody likes vim
        !            76:        ACCEPTABLE_LICENSES+=vim-license
        !            77:        # we want to build packages fo every software
        !            78:        DEPENDS_TARGET=package
        !            79:        UPDATE_TARGET=package
        !            80: 
        !            81: Everything is now ready. *pkg_chk* has many uptions, but we will keep its use very simple.
        !            82: 
        !            83: To see what operations are going to take place without actually doing anything, use the following switches:
        !            84: 
        !            85:        pkg_comp:test.conf# pkg_chk -uan
        !            86: 
        !            87: When ready, call *pkg_chk* this way:
        !            88: 
        !            89:        pkg_comp:test.conf# pkg_chk -ua
        !            90: 
        !            91: Depending on how many packages you must generate, this operation could be a rather long one.
        !            92: 
        !            93: Once the packages creation is finished, you may logout from *pkg_comp* and update your host's packages using binaries created by *pkg_comp*'s *pkg_chk*:
        !            94: 
        !            95:        # pkg_chk -uab
        !            96: 
        !            97: As *pkg_chk manpage* says:
        !            98: 
        !            99:        -b      Use binary packages.  If -s is not set this allows pkg_chk to
        !           100:                run without PKGSRCDIR.
        !           101: 
        !           102: Here we are ! massive upgrade, no harm, no pain.
        !           103: 
        !           104: ### Upgrading more than one machine with pkgin
        !           105: 
        !           106: A convenient method to upgrade more than one machine is to use *pkgtools/pkgin*, a remote package installation and upgrade utility being able to handle packages dependencies.
        !           107: 
        !           108: In the machine hosting binary packages, install an HTTP or FTP server being able to access the directory where your binary packages are located. For example, using *www/lighttpd*:
        !           109: 
        !           110:        ...
        !           111:        dir-listing.activate = "enable"
        !           112:        ...
        !           113:        $HTTP["host"] == "pkgsrc.home.imil.net" {
        !           114:                server.document-root = "/usr/pkgsrc/packages"
        !           115:        }
        !           116:        ...
        !           117: 
        !           118: In this directory, create a *pkg_summary.bz2* file, where all packages, dependencies and descriptions will be available:
        !           119: 
        !           120:        # cd /usr/pkgsrc/packages/All
        !           121:        # pkg_info -X * | bzip2 > pkg_summary.bz2
        !           122: 
        !           123: Then, on the machine to be upgraded, install *pkgin* :
        !           124: 
        !           125:        # pkg_add -v ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/5.0/databases/sqlite3-3.6.17.tgz
        !           126:        # pkg_add -v ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/5.0/pkgtools/pkgin-0.2.5.tgz
        !           127: 
        !           128: And put your own repository in */usr/pkg/etc/pkgin/repositories.conf*:
        !           129: 
        !           130:        http://pkgsrc.home.imil.net/All
        !           131: 
        !           132: Update *pkgin*'s database:
        !           133: 
        !           134:        # pkgin up
        !           135: 
        !           136: And upgrade your packages:
        !           137: 
        !           138:        # pkgin full-upgrade
        !           139: 
        !           140: There you go !

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb