Add note aobut old bootstraps, clean up whitespace
[ikiwiki.git] / docs / developer / PbulkBuilding.mdwn
1 ## Bulk build notes 
2
3 Joerg Sonnenberger's new bulk building interface is located in pkgtools/pbulk.  On pkgbox, this is located in /archive/NetBSD-pkgsrc.
4
5 To do this without affecting the existing pkgsrc setup on the machine you are using, you create a chroot and install pkgsrc twice inside it - once for pbulk and the various support programs, and once for the actual pkgsrc where everything is built.
6
7 These notes are taken from Justin Sherrill's test builds on pkgbox.dragonflybsd.org, and from suggestions from Joerg.  This reflects using version 0.36 of pbulk.
8
9 ### Setting up the chroot 
10
11 If getting rid of an earlier install, delete all the files you can, adjust the permissions on the ones left, and then delete what remains.
12
13     rm -rf /build/pbulk_chroot
14     chflags -R noschg /build/pbulk_chroot
15     rm -rf /build/pbulk_chroot
16
17 Create dir for chroot
18
19     mkdir /build/pbulk_chroot
20
21 Add files to chroot
22
23     cd /usr/src
24
25 If there was no prior buildworld in this , you'll need to do this step 
26
27     make DESTDIR=/build/pbulk_chroot buildworld
28
29 Add world to chroot
30
31     make DESTDIR=/build/pbulk_chroot installworld
32
33 note that this is not /etc, but /usr/src/etc
34
35     cd etc
36     make DESTDIR=/build/pbulk_chroot distribution
37
38 Additional files that will be needed in the chroot
39
40     cp /etc/resolv.conf /build/pbulk_chroot/etc
41
42 Make sure you've loaded the linux module if you don't want to get unnecessary messages about unknown ELF types.
43
44     kldload linux.ko
45
46 Jeremy C. Reed has a large repository of the distfiles for pkgsrc in another directory outside of the chroot; mounting it and adding it to DIST_PATH should make it available, saving the bulk build process (and Matt's bandwidth) from having to download more.
47
48     mkdir /build/pbulk_chroot/archive
49     mount_null /archive /build/pbulk_chroot/archive
50
51 Should be ready to go...
52
53     chroot /build/pbulk_chroot
54     /etc/rc.d/ldconfig start
55
56 ### Adding pkgsrc bootstrap 
57
58 Everything past this point is in the chroot!
59
60     mkdir /bulklog
61     mkdir /scratch
62     mkdir /distfiles
63     mkdir /packages
64
65 Grab the most recent quarterly release of pkgsrc:
66    
67     setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot
68     setenv CVS_RSH ssh
69     cd /usr
70     cvs -q checkout -rpkgsrc-2008Q1 -P pkgsrc
71
72 To update the pkgsrc files later
73
74     cvs -q update -dP
75
76 Put this in /root/mk-base.conf, for use later when building the first bootstrap:
77
78     WRKOBJDIR = /scratch
79     PKGSRCDIR = /usr/pkgsrc
80     DISTDIR = /distfiles
81     DIST_PATH = /archive/distfiles
82     PACKAGES = /packages
83
84     FAILOVER_FETCH= yes
85     _ACCEPTABLE=                    yes
86     ALLOW_VULNERABLE_PACKAGES=      yes
87
88     PKG_DEVELOPER?= yes
89     PKG_DEFAULT_OPTIONS="dri inet6"
90
91 We need to create a clean bootstrap kit for later.  This installs pkgsrc tools into /usr/pkg_bulk, too.
92
93 Keep in mind that if any part of the bootstrap was updated and this is not a from-scratch pbulk setup, you will need to delete all the existing packages in /usr/pkg and in /usr/pkg_bulk using the appropriate pkg_delete.  
94
95     mkdir /usr/pkg_bulk/
96     cd /usr/pkgsrc/bootstrap
97     ./bootstrap --prefix /usr/pkg_bulk --pkgdbdir /usr/pkg_bulk/.pkgdb
98
99     cd /usr/pkgsrc/pkgtools/pbulk
100     env PATH=/usr/pkg_bulk/bin:/usr/pkg_bulk/sbin:${PATH} bmake package
101
102     cd /usr/pkgsrc/bootstrap
103     ./cleanup
104     ./bootstrap --gzip-binary-kit /usr/pkgsrc/bootstrap/bootstrap.tgz --mk-fragment=/root/mk-base.conf
105
106 We need to make a binary kit with the corrected mk.conf so that pbulk is always set up with the right version as it builds/removes/adds packages
107
108     cd /usr/pkgsrc/bootstrap
109     mkdir temp
110     mv bootstrap.tgz temp
111     cd temp
112     tar xf bootstrap.tgz
113     cp /usr/pkg/etc/mk.conf usr/pkg/etc/mk.conf
114     tar hzcf ../bootstrap.tar.gz usr var
115
116 Edit /usr/pkg_bulk/etc/pbulk.conf and change these lines to what is needed.  Be sure to put in a destination for the rsync command, as a side effect of that process is the removal of packages that are not for distribution due to various laws.  If this is being performed on a single machine, nfsmount directories in the chroot so that you can still copy the files around.  The rsync options below assume the packages and report are being copied around on the local machine.
117
118     base_url=http://something/you_should_change_here
119     master_mode=no
120
121     pkg_rsync_args="-av --delete-excluded"
122     pkg_rsync_target="/archive/packages/DragonFly-2.0/pkgsrc-current"
123     report_rsync_args="-avz --delete-excluded"
124     report_rsync_target="/archive/packages/DragonFly-2.0/pbulk_report"
125
126     report_recipients="you@your.email"
127     make=/usr/pkg/bin/bmake
128
129     # optional
130     keep_wrkdir=no
131     keep_prefix=no
132
133 If the system you are building on is a slightly different version than the target for your packages, pkg_add will complain about the difference in uname.  To fix this, change the UNAME_r and UNAME_v environment variables to the desired values before building.
134
135     (before)
136     # uname -v
137     DragonFly 2.1.0-DEVELOPMENT #0: Wed Sep 24 04:26:56 PDT 2008     root@:/usr/obj/usr/src/sys/PKGBOX
138     # uname -r
139     2.1.0-DEVELOPMENT
140
141     # setenv UNAME_v 'DragonFly 2.0.1-RELEASE #0: Wed Sep 24 04:26:56 PDT 2008     root@:/usr/obj/usr/src/sys/PKGBOX'
142     # setenv UNAME_r 2.0.1-RELEASE  
143
144     (after)
145     # uname -v
146     DragonFly 2.0.1-RELEASE #0: Wed Sep 24 04:26:56 PDT 2008     root@:/usr/obj/usr/src/sys/PKGBOX
147     # uname -r
148     2.0.1-RELEASE
149
150 Kick off the bulk build.  It takes a LONG time, so it's worth doing this in a screen session.  Unless you install screen in the same way as pbulk, it won't be available in the chroot, so you may need to get out of the chroot, enter a screen session, and re-enter the chroot before this step.
151
152     /usr/pkg_bulk/bin/bulkbuild
153
154 The line for setting up a rsync server for the mirrors: (do this outside the chroot)
155
156     rsync --daemon --bwlimit#200 --config/usr/pkg/etc/rsync/rsyncd.conf
157
158 If the build stops or pauses or whatever, this line will restart it, for versions 0.28 and older.
159
160     /usr/pkg_bulk/libexec/pbulk/build
161
162 Version 0.29 and later restart the build with this:
163
164     /usr/pkg_bulk/bin/bulkbuild-restart
165