From: y0169.zhang Date: Wed, 26 Jul 2017 11:40:01 +0000 (+0800) Subject: Remove process lock, add temporary file to fix issue: X-Git-Tag: submit/devel/20190730.074441~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F140830%2F2;p=tools%2Fbuild.git Remove process lock, add temporary file to fix issue: https://bugs.tizen.org/browse/DEVT-310 Change-Id: I2ef65f1d2051a6a6a8d2bdbaa57a12862e1b56c5 Signed-off-by: y0169.zhang --- diff --git a/README b/README index 33c7998..ac21af8 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -This is a tool to build binary packages in a safe and reproducible +This is a tool to build binary packages in a safe and reproducible way. The default is to build in a chroot sandbox, but it also supports building in a virtual machine for better security. diff --git a/createrepomddeps b/createrepomddeps index fdb5346..8ef9ddf 100755 --- a/createrepomddeps +++ b/createrepomddeps @@ -33,6 +33,7 @@ use Build::Rpmmd; use Digest::MD5 (); use File::Path qw(mkpath rmtree); use File::Basename; +use File::Copy qw(move); use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT IPC_EXCL SEM_UNDO); use IPC::Semaphore; @@ -89,20 +90,20 @@ for my $url (@ARGV) { $dir = "$cachedir/$repoid/"; $baseurl .= '/' unless $baseurl =~ /\/$/; mkpath("${dir}repodata"); - my $sem; - my $key = IPC::SysV::ftok($dir, '1'); - if ($sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT | IPC_EXCL)) { - $sem->setval(0, 1); - } else { - $sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT); - } - - $sem->op(0, -1, SEM_UNDO); - if (!-f "${dir}repodata/repomd.xml") { + #my $sem; + #my $key = IPC::SysV::ftok($dir, '1'); + #if ($sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT | IPC_EXCL)) { + # $sem->setval(0, 1); + #} else { + # $sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT); + #} + # + #$sem->op(0, -1, SEM_UNDO); + #if (!-f "${dir}repodata/repomd.xml") { system($INC[0].'/download', "${dir}repodata", "${baseurl}repodata/repomd.xml"); - } - $sem->op(0, 1, SEM_UNDO); - $sem->remove(); + #} + #$sem->op(0, 1, SEM_UNDO); + #$sem->remove(); } else { $dir = $url; } @@ -126,14 +127,14 @@ for my $url (@ARGV) { utf8::downgrade($u); } my $cached; - my $sem; - my $key = IPC::SysV::ftok("${dir}repodata/", '1'); - if ($sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT | IPC_EXCL)) { - $sem->setval(0, 1); - } else { - $sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT); - } - $sem->op(0, -1, SEM_UNDO); + #my $sem; + #my $key = IPC::SysV::ftok("${dir}repodata/", '1'); + #if ($sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT | IPC_EXCL)) { + # $sem->setval(0, 1); + #} else { + # $sem = IPC::Semaphore->new($key, 1, S_IRUSR | S_IWUSR | IPC_CREAT); + #} + #$sem->op(0, -1, SEM_UNDO); if (-e $u) { $cached = 1; $cached = 0 if exists($f->{'size'}) && $f->{'size'} != (-s _); @@ -149,8 +150,8 @@ for my $url (@ARGV) { die("inconsistent repodata in $url\n"); } } - $sem->op(0, 1, SEM_UNDO); - $sem->remove(); + #$sem->op(0, 1, SEM_UNDO); + #$sem->remove(); my $fh; open($fh, '<', $u) or die "Error opening $u: $!\n"; diff --git a/download b/download index 40b3295..a597e62 100755 --- a/download +++ b/download @@ -88,7 +88,7 @@ for my $url (@ARGV) { } } $ua->env_proxy if $url->scheme ne 'https'; - my $dest = "$dir/".basename($url->path); + my $dest = "$dir/".basename($url->path).".tmp"; unlink($dest); # just in case my $retry = 3; while ($retry--) { @@ -98,6 +98,7 @@ for my $url (@ARGV) { die "reqesting " . hide_passwd($original) . " failed: ".$res->status_line."\n" unless $retry && $res->previous; warn "retrying " . hide_passwd($original) . "\n"; } + rename($dest, "$dir/".basename($url->path)); } # vim:sw=2