my $depends = 0; #depends subcommand to put reverse dependency
my $reverse_off = 0; #disable reverse dependency
my $reverse_on = 1; #enable reverse dependency
-
GetOptions (
"repository=s" => \@repos,
"arch=s" => \$arch,
}
-mkdir_p($order_dir);
+mkdir_p("$order_dir");
mkdir_p($success_logs_path);
mkdir_p($fail_logs_path);
mkdir_p($cache_path);
if ($includeall == 0 || $spec_commit ne "") {
my (undef, $tmp_file) = tempfile(OPEN => 0);
my $__commit = $spec_commit eq "" ? $commit : $spec_commit;
- if (my_system("cd $base; git show $__commit:$l_packaging_dir >$tmp_file 2>/dev/null") == 0) {
+ if (my_system("cd '$base'; git show $__commit:'$l_packaging_dir' >'$tmp_file' 2>/dev/null") == 0) {
open my $file, '<', $tmp_file or die $!;
# the content like:
# tree $__commit:$packaging_dir
} else { #packaging_dir is a symbol link
my (undef, $tmp_symlink_file) = tempfile(OPEN => 0);
# git show the real packaging dir
- if (my_system("cd $base; git show $__commit:$first_line >$tmp_symlink_file 2>/dev/null") == 0) {
+ if (my_system("cd '$base'; git show $__commit:'$first_line' >'$tmp_symlink_file' 2>/dev/null") == 0) {
open my $symlink_file, '<', $tmp_symlink_file or die $!;
my $specs;
while (<$symlink_file>) {
push @args, "gbs";
push @args, "--debug" if ($debug);
push @args, "export";
- push @args, "$base";
- push @args, "-o $out_dir";
+ push @args, "'$base'";
+ push @args, "-o '$out_dir'";
push @args, "--outdir-directly";
push @args, "--spec $spec";
if ($includeall == 1) {
}
my $src_rpm = "$srpm_repo_path/$cache_key.src.rpm";
- if (-f $src_rpm) {
+ if (-f "$src_rpm") {
# Remove old source rpm packages to build again, or depanneur
# will skip packages with src.rpm exists
- my_system("rm -f $src_rpm");
+ my_system("rm -f '$src_rpm'");
}
- open(my $rev1, "+>", $cache_fname) ||
+ open(my $rev1, "+>", "$cache_fname") ||
die "write reversion cache($cache_fname) failed: $!";
print $rev1 $cache_val . "\n";
close($rev1);
my ($base, $commit_id) = @_;
# pipe to read
- open(my $git, '-|', "git --git-dir $base/.git rev-parse $commit_id") ||
+ open(my $git, '-|', "git --git-dir '$base'/.git rev-parse $commit_id") ||
die "query git commit reversion($commit_id) failed: $!";
my $rev = readline($git);
close($git);
# \Q and \E to keep the raw string not be escaped
$spec =~ s!\Q$base/\E!!;
$without_base = $spec;
- if (my_system("cd $base; git show $spec_commit:$without_base >$tmp_spec 2>/dev/null") != 0) {
+ if (my_system("cd '$base'; git show $spec_commit:$without_base >'$tmp_spec' 2>/dev/null") != 0) {
warning("failed to checkout spec file from commit: $spec_commit:$without_base");
return;
}
my $exported_key = basename($source_cache{"$base:$current_rev"});
# if one package have multiple spec files
# No need to export, just copy one
- my_system("cp -r $pkg_path/$exported_key $pkg_path/$cache_key");
- my_system("cp -f $pkg_path/cache/$exported_key $pkg_path/cache/$cache_key");
+ my_system("cp -r '$pkg_path'/'$exported_key' '$pkg_path'/'$cache_key'");
+ my_system("cp -f '$pkg_path'/cache/'$exported_key' '$pkg_path'/cache/'$cache_key'");
} else {
# if it's failed to write cache
my %packs_arch;
my %packs_done;
- open(my $fh, '<', $rpmdeps) || die("$rpmdeps: $!\n");
+ open(my $fh, '<', "$rpmdeps") || die("$rpmdeps: $!\n");
# WARNING: the following code assumes that the 'I' tag comes last
# .repo.cache like:
# F:acl.i586-1373460453/1373460459/0: http://.../packages/i586/acl-2.2.49-2.1.i586.rpm
my $extra_opts = "--changelog-limit=0 -q";
if ($skip_srcrpm == 0){
- my_system("touch $srpm_repo_path");
+ my_system("touch '$srpm_repo_path'");
}
- my_system("touch $rpm_repo_path");
+ my_system("touch '$rpm_repo_path'");
# if local repo has been created, run createrepo with --update
$extra_opts = $extra_opts . " --update " if ( -e "$localrepo/$dist/$arch/repodata" );
$extra_opts = $extra_opts . " --groupfile=$groupfile " if ( -e "$groupfile");
- my_system ("createrepo $extra_opts $localrepo/$dist/$arch > /dev/null 2>&1 ") == 0 or die "createrepo failed: $?\n";
+ my_system ("createrepo $extra_opts '$localrepo/$dist/$arch' > /dev/null 2>&1 ") == 0 or die "createrepo failed: $?\n";
}
#---------------------------------------------------------------------
sub worker_thread {
my ($name, $thread, $index) = @_;
-
+ debug("call build process:");
my $status;
eval {
# call build process
#---------------------------------------------------------------------
sub safe_umount {
my ($device) = @_;
- return if (my_system("sudo /bin/umount -l $device") == 0);
+ return if (my_system("sudo /bin/umount -l '$device'") == 0);
warning("!!!! umount device $device failed. It may cause files lost in ".
"some cases. Please stop the process which is using this device and ".
"press any key to umount again !!!!");
<>;
- if (my_system("sudo /bin/umount -l -f $device") != 0) {
+ if (my_system("sudo /bin/umount -l -f '$device'") != 0) {
warning("!!!! IMPORTANT: umount failed again, please backup your ".
"source code and try to umount manually !!!!");
}
my $na = "$name$arch";
if (exists $ref_hash->{$na}) {
foreach (@{$ref_hash->{$na}}) {
- my_system("rm -rf $_");
+ my_system("rm -rf '$_'");
}
}
$ref_hash->{$na} = [$pkg];
} else {
warning("depanneur only support linux platform");
}
- my $target_arch=`$build_dir/queryconfig target --dist $dist --configdir $dist_configs --archpath $arch`;
+ my $target_arch=`$build_dir/queryconfig target --dist '$dist' --configdir '$dist_configs' --archpath '$arch'`;
chomp $target_arch;
if ($target_arch eq "") {
push @args, "--target $arch";
push @args, "--no-init" if ($noinit == 1);
push @args, "--keep-packs" if ($keep_packs == 1);
push @args, "--use-higher-deps" if ($use_higher_deps == 1);
- push @args, "--cachedir $cache_dir";
- push @args, "--dist $dist_configs/$dist.conf";
- push @args, "--arch $archpath";
- push @args, "$srpm_filename";
+ push @args, "--cachedir '$cache_dir'";
+ push @args, "--dist '$dist_configs'/$dist.conf";
+ push @args, "--arch '$archpath'";
+ push @args, "'$srpm_filename'";
push @args, "--ccache" if ($ccache);
- push @args, "--icecream $icecream" if ($icecream);
+ push @args, "--icecream '$icecream'" if ($icecream);
push @args, "--baselibs" if ($create_baselibs);
if (! $extra_packs eq "") {
my $packs = join(' ', split(',', $extra_packs));
info("*** [$index/$count] building $name-$version-$release $arch $dist (worker: $thread) ***");
if ( -d "$rpm_repo_path" ) {
- push @args, "--repository $rpm_repo_path";
+ push @args, "--repository '$rpm_repo_path'";
}
foreach my $r (@package_repos) {
push @args, "--repository $r";
}
push @args, "--debug" if ($disable_debuginfo != 1);
- push @args, "--root $scratch";
- if ($noinit == 1 && -e "$scratch/not-ready") {
+ push @args, "--root '$scratch'";
+ if ($noinit == 1 && -e "'$scratch'/not-ready") {
error("build root is not ready , --noinit is not allowed");
}
- push @args, "--clean" if (-e "$scratch/not-ready");
+ push @args, "--clean" if (-e "'$scratch'/not-ready");
push @args, $redirect;
for my $define (@defines) {
push @args, "--define '$define'";
push @args, "--define '%reconfigure echo'";
push @args, "--define '%autogen echo'";
}
- push @args, "--root $scratch";
+ push @args, "--root '$scratch'";
push @args, "--no-topdir-cleanup";
push @args, "--no-init";
@args = grep { $_ ne "--clean"} @args;
my $project_base_path = $to_build{$name}->{project_base_path};
if (! -e "$builddir") {
- my_system("sudo /bin/mkdir -p $builddir");
+ my_system("sudo /bin/mkdir -p '$builddir'");
}
- my $mount = "sudo /bin/mount -o bind $project_base_path $builddir";
+ my $mount = "sudo /bin/mount -o bind '$project_base_path' '$builddir'";
my_system($mount);
my $tmp_dir = abs_path(tempdir(CLEANUP=>1));
- my_system("tar -zcf $source_tar $tmp_dir") if ($source_tar ne "");
+ my_system("tar -zcf '$source_tar' '$tmp_dir'") if ("$source_tar" ne "");
}
if ($not_ex) {
if ( -d "$builddir") {
- my_system("rm -rf $builddir");
+ my_system("rm -rf '$builddir'");
}
my $otherdir = "$scratch/home/abuild/rpmbuild/OTHER/";
if ( ! -d "$otherdir") {
- my_system("sudo /bin/mkdir -p $otherdir");
+ my_system("sudo /bin/mkdir -p '$otherdir'");
}
my $project_base_path = $to_build{$name}->{project_base_path};
- my_system("sudo /bin/mkdir -p $builddir");
- my $mount = "sudo /bin/mount -o bind $project_base_path $builddir";
+ my_system("sudo /bin/mkdir -p '$builddir'");
+ my $mount = "sudo /bin/mount -o bind '$project_base_path' '$builddir'";
my_system($mount);
my $packaing_files = dirname($to_build{$name}->{filename});
my_system("cp -a $packaing_files/* $project_base_path/");
}
$cmd = join(" ", @args);
- debug($cmd);
+ #debug($cmd);
my $ret = my_system ($cmd);
if ($incremental == 1) {
#FIXME: more safe way needed to remove this fake source tar
- my_system("rm -f $source_tar") if ($source_tar ne "");
+ my_system("rm -f '$source_tar'") if ($source_tar ne "");
safe_umount($builddir) if ($incremental == 1);
}
if ($not_ex) {
- my_system("rm -f $source_tar") if ($source_tar ne "");
+ my_system("rm -f '$source_tar'") if ($source_tar ne "");
safe_umount($builddir)
}
# Save build config to build root for --noinit use
- my_system("sudo /bin/cp $dist_configs/$dist.conf $scratch/$dist.conf") if ($noinit == 0);
+ my_system("sudo /bin/cp '$dist_configs/$dist.conf' '$scratch'/$dist.conf") if ($noinit == 0);
if ($ret == 0) {
# Set the real path of RPMS and SRPMS
$rpmdirpath = "/.build.packages/RPMS";
$srcrpmdirpath = "/.build.packages/SRPMS";
} else {
- $rpmdirpath = `sudo chroot $scratch su -c "rpm --eval %{_rpmdir} 2>/dev/null" - abuild`;
- $srcrpmdirpath = `sudo chroot $scratch su -c "rpm --eval %{_srcrpmdir} 2>/dev/null" - abuild`;
+ $rpmdirpath = `sudo chroot '$scratch' su -c "rpm --eval %{_rpmdir} 2>/dev/null" - abuild`;
+ $srcrpmdirpath = `sudo chroot '$scratch' su -c "rpm --eval %{_srcrpmdir} 2>/dev/null" - abuild`;
}
chomp($rpmdirpath);
chomp($srcrpmdirpath);
mkdir_p "$success_logs_path/$name-$version-$release";
if (-e "$logpath") {
- my_system ("sudo /bin/mv $logpath $success_logs_path/$name-$version-$release/log.txt");
+ my_system ("sudo /bin/mv '$logpath' '$success_logs_path'/$name-$version-$release/log.txt");
if ($vmtype eq "kvm") {
my $dir_logpath = dirname($logpath);
- my_system ("/bin/rm -rf $dir_logpath");
+ my_system ("/bin/rm -rf '$dir_logpath'");
}
$succeeded{"$name"} = "$success_logs_path/$name-$version-$release/log.txt";
}
{
# Update global local repo, so lock it
lock($DETACHING);
- if (my @srpms = bsd_glob "$scratch/$srcrpmdirpath/*.rpm") {
+# if (my @srpms = bsd_glob "$scratch/$srcrpmdirpath/*.rpm") {
+ if (my @srpms = (`find "$scratch/$srcrpmdirpath" -type f -name "*.rpm" 2>/dev/null`)) {
#remove old srpms in local repo
#copy the new ones to local repo
update_repo_with_rpms(\%srpmpaths, @srpms);
if ($skip_srcrpm == 0){
foreach (@srpms) {
- my_system ("sudo ln $_ $srpm_repo_path");
+ $_ =~ s/\n//;
+ my_system ("sudo ln '$_' '$srpm_repo_path'");
}
}
} elsif ($skip_srcrpm == 1){
- my_system("/bin/rm -rf $srpm_repo_path/*.rpm");
+ my_system("/bin/rm -rf '$srpm_repo_path'/*.rpm");
}
- if (my @rpms = bsd_glob "$scratch/$rpmdirpath/*/*.rpm") {
+# if (my @rpms = bsd_glob "$scratch/$rpmdirpath/*/*.rpm") {
+ if (my @rpms = (`find "$scratch/$rpmdirpath" -type f -name "*.rpm" 2>/dev/null`)) {
+ #remove old rpms in local repo
#remove old rpms in local repo
#copy the new ones to local repo
update_repo_with_rpms (\%rpmpaths, @rpms);
foreach (@rpms) {
- my_system ("sudo ln $_ $rpm_repo_path");
+ $_ =~ s/\n//;
+ my_system ("sudo ln '$_' '$rpm_repo_path'");
}
}
- my_system("$build_dir/createdirdeps $rpm_repo_path > $order_dir/.repo.cache.local ");
- my_system("echo D: >> $order_dir/.repo.cache.local");
- my_system("cat $order_dir/.repo.cache.local $order_dir/.repo.cache.remote >$order_dir/.repo.cache");
+ my_system("'$build_dir'/createdirdeps '$rpm_repo_path' > '$order_dir'/.repo.cache.local ");
+ my_system("echo D: >> '$order_dir'/.repo.cache.local");
+ my_system("cat '$order_dir'/.repo.cache.local '$order_dir'/.repo.cache.remote >'$order_dir'/.repo.cache");
}
info("finished building $name");
$packages_built = 1;
mkdir_p "$fail_logs_path/$name-$version-$release";
if ( -f "$logpath" ) {
# move failed log from build root
- my_system ("sudo /bin/mv $logpath $fail_logs_path/$name-$version-$release/log.txt");
+ my_system ("sudo /bin/mv '$logpath' '$fail_logs_path'/$name-$version-$release/log.txt");
if ($vmtype eq "kvm") {
my $dir_logpath = dirname($logpath);
- my_system ("/bin/rm -rf $dir_logpath");
+ my_system ("/bin/rm -rf '$dir_logpath'");
}
$errors{"$name"} = "$fail_logs_path/$name-$version-$release/log.txt";
warning("build failed, Leaving the logs in $fail_logs_path/$name-$version-$release/log.txt");
my $tmp_dir = abs_path(tempdir(CLEANUP=>1));
if ( @package_group_rpm != 0 and -e $package_group_rpm[0] ) {
#unzip package-group binary and find the patterns.xml
- my_system("cd $tmp_dir; rpm2cpio $package_group_rpm[0] | cpio -di ");
+ my_system("cd '$tmp_dir'; rpm2cpio $package_group_rpm[0] | cpio -di ");
( $patternfile ) = glob("$tmp_dir/*/*/*/patterns.xml");
}
if ( -e $patternfile ) {
sub build_json_report
{
open(my $report_json, '>', "$localrepo/$dist/$arch/report.json");
- print $report_json to_json(\%build_status_json);
+ print $report_json to_json(\%build_status_json,{allow_nonref => 1});
close($report_json);
}
info("retrieving repo metadata...");
my $repos_setup = 1;
- my_system("> $order_dir/.repo.cache.local");
+ my_system("> '$order_dir'/.repo.cache.local");
if (-d "$rpm_repo_path") {
- my_system("$build_dir/createdirdeps $rpm_repo_path >> $order_dir/.repo.cache.local");
- my_system("echo D: >> $order_dir/.repo.cache.local");
+ my_system("$build_dir/createdirdeps '$rpm_repo_path' >> '$order_dir'/.repo.cache.local");
+ my_system("echo D: >> '$order_dir'/.repo.cache.local");
}
- my_system("> $order_dir/.repo.cache.remote");
+ my_system("> '$order_dir'/.repo.cache.remote");
foreach my $repo (@package_repos) {
my $cmd = "";
if ($repo =~ /^\// && ! -e "$repo/repodata/repomd.xml") {
- $cmd = "$build_dir/createdirdeps $repo >> $order_dir/.repo.cache.remote ";
+ $cmd = "$build_dir/createdirdeps '$repo' >> '$order_dir'/.repo.cache.remote ";
} else {
- $cmd = "$build_dir/createrepomddeps --cachedir=$cache_dir $repo >> $order_dir/.repo.cache.remote ";
+ $cmd = "$build_dir/createrepomddeps --cachedir='$cache_dir' '$repo' >> '$order_dir'/.repo.cache.remote ";
}
debug($cmd);
if ( my_system($cmd) == 0 ) {
- my_system("echo D: >> $order_dir/.repo.cache.remote");
+ my_system("echo D: >> '$order_dir'/.repo.cache.remote");
} else {
$repos_setup = 0;
}
}
# Merge local repo cache and remote repo cache
- my_system("cat $order_dir/.repo.cache.local $order_dir/.repo.cache.remote >$order_dir/.repo.cache");
+ my_system("cat '$order_dir'/.repo.cache.local '$order_dir'/.repo.cache.remote >'$order_dir'/.repo.cache");
if ($repos_setup == 0 ) {
error("repo cache creation failed...");
info("retrieving repo metadata...");
my $repos_setup = 1;
-my_system("> $order_dir/.repo.cache.local");
+my_system("> '$order_dir'/.repo.cache.local");
if (-d "$rpm_repo_path") {
- my_system("$build_dir/createdirdeps $rpm_repo_path >> $order_dir/.repo.cache.local");
- my_system("echo D: >> $order_dir/.repo.cache.local");
+ my_system("$build_dir/createdirdeps '$rpm_repo_path' >> '$order_dir'/.repo.cache.local");
+ my_system("echo D: >> '$order_dir'/.repo.cache.local");
}
-my_system("> $order_dir/.repo.cache.remote");
+my_system("> '$order_dir'/.repo.cache.remote");
foreach my $repo (@package_repos) {
my $cmd = "";
if ($repo =~ /^\// && ! -e "$repo/repodata/repomd.xml") {
- $cmd = "$build_dir/createdirdeps $repo >> $order_dir/.repo.cache.remote ";
+ $cmd = "$build_dir/createdirdeps '$repo' >> '$order_dir'/.repo.cache.remote ";
} else {
- $cmd = "$build_dir/createrepomddeps --cachedir=$cache_dir $repo >> $order_dir/.repo.cache.remote ";
+ $cmd = "$build_dir/createrepomddeps --cachedir='$cache_dir' '$repo' >> '$order_dir'/.repo.cache.remote ";
}
debug($cmd);
if ( my_system($cmd) == 0 ) {
- my_system("echo D: >> $order_dir/.repo.cache.remote");
+ my_system("echo D: >> '$order_dir'/.repo.cache.remote");
} else {
$repos_setup = 0;
}
}
# Merge local repo cache and remote repo cache
-my_system("cat $order_dir/.repo.cache.local $order_dir/.repo.cache.remote >$order_dir/.repo.cache");
+my_system("cat '$order_dir'/.repo.cache.local '$order_dir'/.repo.cache.remote >'$order_dir'/.repo.cache");
if ($repos_setup == 0 ) {
error("repo cache creation failed...");
}
# scan local repo
-for my $pkg (bsd_glob "$rpm_repo_path/*.rpm") {
+#for my $pkg (bsd_glob "$rpm_repo_path/*.rpm") {
+for my $pkg (`find "$rpm_repo_path" -type f -name "*.rpm" 2>/dev/null`) {
+ $pkg =~ s/\n//;
my ($name, $version, $release, $arch) = get_pkg_info $pkg;
next if $name eq '';
my $na = "$name$arch";
$rpmpaths{$na} = [$pkg];
}
}
-for my $pkg (bsd_glob "$srpm_repo_path/*.rpm") {
+#for my $pkg (bsd_glob "$srpm_repo_path/*.rpm") {
+for my $pkg (`find "$srpm_repo_path" -type f -name "*.rpm" 2>/dev/null`) {
+ $pkg =~ s/\n//;
my ($name, $version, $release, $arch) = get_pkg_info $pkg;
next if $name eq '';
my $na = "$name$arch";
print "\n";
}
}
-
# Main process loop
# Every loop, first update package information
# include dependencies if there is new package
if ($dirty) {
# there is any package has been built
refresh_repo();
- update_expansion_errors();
+ update_expansion_errors();
#update_pkgdeps();
#update_pkgddeps();
#if (check_circle() == 1) {
$dirty = 0;
}
-
foreach my $name (@build_order) {
# skip the followint packages:
# - packages already done (in @done list)
push(@order_clean, $name);
}
}
-
#remove unuseful package name from build_order
foreach my $u_name (@order_clean) {
@build_order = grep { $_ ne $u_name} @build_order;
while ((threads->list() > 0)) {
sleep(1);
}
-
update_repo();
build_report();