From b020e2b7ec77561e593510e6a834a884e6a8944e Mon Sep 17 00:00:00 2001 From: Jose V Beneyto Date: Thu, 4 Jul 2013 17:39:58 +0200 Subject: [PATCH] Use compression-mode defined in pkgmk.conf --- scripts/pkg-get.pl | 16 ++++++++++++---- scripts/pkg-repgen.pl | 28 ++++++++++++++++++---------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/scripts/pkg-get.pl b/scripts/pkg-get.pl index 3fe51e6..cb5ee10 100755 --- a/scripts/pkg-get.pl +++ b/scripts/pkg-get.pl @@ -35,6 +35,14 @@ GetOptions("do"=>\$download_only, "f"=>\$force, "im"=>\$ignore_md5sum, "margs=s"=>\$unused, "rargs=s"=>\$unused, "r=s"=>\$root); +# use compression-mode defined in pkgmk.conf +our $compress = "gz"; +open CONFIG, "/etc/pkgmk.conf" or die "Could not open /etc/pkgmk.conf"; +while () { + $compress = $1 if m/^PKGMK_COMPRESSION_MODE="(.*)"\n/; +} +close CONFIG; + if ($root) { $LOCKFILE = $root.$LOCKFILE ; $PKGDB = $root.$PKGDB; @@ -156,10 +164,10 @@ sub parsepackage { $name =~ s/\#.*$//; my $version = $p[0]; $version =~ s/^.*\#//; - $version =~ s/-\w*\.pkg\.tar\.gz//; + $version =~ s/-\w*\.pkg\.tar\.[gbx]z*//; my $release = $p[0]; $release =~ s/^.*-//; - $release =~ s/\.pkg\.tar\.gz//; + $release =~ s/\.pkg\.tar\.[gbx]z*//; if (not $_[2]) {$_[2] = $_[1]}; $pkg{'name'} = $name; $pkg{'version'} = $version; @@ -497,7 +505,7 @@ sub getdependencies { # Download given package (if needed), check md5sum sub downloadpkg { my %pkg = @_; - my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.gz"; + my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.$compress"; if (-f $fullpath) { my $md5 = `md5sum $fullpath`; chomp; $md5 =~ s/\s+.*$//; @@ -538,7 +546,7 @@ sub installpkg { if ($force){$aa = $aa."-f "}; if ($root) {$aa = $aa."-r ".$root." "}; if ($pkg{'pre_install'} eq "yes" and ($install_scripts or $pre_install)) {dopre(%pkg)}; - my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.gz"; + my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.$compress"; print "pkg-get: /usr/bin/pkgadd $upgrade$aa$fullpath\n"; system ("/usr/bin/pkgadd $upgrade$aa$fullpath") == 0 or return 0; if ($pkg{'post_install'} eq "yes" and ($install_scripts or $post_install)) {dopost(%pkg)}; diff --git a/scripts/pkg-repgen.pl b/scripts/pkg-repgen.pl index 2743ce4..9e29f15 100755 --- a/scripts/pkg-repgen.pl +++ b/scripts/pkg-repgen.pl @@ -16,6 +16,14 @@ use Getopt::Long; our $title = "CRUX Packages"; our $header; our $footer; GetOptions("title=s"=>\$title, "header=s"=>\$header, "footer=s"=>\$footer); +# Use compression-mode defined in pkgmk-conf +our $compress = "gz"; +open CONFIG, "/etc/pkgmk.conf" or die "Could not open /etc/pkgmk.conf"; +while () { + $compress = $1 if m/^PKGMK_COMPRESSION_MODE="(.*)"\n/; +} +close CONFIG; + if ($#ARGV >= 0) { # single packages pkgrepo_single(); pkgdeps_single(); @@ -35,7 +43,7 @@ sub pkgdeps_single { print "+ Generating dependencies\n"; my $hasnew = 0; foreach my $p (@ARGV) { - my @packages = glob("$p#*.pkg.tar.gz"); + my @packages = glob("$p#*.pkg.tar.$compress"); if ($#packages == 0) { my $found = 0; my $package = $packages[0]; @@ -65,7 +73,7 @@ sub pkgrepo_single { print "+ Generating repository\n"; my $hasnew = 0; foreach my $p (@ARGV) { - my @packages = glob("$p#*.pkg.tar.gz"); + my @packages = glob("$p#*.pkg.tar.$compress"); if ($#packages == 0) { my $found = 0; my $package = $packages[0]; @@ -103,7 +111,7 @@ sub pkgrepo_single { # generate dependencies sub pkgdeps { print "+ Generating dependencies\n"; - my @packages = glob("*#*.pkg.tar.gz"); + my @packages = glob("*#*.pkg.tar.$compress"); open (my $fh, '>PKGDEPS'); foreach my $package (@packages) { $package =~ s/#.*//; @@ -118,7 +126,7 @@ sub pkgdeps { # generate the main repository file and index page sub pkgrepo { print "+ Generating repository\n"; - my @packages = glob("*#*.pkg.tar.gz"); + my @packages = glob("*#*.pkg.tar.$compress"); our $odd = "odd"; my $count = 0; open (my $fh, '>PKGREPO'); @@ -141,8 +149,8 @@ sub pkgrepo { printf $fh "%-s:%-s:%-s:%-s:%-s\n", $package,$du,$md5,$des,$flags; my $version = $package; $version =~ s/^.*\#//; - $version =~ s/\.pkg\.tar\.gz//; - print $ih " "; + $version =~ s/\.pkg\.tar\.[gbx]z*//; + print $ih ""; print $ih "$name"; my $url = $package; $url =~ s/\#/\%23/; @@ -162,10 +170,10 @@ sub pkgrepo { # generate README file sub pkgread { print "+ Generating README\n"; - my @packages = glob("*#*.pkg.tar.gz"); + my @packages = glob("*#*.pkg.tar.$compress"); open (my $fh, '>PKGREAD'); print $fh "# README files for repository. Do NOT remove this line.\n"; - foreach my $package (@packages) { + foreach my $package (@packages) { $package =~ s/#.*//; my $path = `prt-get path $package`; $path =~ s/\n//g; @@ -192,7 +200,7 @@ sub pkginst { # # PKGINST: pre-post install scripts for CRUX packages "; - my @packages = glob("*#*.pkg.tar.gz"); + my @packages = glob("*#*.pkg.tar.$compress"); foreach my $package (@packages) { $package =~ s/#.*//; my $path = `prt-get path $package`; @@ -254,7 +262,7 @@ EOH } table { - border: solid #e5dccf 1px; + border: solid #e5dccf 1px; font-size: 85%; } td