diff options
author | roam <roam@FreeBSD.org> | 2003-01-08 23:40:08 +0800 |
---|---|---|
committer | roam <roam@FreeBSD.org> | 2003-01-08 23:40:08 +0800 |
commit | 62b4e161d3c4a6100cc81e0091e1b8cad39e0ee4 (patch) | |
tree | 86f8bc874ed979b1f3ab93228c4a0d3402f5ed4b /Tools/scripts | |
parent | 5d757ee8536631ead945213312df6a95ba851ef5 (diff) | |
download | freebsd-ports-gnome-62b4e161d3c4a6100cc81e0091e1b8cad39e0ee4.tar.gz freebsd-ports-gnome-62b4e161d3c4a6100cc81e0091e1b8cad39e0ee4.tar.zst freebsd-ports-gnome-62b4e161d3c4a6100cc81e0091e1b8cad39e0ee4.zip |
Add two utilties for listing and stashing away package files obtained
from recursive dependency builds a la:
make DEPENDS_TARGET='install package clean' all install package clean
The pkg-list script obtains a list of the packages in the dependency
directories; the pkg-stash script moves them away to a predefined
directory, adding a timestamp to the package file name. This is
convenient for keeping ready-built packages for system rescue
activities.
Diffstat (limited to 'Tools/scripts')
-rw-r--r-- | Tools/scripts/pkg-stash/pkg-list.sh | 6 | ||||
-rwxr-xr-x | Tools/scripts/pkg-stash/pkg-stash.pl | 104 |
2 files changed, 110 insertions, 0 deletions
diff --git a/Tools/scripts/pkg-stash/pkg-list.sh b/Tools/scripts/pkg-stash/pkg-list.sh new file mode 100644 index 000000000000..88cdc2a16970 --- /dev/null +++ b/Tools/scripts/pkg-stash/pkg-list.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# $FreeBSD$ + +for i in . `make all-depends-list`; do + cd $i && [ -f "`make -V PKGFILE`" ] && make -V PKGFILE +done diff --git a/Tools/scripts/pkg-stash/pkg-stash.pl b/Tools/scripts/pkg-stash/pkg-stash.pl new file mode 100755 index 000000000000..5e9822767050 --- /dev/null +++ b/Tools/scripts/pkg-stash/pkg-stash.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl -wT +# $FreeBSD$ + +use strict; + +use Sys::Hostname; +use File::Basename; +use Getopt::Std; +use POSIX qw(strftime); + +sub usage() { + + die("Usage:\n" + ."\tpkg-stash [-D base] [-d dir] [-g group] [-o owner] [-cfNn] filename..\n" + ."\tpkg-stash [-D base] [-d dir] [-g group] [-o owner] -p\n"); +} + +sub stashfile($ %) { + my ($path, %args) = @_; + my ($dir, $base, $ext); + my ($ts, $fname); + my (@opts, @cmd); + + ($base, $dir, $ext) = fileparse($path, '\.tgz', '\.tar\.gz', '\.tbz', '\.tbz2'); + if ($args{'nostamp'}) { + $ts = ""; + } else { + $ts = "-ts".strftime("%Y%m%d%H%M", localtime()); + } + $fname = "$base$ts$ext"; + + @cmd = ("install"); + push(@cmd, '-v') if ($args{'verbose'}); + push(@cmd, $args{'copy'}) if ($args{'copy'} ne ""); + push(@cmd, $args{'owner'}) if ($args{'owner'} ne ""); + push(@cmd, $args{'group'}) if ($args{'group'} ne ""); + push(@cmd, $path, "$args{dir}/$fname"); + + if ($args{'noact'}) { + print join(' ', @cmd)."\n"; + return 1; + } + if (system(@cmd) != 0) { + warn "Installing $path to $args{dir}/$fname failed: $?\n"; + } + if (system('rm', $path) != 0) { + warn "Removing %path failed: $?\n"; + } +} + +MAIN:{ + my %stashargs = ( + "base" => "/var/backups/packages/", + "copy" => "", + "dir" => "", + "group" => "", + "noact" => 0, + "nostamp" => 0, + "owner" => "", + "verbose" => 0, + ); + my $printonly = 0; + my %opts; + my $path; + + getopts("CcD:d:fg:Nno:pv", \%opts) or + usage(); + $stashargs{'base'} = $opts{'D'} if (defined($opts{'D'})); + $stashargs{'copy'} = 'c' if (defined($opts{'c'})); + $stashargs{'copy'} = 'C' if (defined($opts{'C'})); + $stashargs{'dir'} = $opts{'d'} if (defined($opts{'d'})); + $stashargs{'force'} = 1 if (defined($opts{'f'})); + $stashargs{'group'} = "-g $opts{g}" if (defined($opts{'g'})); + $stashargs{'nostamp'} = 1 if (defined($opts{'N'})); + $stashargs{'noact'} = 1 if (defined($opts{'n'})); + $stashargs{'owner'} = "-o $opts{o}" if (defined($opts{'o'})); + $stashargs{'verbose'} = 1 if (defined($opts{'v'})); + $printonly = 1 if (defined($opts{'p'})); + + if ($stashargs{'dir'} eq "") { + my $hostname = hostname(); + + $hostname =~ s/\..*//; + $stashargs{'dir'} = $stashargs{'base'}.$hostname; + } + + # Do nada? + if ($printonly) { + print $stashargs{'dir'}."\n"; + exit(0); + } + + # Force taint mode into submission + delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; + $ENV{'PATH'} = '/bin:/usr/bin'; + + # Okay, process the arguments.. + if ($#ARGV == -1) { + usage(); + } + foreach $path (@ARGV) { + stashfile($path, %stashargs); + } +} |