From c68062b624c2e52de24e10f2058681c0222ed983 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Wed, 23 Jan 2019 23:50:36 +0100 Subject: [PATCH] make_disc_trees: don't use system() for trivial things Fair warning: completely untested and I don't know perl. --- tools/make_disc_trees.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/make_disc_trees.pl b/tools/make_disc_trees.pl index 0d266ef5..c7648ac5 100755 --- a/tools/make_disc_trees.pl +++ b/tools/make_disc_trees.pl @@ -9,6 +9,7 @@ use Digest::MD5; use Digest::SHA; use File::stat; use File::Find; +use File::Path qw(make_path remove_tree); use File::Basename; use Compress::Zlib; @@ -585,7 +586,7 @@ sub check_base_installable { print LOG "Debootstrap reported error: $error_string\n"; die "Debootstrap reported error: $error_string\n"; } - system("rm -rf $tdir/debootstrap_tmp"); + remove_tree("$tdir/debootstrap_tmp"); return $ok; } @@ -865,7 +866,8 @@ sub finish_disc { $ok += $archok; } if ($ok == 0) { - system("touch $cddir/.disk/base_installable"); + open(my $fh, ">>", "$cddir/.disk/base_installable"); + close($fh); print " Found all files needed for debootstrap for all binary arches\n"; } else { print " $ok files missing for debootstrap, not creating base_installable\n"; @@ -910,7 +912,7 @@ sub finish_disc { # And sort; it should make things faster for people checking # the md5sums, as ISO9660 dirs are sorted alphabetically system("LANG=C sort -uk2 md5sum.txt | grep -v \./md5sum.txt > md5sum.txt.tmp"); - system("mv -f md5sum.txt.tmp md5sum.txt"); + rename("md5sum.txt.tmp", "md5sum.txt"); chdir $bdir; if (defined($ENV{'DISC_END_HOOK'})) { @@ -1010,7 +1012,7 @@ sub add_Packages_entry { msg_ap(0, " Adding $p to $pkgfile(.gz)\n"); if (! -d $pdir) { - system("mkdir -p $pdir"); + make_path($pdir); $blocks_added++; } @@ -1062,7 +1064,7 @@ sub add_trans_desc_entry { $idir = Packages_dir($dir, $file, $section, $in_backports) . "/i18n"; if (! -d $idir) { - system("mkdir -p $idir"); + make_path($idir); $blocks_added++; }