diff options
author | Florent Villard <warly@mandriva.com> | 2006-02-08 14:57:08 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2006-02-08 14:57:08 +0000 |
commit | ec3c198211891840aa8952cd6c6c57dc8706c13f (patch) | |
tree | b64c4c18bf4ee8a2d99af44cb3486a7923e1c5a1 /iurt2 | |
parent | a3f9dac6bfb95627b67eeb569c09256b7dd142d9 (diff) | |
download | iurt-ec3c198211891840aa8952cd6c6c57dc8706c13f.tar iurt-ec3c198211891840aa8952cd6c6c57dc8706c13f.tar.gz iurt-ec3c198211891840aa8952cd6c6c57dc8706c13f.tar.bz2 iurt-ec3c198211891840aa8952cd6c6c57dc8706c13f.tar.xz iurt-ec3c198211891840aa8952cd6c6c57dc8706c13f.zip |
add --stop option to perform a different rpm -bX build command and then have a shell into the chroot
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 57 |
1 files changed, 43 insertions, 14 deletions
@@ -24,6 +24,9 @@ # TODO # # - use a cache (rpmctl cache for example) to find maintainer +# - add a --user option to build into the chroot with an alternate user +# - add a --stop bi option to only do the bi step of rpm compilation and stop afterwards +# - add icecream compilation support # use strict; use Hdlist; @@ -44,6 +47,12 @@ $run{todo} = [ ]; [ "", "$program_name", 0, "[options]", "$program_name rebuild bot", sub { $arg or usage($program_name, \@params) }, "" ], + [ "d", "distro", 1, "", + "Set the distribution", + sub { ($run{distro}) = @_; 1 }, "Setting the distribution" ], + [ "a", "arch", 1, "", + "Set the architecture", + sub { ($run{my_arch}) = @_; 1 }, "Setting architecture" ], [ "", "cache", 0, "", "Use the global cache file", sub { $run{cache} = 1 }, "Activating cache use" ], @@ -83,15 +92,21 @@ $run{todo} = [ ]; $run{distro} = shift @_; $run{my_arch} = shift @_; foreach (@_) { + my ($path, $srpm); if (m,(.*/)([^/]*.src.rpm)$, && -f $_) { - push @{$run{todo}}, [ $1, $2 ]; - print {$run{LOG}} "iurt: force build for $2 (from $1)\n"; + ($path, $srpm) = ( $1, $2 ) } elsif (m,([^/]*.src.rpm)$, && -f $_) { - push @{$run{todo}}, [ './', $1 ]; - print {$run{LOG}} "iurt: force build for $1\n"; + ($path, $srpm) = ( './', $1 ) } else { die "FATAL iurt: $_ does not seems to be a SRPM\n" } + my $hdr = rpm2header($_); + if (check_arch($hdr)) { + print {$run{LOG}} "iurt: force build for $2 (from $1)\n"; + push @{$run{todo}}, [ $path, $srpm ] + } else { + print {$run{LOG}} "ERROR iurt: $_ could not be build on $run{my_arch}, ignored.\n" + } } 1 }, "Activating rebuild mode" ], @@ -117,16 +132,19 @@ $run{todo} = [ ]; [ "w", "warn", 0, "", "Warn maintainer of the packages about problem in the rebuild", sub { $run{warn} = 1 ; 1 }, "Setting warn flag to warn maintainers" ], + [ "", "stop", 1, "<rpm step>", + "Perform rpm -b<rpm step> (p c i) instead of rpm -ba and then open a shell in the chroot", + sub { ($run{stop}) = @_; 1 }, "Setting rpm build option" ], [ "d", "dir", -1, "", "Directory where to find packages to rebuild", - sub { $run{extra_dir} = @_; 1 }, "Adding extra source packages directories" ], + sub { $run{extra_dir} = \@_; 1 }, "Adding extra source packages directories" ], ); open(my $LOG, ">&STDERR"); $run{LOG} = $LOG; -my $todo = parseCommandLine("$program_name", \@ARGV, \@params); -@ARGV and usage("$program_name", \@params, "@ARGV, too many arguments"); +my $todo = parseCommandLine($program_name, \@ARGV, \@params); +@ARGV and usage($program_name, \@params, "@ARGV, too many arguments"); foreach my $t (@$todo) { print {$run{LOG}} "$program_name: $t->[2]\n" if $run{verbose} > 5; &{$t->[0]}(@{$t->[1]}) or print {$run{LOG}} "ERROR: $t->[2]\n"; @@ -179,7 +197,7 @@ my %config_usage = ( vendor => { desc => 'Name of the packages vendor', default => 'Mandriva' }, ); config_usage() if $run{config_usage}; -$run{my_arch} or usage("no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo @{$run{todo}})"); +$run{my_arch} or usage($program_name, \@params, "no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo @{$run{todo}})"); if (!$arch_comp{$real_arch}{$run{my_arch}}) { die "FATAL iurt: could not compile $run{my_arch} binaries on a $real_arch" } @@ -197,7 +215,7 @@ if ($run{distro} ne 'cooker') { $config->{upload} =~ s/cooker/contrib/g; } --d $config->{upload} or usage("$config->{upload} does not exist"); +-d $config->{upload} or usage($program_name, \@params, "$config->{upload} does not exist"); if (!$run{debug} && $run{media} || $run{chroot}) { $run{pidfile} = "$config->{cache_home}/iurt.$run{distro_tag}.$run{my_arch}.pid"; @@ -248,6 +266,7 @@ if ($run{cache}) { $config->{local_upload} ||= $config->{local_home}; my $local_spool = "$config->{local_upload}/iurt/$run{distro_tag}/$run{my_arch}"; if (!-d "$config->{local_upload}/iurt/$run{distro_tag}/") { + -d "$config->{local_upload}/iurt" or mkdir "$config->{local_upload}/iurt"; mkdir "$config->{local_upload}/iurt/$run{distro_tag}"; if (!-d $local_spool) { mkdir $local_spool; @@ -258,6 +277,8 @@ if (!-d "$config->{local_upload}/iurt/$run{distro_tag}/") { dump_rpmmacros("$chroot/home/builder/.rpmmacros") or die "FATAL iurt: could not dump rpm macros"; my $unionfs_dir; if ($run{unionfs}) { + # FIXME need to grep /proc/modules not ot try to load it if already loaded + system("sudo /sbin/modprobe -f unionfs"); $unionfs_dir = "$config->{local_home}/iurt_unionfs$debug_tag"; clean_all_unionfs($unionfs_dir); -d $unionfs_dir or mkdir $unionfs_dir @@ -408,7 +429,11 @@ retry: debug_mail => $run{debug}, log => "$local_spool/log/"); # or next; As this failed quite often, do not stop print {$run{LOG}} "Compiling $srpm\n" if $run{verbose}; - if (!perform_command(qq{TMP=/home/builder/tmp/ sudo chroot $chroot /bin/su builder -c "rpm --rebuild /home/builder/rpm/SRPMS/$srpm"}, + my $command = "rpm --rebuild /home/builder/rpm/SRPMS/$srpm"; + if ($run{stop}) { + $command = "rpm -b$run{stop} /home/builder/rpm/SPECS/*.spec" + } + if (!perform_command(qq{TMP=/home/builder/tmp/ sudo chroot $chroot /bin/su builder -c "$command"}, \%run, $config, mail => $maintainer, error => "[REBUILD] $srpm from $run{distro_tag} does not build correctly on $run{my_arch}", @@ -420,6 +445,9 @@ retry: error_regexp => 'rror.*ailed|Bad exit status|RPM build error', callback => sub { my ($opt, $output) = @_; + if ($run{stop}) { + exec "sudo chroot $chroot /bin/su builder -c bash" + } print {$run{LOG}} "iurt: calling callback for $opt->{hash}\n" if $run{debug}; if ($unionfs_tmp && $output =~ /no space left on device/i) { print {$run{LOG}} "ERROR iurt: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode\n"; @@ -526,7 +554,7 @@ sub clean_all_unionfs { print {$run{LOG}} "Cleaning old unionfs remaining dir in $unionfs_dir\n" if $run{verbose} > 1; opendir my $dir, $unionfs_dir or die "FATAL iurt: could not open $unionfs_dir ($!)"; foreach (readdir $dir) { - /unionfs\.((?:0.)\d+)\.(\d+)$/ or next; + /unionfs\.((?:0\.)?\d+)\.(\d+)$/ or next; clean_unionfs($unionfs_dir, $1, $2); } closedir $dir @@ -725,9 +753,10 @@ sub sendmail { sub check_arch { my ($hdr) = @_; my (@exclusive_arch) = $hdr->queryformat('%{EXCLUSIVEARCH}'); - grep { $_ eq $run{my_arch} || $_ eq '(none)' } @exclusive_arch or return 1; + return if ! grep { $_ eq $run{my_arch} || $_ eq '(none)' } @exclusive_arch; my (@exclude_arch) = $hdr->queryformat('%{EXCLUDEARCH}'); - grep { $_ eq $run{my_arch} } @exclusive_arch and return 1 + return if grep { $_ eq $run{my_arch} } @exclude_arch; + 1 } sub check_version { @@ -964,7 +993,7 @@ sub search_packages { defined $cache->{failure}{$srpm} and next; if (!$cache->{queue}{$srpm} && check_needed($srpm)) { my $hdr = rpm2header("$dir/$srpm"); - check_arch($hdr) and next; + check_arch($hdr) or next; my $changelog = $hdr->queryformat("%{CHANGELOGNAME}"); my ($mail) = $changelog =~ /<(.*@.*)>/; $maint{$srpm} = $mail; |