diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:46:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:46:56 +0000 |
commit | 8e79ad9f544d1c4a0476e0d96aef0496ca7fc741 (patch) | |
tree | cda1743f5820600fd8c638ac7f034f917ac8c381 /bin/buildd | |
parent | Initial commit. (diff) | |
download | sbuild-8e79ad9f544d1c4a0476e0d96aef0496ca7fc741.tar.xz sbuild-8e79ad9f544d1c4a0476e0d96aef0496ca7fc741.zip |
Adding upstream version 0.85.6.upstream/0.85.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | bin/buildd | 93 | ||||
-rwxr-xr-x | bin/buildd-mail | 42 | ||||
-rwxr-xr-x | bin/buildd-make-chroot | 97 | ||||
-rwxr-xr-x | bin/buildd-update-chroots | 42 | ||||
-rwxr-xr-x | bin/buildd-uploader | 51 | ||||
-rwxr-xr-x | bin/buildd-vlog | 132 | ||||
-rwxr-xr-x | bin/buildd-watcher | 42 |
7 files changed, 499 insertions, 0 deletions
diff --git a/bin/buildd b/bin/buildd new file mode 100755 index 0000000..41fbf09 --- /dev/null +++ b/bin/buildd @@ -0,0 +1,93 @@ +#!/usr/bin/perl +# +# buildd: daemon to automatically build packages +# Copyright © 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> +# Copyright © 2009 Roger Leigh <rleigh@debian.org> +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +use strict; +use warnings; + +use Buildd::Conf qw(); +use Buildd::Daemon; +use Sbuild::OptionsBase; + +sub shutdown_fast ($); +sub reread_config ($); +sub reopen_log ($); + +my $conf = Buildd::Conf::new(); +exit 1 if !defined($conf); +my $options = Sbuild::OptionsBase->new($conf, "buildd", "1"); +exit 1 if !defined($options); +my $daemon = Buildd::Daemon->new($conf); +exit 1 if !defined($daemon); + +# Global signal handling +foreach (qw(QUIT ILL TRAP ABRT BUS FPE USR2 SEGV PIPE XCPU XFSZ)) { + $SIG{$_} = \&shutdown_fast; +} +$SIG{'HUP'} = \&reopen_log; +$SIG{'USR1'} = \&reread_config; +$SIG{'INT'} = \&shutdown; +$SIG{'TERM'} = \&shutdown; + +exit $daemon->run(); + +sub shutdown_fast ($) { + my $signame = shift; + $daemon->log("buildd ($$) killed by SIG$signame\n") + if defined($daemon); + unlink( $conf->get('PIDFILE') ); + exit 1; +} + +sub shutdown ($) { + my $signame = shift; + + if ($daemon) { + $daemon->shutdown($signame); + } + exit 1; +} + +sub reread_config ($) { + my $signame = shift; + + $daemon->log("buildd ($$) received SIG$signame -- rereading configuration\n") + if defined($daemon); + + $Buildd::Conf::reread_config = 1; +} + +sub reopen_log ($) { + my $signame = shift; + + $daemon->log("buildd ($$) received SIG$signame -- reopening logfile\n") + if defined($daemon); + + $daemon->reopen_log(); +} + +END { + unlink( $conf->get('PIDFILE') ) + if (defined($conf) && + defined($daemon) && + $daemon->get('Daemon')); +} diff --git a/bin/buildd-mail b/bin/buildd-mail new file mode 100755 index 0000000..a45424e --- /dev/null +++ b/bin/buildd-mail @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# +# buildd-mail: mail answer processor for buildd +# Copyright © 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> +# Copyright © 2009 Roger Leigh <rleigh@debian.org> +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +use strict; +use warnings; + +use Buildd::Conf qw(); +use Buildd::Mail; +use Sbuild::OptionsBase; + +my $conf = Buildd::Conf::new(); +exit 1 if !defined($conf); +my $options = Sbuild::OptionsBase->new($conf, "buildd-mail", "1"); +exit 1 if !defined($options); +my $mail = Buildd::Mail->new($conf); +exit 1 if !defined($mail); + +my $status = $mail->run(); + +$mail->close_log(); + +exit $status; diff --git a/bin/buildd-make-chroot b/bin/buildd-make-chroot new file mode 100755 index 0000000..6062968 --- /dev/null +++ b/bin/buildd-make-chroot @@ -0,0 +1,97 @@ +#!/bin/sh -e +# +# Script that uses debootstrap 0.3.2+ to build a build-essential +# chroot for buildd use. +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +# user suite target <mirror> +if [ "$#" -lt "3" ]; then + echo "usage: buildd-make-chroot user suite target <mirror>" + exit 1 +fi + +if [ "$#" -gt "4" ]; then + echo "usage: buildd-make-chroot user suite target <mirror>" + exit 1 +fi + +USER=$1 +SUITE=$2 +if echo "$3" | grep -Eq '^/'; then + TARGET="$3" +else + TARGET="`pwd`/$3" +fi +if [ "$#" -gt "3" ]; then + MIRROR=$4 +else + MIRROR=http://incoming.debian.org/debian +fi +debootstrap --variant=buildd --include=sudo,fakeroot,build-essential $SUITE $TARGET $MIRROR +hostname=`hostname` +echo 127.0.0.1 $hostname localhost > $TARGET/etc/hosts +echo "# put any local/close mirrors at the top of the file" > $TARGET/etc/apt/sources.list +if [ "$#" -gt "3" ]; then + echo "deb $4 $SUITE main contrib" >> $TARGET/etc/apt/sources.list +fi +echo "deb http://incoming.debian.org/debian-debian buildd-$SUITE main contrib" >> $TARGET/etc/apt/sources.list +echo "deb-src http://incoming.debian.org/debian-debian buildd-$SUITE main contrib" >> $TARGET/etc/apt/sources.list +case "$2" in + sid) + ;; + woody) + echo "deb http://non-us.debian.org/debian-non-US $SUITE/non-US main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://non-us.debian.org/debian-non-US $SUITE/non-US main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + echo "deb http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + ;; + sarge) + echo "deb http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + ;; + etch) + echo "deb http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://incoming.debian.org/debian $SUITE-proposed-updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/debian-security $SUITE/updates main contrib" >> $TARGET/etc/apt/sources.list + echo "deb http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + echo "deb-src http://$hostname:PASSWORD@security-master.debian.org/buildd $SUITE/" >> $TARGET/etc/apt/sources.list + ;; +esac +getent passwd $USER | sed -re 's/^([^:]+):x/\1:*/' -e 's/:[^:]+:([^:]+)$/:\/nonexistent:\1/' >> $TARGET/etc/passwd +getent group $USER | sed -re 's/^([^:]+):x/\1:*/' >> $TARGET/etc/group +echo $USER ALL=NOPASSWD: ALL >> $TARGET/etc/sudoers +mkdir -p $TARGET/var/lib/sbuild//srcdep-lock $TARGET/build/$USER +chown -R $USER:$USER $TARGET/var/lib/sbuild $TARGET/build/$USER +chmod -R 02775 $TARGET/var/lib/sbuild +echo include /etc/ld.so.conf.d/*.conf >> $TARGET/etc/ld.so.conf +(cd $TARGET/dev ; ./MAKEDEV fd) +sudo chroot $TARGET dpkg -P debconf-i18n debconf liblocale-gettext-perl libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl procps makedev +echo "Successfully setup chroot for a buildd" +echo Possible commands to append to fstab: +echo echo $SUITE-proc $TARGET/proc proc defaults 0 0 \>\> /etc/fstab +echo echo $SUITE-devpts $TARGET/dev/pts devpts defaults,gid=5,mode=600 0 0 \>\> /etc/fstab diff --git a/bin/buildd-update-chroots b/bin/buildd-update-chroots new file mode 100755 index 0000000..b8d0166 --- /dev/null +++ b/bin/buildd-update-chroots @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# Copyright © 2009 Thibaut VARÈNE <varenet@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +cleanup() { + rm -f ~/NO-DAEMON-PLEASE +} + +touch ~/NO-DAEMON-PLEASE +trap cleanup 0 + +touch ~/EXIT-DAEMON-PLEASE +echo -n Waiting for sbuild and buildd to exit... +while [ -f ~/EXIT-DAEMON-PLEASE ]; do + sleep 10 +done +echo . + +schroot -a -u root -d /root -- apt-get update +echo Upgrading chroots: +schroot -a -u root -d /root -- apt-get dist-upgrade -y +echo Cleaning chroots: +schroot -a -u root -d /root -- apt-get autoremove -y +schroot -a -u root -d /root -- debfoster -f + diff --git a/bin/buildd-uploader b/bin/buildd-uploader new file mode 100755 index 0000000..de172f0 --- /dev/null +++ b/bin/buildd-uploader @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# +# buildd-uploader: upload finished packages for buildd +# Copyright © 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> +# Copyright © 2009 Roger Leigh <rleigh@debian.org> +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +use strict; +use warnings; + +use Buildd qw(unlock_file); +use Buildd::Conf qw(); +use Buildd::Uploader; +use Sbuild::OptionsBase; + +my $conf = Buildd::Conf::new(); +exit 1 if !defined($conf); +my $options = Sbuild::OptionsBase->new($conf, "buildd-uploader", "1"); +exit 1 if !defined($options); +my $uploader = Buildd::Uploader->new($conf); +exit 1 if !defined($uploader); + +my $status = $uploader->run(); + +$uploader->close_log(); + +exit $status; + +END { + unlock_file($conf->get('HOME') . "/buildd-uploader") + if (defined($conf) && + defined($uploader) && + defined($uploader->get('Uploader Lock')) && + $uploader->get('Uploader Lock')); +} diff --git a/bin/buildd-vlog b/bin/buildd-vlog new file mode 100755 index 0000000..3b83efa --- /dev/null +++ b/bin/buildd-vlog @@ -0,0 +1,132 @@ +#!/usr/bin/perl +# +# buildd-vlog: little utility to watch the logs written by sbuild +# Copyright © 1999 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> +# Copyright © 2009 Roger Leigh <rleigh@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +use strict; +use warnings; +use POSIX; + +use Buildd; +use Buildd::Conf qw(); +use Sbuild::OptionsBase; + +my $conf = Buildd::Conf::new(); +exit 1 if !defined($conf); +my $options = Sbuild::OptionsBase->new($conf, "buildd-vlog", "1"); +exit 1 if !defined($options); + +my $logpath = $conf->get('HOME') . '/logs'; + +sub read_progress (); +sub newest_log ($); +sub tail ($); + +while( 1 ) { + + my $curr_pkg = read_progress(); + if (!$curr_pkg) { + print "No build-progress -- waiting\n"; + do { + sleep 5; + } while (!($curr_pkg = read_progress())); + } + + print("package '$curr_pkg'\n"); + + my $logf = newest_log( "$logpath/${curr_pkg}*" ); + + if ($logf eq "") { + sleep(1); + next; + } + + print "\n\n", "="x78, "\n$logf:\n\n"; + + tail( $logf ); +} + +sub read_progress () { + my $f = $conf->get('HOME') . '/build/build-progress'; + my $p = ""; + my $state = ""; + + open( F, "<$f" ) || return ""; + while( <F> ) { + s/_[0-9]+:/_/; + ($p,$state) = ($1,$2) if /^(\S+): (\S+)$/; + } + return "" + if ($state ne "building"); + close( F ); + return $p; +} + +sub newest_log ($) { + my $pattern = shift; + + my @f = glob( $pattern ); + my $maxtime = 0; + my $f = ""; + my @s; + + foreach (@f) { + @s = stat( $_ ); + warn "Cannot stat $_: $!", next if !@s; + if ($s[9] > $maxtime) { + $maxtime = $s[9]; + $f = $_; + } + } + return $f; +} + +sub tail ($) { + my $f = shift; + + my @s = stat( $f ); + if (!@s) { + warn "Cannot stat $f: $!\n"; + return; + } + my $size = $s[7]; + + if (!open( F, "<$f" )) { + warn "Cannot open $f: $!\n"; + return; + } + if ($size > 3*1024) { + seek( F, -3*1024, SEEK_END ); + my $junk = <F>; # throw away first incomplete line + print $size+3*1024, " bytes skipped...\n"; + } + + while( 1 ) { + while( <F> ) { + print $_; + if (/^Build needed \d\d:\d\d:\d\d/) { + close( F ); + sleep( 1 ); + return; + } + } + sleep( 2 ); + } +} diff --git a/bin/buildd-watcher b/bin/buildd-watcher new file mode 100755 index 0000000..5d6a110 --- /dev/null +++ b/bin/buildd-watcher @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# +# buildd-watcher: +# Copyright © 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> +# Copyright © 2009 Roger Leigh <rleigh@debian.org> +# Copyright © 2005 Ryan Murray <rmurray@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +# +####################################################################### + +use strict; +use warnings; + +use Buildd::Conf qw(); +use Buildd::Watcher; +use Sbuild::OptionsBase; + +my $conf = Buildd::Conf::new(); +exit 1 if !defined($conf); +my $options = Sbuild::OptionsBase->new($conf, "buildd-watcher", "1"); +exit 1 if !defined($options); +my $watcher = Buildd::Watcher->new($conf); +exit 1 if !defined($watcher); + +my $status = $watcher->run(); + +$watcher->close_log(); + +exit $status; |