TARGET=${config_name%-*} BRANCH=${config_name##*-} SANDBOX_NAME=$TARGET-$BRANCH SANDBOX_TYPE=netbsd-release SANDBOX_ROOT=/home/pbulk/$SANDBOX_NAME #SANDBOX_SCR=/scratch2/pbulk/$SANDBOX_NAME SANDBOX_SCR= SANDBOX_SCAN_CLIENTS=16 SANDBOX_BUILD_CLIENTS=8 SANDBOX_BUILD_UID=9997 NETBSD_RELEASE_RELEASEDIR="/home/pbulk/release-$TARGET" case $TARGET in *amd64*) NETBSD_RELEASE_SETS="etc.tar.xz base.tar.xz comp.tar.xz text.tar.xz misc.tar.xz xetc.tar.xz xbase.tar.xz xcomp.tar.xz";; *) NETBSD_RELEASE_SETS="etc.tgz base.tgz comp.tgz text.tgz misc.tgz xetc.tgz xbase.tgz xcomp.tgz";; esac PKGSRC="/home/pbulk/pkgsrc-$BRANCH" DISTFILES="/home/pbulk/distfiles" PACKAGES="/home/pbulk/packages-$SANDBOX_NAME" FINAL="/home/pbulk/final-$SANDBOX_NAME" REPORTS="/home/pbulk/www/pkgsrc/packages/reports/$BRANCH/$TARGET" RECIPIENT="mlelstv@XXXXXXXXXX" SUBJECT_PREFIX="pkgsrc-$SANDBOX_NAME" BASE_URL="http://victory.netbsd.org/pkgsrc/packages/reports/$BRANCH/$TARGET" post_create_hook() { local master sclients bclients b master=yes sclients=$(echo $(jot -b / $SANDBOX_SCAN_CLIENTS 1)) bclients=$(echo $(jot -w /s $SANDBOX_BUILD_CLIENTS 1)) chroot $SANDBOX_ROOT useradd \ -m -u $SANDBOX_BUILD_UID pbulk chroot $SANDBOX_ROOT mkdir -m 755 \ /usr/pkg \ /usr/pkgbulk \ /usr/pkgbulk/etc \ /pbulk mount_null -o ro ${NETBSD_RELEASE_RELEASEDIR}/All $SANDBOX_ROOT/mnt chroot $SANDBOX_ROOT env PKG_PATH=/mnt pkg_add \ -K /usr/pkgbulk/.pkgdb \ -p /usr/pkgbulk \ pbulk libkver rsync digest mozilla-rootcerts-openssl umount $SANDBOX_ROOT/mnt # XXX patches cp ${NETBSD_RELEASE_RELEASEDIR}/pbulk.conf \ $SANDBOX_ROOT/usr/pkgbulk/etc/. find $SANDBOX_ROOT/usr/pkgbulk/ -type f -printx \ | xargs sed -i \ -e 's,/usr/pkg/etc/pbulk,/usr/pkgbulk/etc/pbulk,g' \ -e 's,/usr/pkg/bin/pbulk,/usr/pkgbulk/bin/pbulk,g' \ -e 's,/usr/pkg/libexec/pbulk,/usr/pkgbulk/libexec/pbulk,g' sed -i \ -e 's,/usr/pkg/,/usr/pkgbulk/,g' \ $SANDBOX_ROOT/usr/pkgbulk/sbin/kver \ sed -i \ -e '1i\ ulimit -n unlimited \ ulimit -p unlimited \ ulimit -r unlimited \ ulimit -t 43200 \ ' \ -e 's#^\(base_url\)=.*#\1='"$BASE_URL"'#' \ -e 's#^\(reuse_scan_results\)=.*#\1=no#' \ -e 's#^\(master_mode\)=.*#\1="'"$master"'"#' \ -e 's#^\(master_ip\)=.*#\1="localhost"#' \ -e 's#^\(scan_clients\)=.*#\1="'"$sclients"'"#' \ -e 's#^\(build_clients\)=.*#\1="'"$bclients"'"#' \ -e 's#^\(pkg_rsync_args\)=.*#\1="-av --delete-excluded -e ssh"#' \ -e 's#^\(pkg_rsync_target\)=.*#\1='/pbulk/final'#' \ -e 's#^\(report_rsync_args\)=.*#\1="-avz --delete-excluded -e ssh"#' \ -e 's#^\(report_rsync_target\)=.*#\1='"/pbulk/reports"'#' \ -e 's#^\(report_subject_prefix\)=.*#\1='"$SUBJECT_PREFIX"'#' \ -e 's#^\(report_recipients\)=.*#\1='"$RECIPIENT"'#' \ -e 's#^\(ignore_missing_dependencies\)=.*#\1=yes#' \ -e 's#^\(skip_age_check\)=.*#\1=yes#' \ -e 's#^\(bulklog\)=.*#\1="/pbulk/bulklog"#' \ -e 's#^\(packages\)=.*#\1="/pbulk/packages"#' \ -e 's#^\(rsync\)=.*#\1="/usr/pkgbulk/bin/rsync"#' \ -e 's#^\(neato\)=.*#\1="/usr/pkgbulk/bin/neato"#' \ -e 's#^\(digest\)=.*#\1="/usr/pkgbulk/bin/digest"#' \ $SANDBOX_ROOT/usr/pkgbulk/etc/pbulk.conf cp ${NETBSD_RELEASE_RELEASEDIR}/mk.conf $SANDBOX_ROOT/etc/ sed -i \ -e 's#^\(WRKOBJDIR *\)=.*#\1= /pbulk/work#' \ -e 's#^\(PACKAGES *\)=.*#\1= /pbulk/packages#' \ -e 's#^\(DISTDIR *\)=.*#\1= /pbulk/distfiles#' \ -e 's#^\(PBULK_CACHE_DIRECTORY *\)=.*#\1= /pbulk/cache#' \ $SANDBOX_ROOT/etc/mk.conf # mountpoints mkdir -m 755 -p $SANDBOX_ROOT/usr/pkgsrc mkdir -m 755 -p $SANDBOX_ROOT/pbulk/bulklog mkdir -m 755 -p $SANDBOX_ROOT/pbulk/cache mkdir -m 755 -p $SANDBOX_ROOT/pbulk/distfiles mkdir -m 755 -p $SANDBOX_ROOT/pbulk/final mkdir -m 755 -p $SANDBOX_ROOT/pbulk/packages mkdir -m 755 -p $SANDBOX_ROOT/pbulk/reports mkdir -m 755 -p $SANDBOX_ROOT/pbulk/work # create chroots for build clients for b in $bclients; do case $b in /*) chroot $SANDBOX_ROOT mkdir -m 755 \ "$b" \ "$b/dev" \ "$b/usr" \ "$b/tmp" \ "$b/pbulk" \ "$b/pbulk/bulklog" \ "$b/pbulk/cache" \ "$b/pbulk/distfiles" \ "$b/pbulk/final" \ "$b/pbulk/packages" \ "$b/pbulk/work" \ "$b/proc" # clone master sandbox chroot $SANDBOX_ROOT pax -rw -pe \ /etc \ /dev/MAKEDEV \ /bin \ /sbin \ /lib \ /libexec \ /libdata \ /usr \ /var \ "$b/." # create device nodes chroot $SANDBOX_ROOT sh -c \ "cd '$b/dev' && sh MAKEDEV all" if [ -n "$SANDBOX_SCR" ]; then # create work directories on scratch disk mkdir -m 755 -p \ "$SANDBOX_SCR$b-work" fi ;; esac done } post_mount_hook() { local bclients b bclients=$(echo $(jot -w /s $SANDBOX_BUILD_CLIENTS 1)) # host mail spool sandbox_bindfs -o rw /var/spool/postfix "$SANDBOX_ROOT/var/spool/postfix" # host ssl certs sandbox_bindfs -o rw /etc/openssl "$SANDBOX_ROOT/etc/openssl" # pkgsrc-Tree sandbox_bindfs -o ro $PKGSRC "$SANDBOX_ROOT/usr/pkgsrc" # Distfiles sandbox_bindfs -o rw $DISTFILES "$SANDBOX_ROOT/pbulk/distfiles" # Binary Packages sandbox_bindfs -o rw $PACKAGES "$SANDBOX_ROOT/pbulk/packages" # Final Binary Packages sandbox_bindfs -o rw $FINAL "$SANDBOX_ROOT/pbulk/final" # Reports sandbox_bindfs -o rw $REPORTS "$SANDBOX_ROOT/pbulk/reports" # use first slave build directory on master for rebuilding for b in $bclients; do if [ -n "$SANDBOX_SCR" ]; then sandbox_bindfs -o rw "$SANDBOX_SCR$b-work" "$SANDBOX_ROOT/pbulk/work" else mount_tmpfs -m 1777 tmpfs "$SANDBOX_ROOT/pbulk/work" fi break done # Build Slaves for b in $bclients; do # chroot procfs and ptyfs mount_procfs procfs "$SANDBOX_ROOT$b/proc" mount_ptyfs ptyfs "$SANDBOX_ROOT$b/dev/pts" # /tmp as RAM-Disk mount_tmpfs -m 1777 tmpfs "$SANDBOX_ROOT$b/tmp" # chroot /usr/pkg on tmpfs mount_tmpfs -m 1777 tmpfs "$SANDBOX_ROOT$b/usr/pkg" # pkgsrc-Tree sandbox_bindfs -o ro $PKGSRC "$SANDBOX_ROOT$b/usr/pkgsrc" # share pbulk logs with master sandbox_bindfs -o rw "$SANDBOX_ROOT/pbulk/bulklog" "$SANDBOX_ROOT$b/pbulk/bulklog" # share pbulk cache with master sandbox_bindfs -o rw "$SANDBOX_ROOT/pbulk/cache" "$SANDBOX_ROOT$b/pbulk/cache" if [ -n "$SANDBOX_SCR" ]; then # Work directory on scratch disk sandbox_bindfs -o rw "$SANDBOX_SCR$b-work" "$SANDBOX_ROOT$b/pbulk/work" else # Work directory on tmpfs mount_tmpfs -m 1777 tmpfs "$SANDBOX_ROOT$b/pbulk/work" fi # Distfiles sandbox_bindfs -o rw $DISTFILES "$SANDBOX_ROOT$b/pbulk/distfiles" # Binary Packages sandbox_bindfs -o rw $PACKAGES "$SANDBOX_ROOT$b/pbulk/packages" # Final Binary Packages sandbox_bindfs -o rw $FINAL "$SANDBOX_ROOT$b/pbulk/final" # Make sure it can be accessed by build user chroot $SANDBOX_ROOT chown -h pbulk "$b/pbulk/work" # sandboxctl created resolver config when mounting, dup it to slave chroot $SANDBOX_ROOT cp /etc/resolv.conf "$b/etc/." # create build user home chroot $SANDBOX_ROOT mkdir -p -m 755 "$b/home/pbulk" chroot $SANDBOX_ROOT chown pbulk "$b/home/pbulk" # Fix up config files chroot $SANDBOX_ROOT pax -rw -pe \ /etc \ /usr/pkgbulk/etc \ "$b/." done } pre_unmount_hook() { local bclients b bclients=$(echo $(jot -w /s $SANDBOX_BUILD_CLIENTS 1)) # manual umount of Build Slaves # umounts are too slow for the auto cleanup timeout for b in $bclients; do umount -f "$SANDBOX_ROOT$b/pbulk/work" umount -f "$SANDBOX_ROOT$b/pbulk/packages" umount -f "$SANDBOX_ROOT$b/pbulk/final" umount -f "$SANDBOX_ROOT$b/pbulk/distfiles" umount -f "$SANDBOX_ROOT$b/pbulk/cache" umount -f "$SANDBOX_ROOT$b/pbulk/bulklog" umount -f "$SANDBOX_ROOT$b/usr/pkgsrc" umount -f "$SANDBOX_ROOT$b/usr/pkg" umount -f "$SANDBOX_ROOT$b/tmp" umount -f "$SANDBOX_ROOT$b/dev/pts" umount -f "$SANDBOX_ROOT$b/proc" # with /usr/pkg gone, erase the pkgdb chroot $SANDBOX_ROOT rm -rf "$b/var/db/pkg" chroot $SANDBOX_ROOT rm -rf "$b/var/db/pkg.refcount" # and user homes chroot $SANDBOX_ROOT rm -rf "$b/home" done # never fail true } post_destroy_hook() { local bclients b bclients=$(echo $(jot -w /s $SANDBOX_BUILD_CLIENTS 1)) if [ -n "$SANDBOX_SCR" ]; then # destroy work directories on scratch disk for b in $bclients; do case $b in /*) rm -rf -- \ "$SANDBOX_SCR$b-work" ;; esac done fi }