From b505672f077d7cbac647a4a99e7e5b76e2f3a120 Mon Sep 17 00:00:00 2001 From: Andrey Ponomarenko Date: Fri, 28 Nov 2014 11:04:26 +0400 Subject: [PATCH] URPM-repoclosure 1.8: links to update repositories in the profile are not necessary now --- urpm-repoclosure.pl | 131 ++++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/urpm-repoclosure.pl b/urpm-repoclosure.pl index f027cdf..c70c670 100755 --- a/urpm-repoclosure.pl +++ b/urpm-repoclosure.pl @@ -1,14 +1,14 @@ #!/usr/bin/perl ######################################################## -# URPM Repo Closure Checker 1.7.4 for Linux +# URPM Repo Closure Checker 1.8 for Linux # A tool for checking closure of a set of RPM packages # -# Copyright (C) 2011-2014 ROSA Lab +# Copyright (C) 2011-2014 NTC IT ROSA # Written by Andrey Ponomarenko # # PLATFORMS # ========= -# Linux (ROSA, Mandriva, Mageia) +# Linux (ROSA, OpenMandriva) # # REQUIREMENTS # ============ @@ -38,17 +38,17 @@ use File::Copy qw(copy move); use Data::Dumper; use strict; -my $TOOL_VERSION = "1.7.4"; +my $TOOL_VERSION = "1.8"; my $CmdName = get_filename($0); my ($Help, $ShowVersion, $RPMlist, $RPMdir, $StaticMode, $DynamicMode, $NoClean, $HDlist, $FileDeps, $ReportDir, -$AddRPMs, $RTitle, $DepHDlists, $UpdateHDlists, $Profile, -$Target, $ExtInfo, $UseCache); +$AddRPMs, $RTitle, $DepHDlists, $Profile, $Target, +$ExtInfo, $UseCache); my $ShortUsage = "URPM Repo Closure Checker $TOOL_VERSION A tool for checking closure of a set of RPM packages -Copyright (C) 2014 ROSA Lab +Copyright (C) 2014 NTC IT ROSA License: GNU GPL Usage: $CmdName [options] @@ -74,7 +74,6 @@ GetOptions("h|help!" => \$Help, "report-dir=s" => \$ReportDir, "title=s" => \$RTitle, "dep-hdlists=s" => \$DepHDlists, - "update-hdlists=s" => \$UpdateHDlists, "profile=s" => \$Profile, "cache!" => \$UseCache, "target=s" => \$Target, @@ -96,7 +95,7 @@ USAGE: $CmdName --hdlist=http://mirror.yandex.ru/mandriva/.../synthesis.hdlist.cz $CmdName --dir=rpms/ --static --file-deps=file-deps.txt $CmdName --list=list.txt --dynamic - $CmdName --profile=profile.xml + $CmdName --profile=profile.xml --target=rosa2014.1/i586/main OPTIONS: -h|-help @@ -143,9 +142,6 @@ OPTIONS: The list of HDlists that will be used to resolve dependencies. - -update-hdlists - The list of HDlists from update repositories. - -profile Profile of the test run. @@ -181,18 +177,12 @@ PROFILE FORMAT: http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/contrib/release/media_info/synthesis.hdlist.cz - - http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/contrib/updates/media_info/synthesis.hdlist.cz - - http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/main/release/media_info/synthesis.hdlist.cz - http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/main/updates/media_info/synthesis.hdlist.cz http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/contrib/release/media_info/info.xml.lzma - http://abf.rosalinux.ru/downloads/rosa2012lts/repository/i586/contrib/updates/media_info/info.xml.lzma @@ -336,7 +326,9 @@ sub installPackage($) $Cmd .= " --root=\"$TMP_DIR/root\""; $Cmd .= " --noclean --auto --force"; $Cmd .= " $Package"; + print "Running $Cmd\n"; + my $LogPath = $TMP_DIR."/ilog.txt"; system($Cmd." >$LogPath 2>&1"); my $Log = readFile($LogPath); @@ -562,7 +554,7 @@ sub readRPMlist($$) my ($Path, $Type) = @_; if(not -f $Path) { - print STDERR "ERROR: cannot access \'$Path\'\n"; + print STDERR "ERROR: can't access \'$Path\'\n"; exit(1); } my @RPMs = split(/\s+/, readFile($Path)); @@ -581,7 +573,7 @@ sub readRPMlist($$) } elsif(not -f $P) { - print STDERR "ERROR: cannot access \'$P\'\n"; + print STDERR "ERROR: can't access \'$P\'\n"; exit(1); } } @@ -603,7 +595,7 @@ sub dynamicCheck() { # --dir option if(not -d $RPMdir) { - print STDERR "ERROR: cannot access \'$RPMdir\'\n"; + print STDERR "ERROR: can't access \'$RPMdir\'\n"; exit(1); } @RPMs = searchRPMs($RPMdir); @@ -782,9 +774,9 @@ sub getCachedFile($) return undef; } -sub downloadFile($) +sub downloadFile($$) { - my $Url = $_[0]; + my ($Url, $Kind) = @_; if($UseCache) { @@ -801,8 +793,11 @@ sub downloadFile($) if(not -f $DownloadTo or not -s $DownloadTo) { - print STDERR "ERROR: cannot access \'$Url\'\n"; - exit(1); + if($Kind ne "Update") { + print STDERR "ERROR: can't access \'$Url\'\n"; + } + + return ""; } my %Extract = ( @@ -819,7 +814,7 @@ sub downloadFile($) my @Files = cmd_find($Dir, "f", "", ""); if(not @Files) { - print STDERR "ERROR: cannot extract \'$Url\'\n"; + print STDERR "ERROR: can't extract \'$Url\'\n"; exit(1); } unlink($DownloadTo); @@ -834,20 +829,29 @@ sub downloadFile($) return $DownloadTo; } -sub readInfo($$) +sub readInfo($$$) { - my ($Path, $Info) = @_; + my ($Path, $Info, $Kind) = @_; + + if($Kind eq "Update") { + $Path=~s#/release/#/updates/#g; + } + my $Content = ""; if($Path=~/(http|https|ftp):\/\//) { - print "Downloading Info ...\n"; - $Path = downloadFile($Path); + print "Downloading $Kind Info ...\n"; + $Path = downloadFile($Path, $Kind); + + if(not $Path) { + return; + } } else { if(not -f $Path) { - print STDERR "ERROR: cannot access \'$Path\'\n"; + print STDERR "ERROR: can't access \'$Path\'\n"; exit(1); } } @@ -869,7 +873,7 @@ sub readInfo($$) { if(index($_, "sourcerpm=")!=-1) { - if(/sourcerpm=\'(.+?)\'/) + if(/sourcerpm=[\'\"](.+?)[\'\"]/) { my $SRPM = $1; $SRPM=~s/\.src\.rpm//g; @@ -890,11 +894,26 @@ sub readHDlist($$$$$) { my ($Path, $Dep, $RPMdep, $Registered, $Kind) = @_; + if($Kind eq "Update") { + $Path=~s#/release/#/updates/#g; + } + my $Content = ""; if($Path=~/(http|https|ftp):\/\//) { print "Downloading $Kind HDlist ...\n"; - my $DownloadTo = downloadFile($Path); + my $DownloadTo = downloadFile($Path, $Kind); + + if(not $DownloadTo) + { + if($Kind eq "Update") { + return ""; + } + else { + exit(1); + } + } + if(my $Line = readLineNum($DownloadTo, 1)) { if($Line!~/\A\@\w+\@/) @@ -909,7 +928,7 @@ sub readHDlist($$$$$) { if(not -f $Path) { - print STDERR "ERROR: cannot access \'$Path\'\n"; + print STDERR "ERROR: can't access \'$Path\'\n"; exit(1); } $Content = readFile($Path); @@ -987,7 +1006,11 @@ sub staticCheck() if($ExtInfo) { foreach my $Url (split(/\s+/, readFile($ExtInfo))) { - readInfo($Url, \%AddInfo); + readInfo($Url, \%AddInfo, "Update"); + } + + foreach my $Url (split(/\s+/, readFile($ExtInfo))) { + readInfo($Url, \%AddInfo, "Target"); } } @@ -997,7 +1020,7 @@ sub staticCheck() { if(not -d $AddRPMs) { - print STDERR "ERROR: cannot access \'$AddRPMs\'\n"; + print STDERR "ERROR: can't access \'$AddRPMs\'\n"; exit(1); } if(my @AddedRPMs = searchRPMs($AddRPMs)) @@ -1011,18 +1034,6 @@ sub staticCheck() } } } - if($UpdateHDlists) - { - if(not -f $UpdateHDlists) - { - print STDERR "ERROR: cannot access \'$UpdateHDlists\'\n"; - exit(1); - } - foreach my $Url (split(/\s+/, readFile($UpdateHDlists))) { - readHDlist($Url, \%Dep, \%RPMdep, \%Registered, "Update"); - } - - } if($RPMdir or $RPMlist) { print "Checking RPMs ...\n"; @@ -1031,7 +1042,7 @@ sub staticCheck() { if(not -d $RPMdir) { - print STDERR "ERROR: cannot access \'$RPMdir\'\n"; + print STDERR "ERROR: can't access \'$RPMdir\'\n"; exit(1); } @RPMs = searchRPMs($RPMdir); @@ -1051,7 +1062,9 @@ sub staticCheck() readDeps($Path, \%Dep, \%RPMdep); } } - elsif($HDlist) { + elsif($HDlist) + { + readHDlist($HDlist, \%Dep, \%RPMdep, \%Registered, "Update"); readHDlist($HDlist, \%Dep, \%RPMdep, \%Registered, "Target"); } @@ -1059,9 +1072,14 @@ sub staticCheck() { if(not -f $DepHDlists) { - print STDERR "ERROR: cannot access \'$DepHDlists\'\n"; + print STDERR "ERROR: can't access \'$DepHDlists\'\n"; exit(1); } + + foreach my $Url (split(/\s+/, readFile($DepHDlists))) { + readHDlist($Url, \%Dep_D, \%RPMdep_D, \%Registered, "Update"); + } + foreach my $Url (split(/\s+/, readFile($DepHDlists))) { readHDlist($Url, \%Dep_D, \%RPMdep_D, \%Registered, "Dep"); } @@ -1072,7 +1090,7 @@ sub staticCheck() { if(not -f $FileDeps) { - print STDERR "ERROR: cannot access \'$FileDeps\'\n"; + print STDERR "ERROR: can't access \'$FileDeps\'\n"; exit(1); } %IgnoreDeps = map {$_=>1} split(/\s+/, readFile($FileDeps)); @@ -1538,7 +1556,7 @@ sub checkProfile() while(my $Repos = parseTag(\$Content, "repos")) { my %Info = (); - foreach my $Tag ("distr", "name", "arch", "section", "hdlist", "updates", "deps", "info") { + foreach my $Tag ("distr", "name", "arch", "section", "hdlist", "deps", "info") { $Info{$Tag} = parseTag(\$Repos, $Tag); } @@ -1549,7 +1567,6 @@ sub checkProfile() } writeFile("dep.hdlists", $Info{"deps"}); - writeFile("update.hdlists", $Info{"updates"}); writeFile("info.hdlists", $Info{"info"}); my $Cmd = "perl $0"; @@ -1563,9 +1580,6 @@ sub checkProfile() if($Info{"deps"}) { $Cmd .= " --dep-hdlists=dep.hdlists"; } - if($Info{"updates"}) { - $Cmd .= " --update-hdlists=update.hdlists"; - } if($Info{"info"} and $Info{"arch"} ne "SRPMS") { $Cmd .= " --info=info.hdlists"; } @@ -1587,6 +1601,7 @@ sub checkProfile() } unlink("dep.hdlists"); unlink("update.hdlists"); + unlink("info.hdlists"); my $Content = readFile($Info{"TXT"}); @@ -1722,7 +1737,7 @@ sub scenario() } if($ShowVersion) { - print "URPM Repo Closure Checker $TOOL_VERSION\nCopyright (C) 2014 ROSA Lab\nLicense: GPL \nThis program is free software: you can redistribute it and/or modify it.\n\nWritten by Andrey Ponomarenko.\n"; + print "URPM Repo Closure Checker $TOOL_VERSION\nCopyright (C) 2014 NTC IT ROSA\nLicense: GPL \nThis program is free software: you can redistribute it and/or modify it.\n\nWritten by Andrey Ponomarenko.\n"; exit(0); }