summaryrefslogtreecommitdiff
path: root/pkgtools/pkgconflict/files/pkgdbextract
blob: fcd81f88df85c687a1a25957cea8ab3fa6e145e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/csh -f
# $NetBSD: pkgdbextract,v 1.1 2001/04/03 18:03:04 wennmach Exp $
#
# pkgdbextract: tool to extract packages databases from binary packages
#               into a destination directory, suitable for use with pkgconflict
#
# Author: Lex Wennmacher <wennmach@netbsd.org>
#

# Usage pkgdbextract BASEDIR package1.tgz [ package2.tgz ... ]

set nargs=$#argv
if ($nargs < 2) then
    echo pkgdbextract: usage: pkgdbextract BASEDIR package1.tgz [ package2.tgz ... ]
    exit -1
endif

set BASEDIR=$1

if (! -d $BASEDIR) mkdir -p $BASEDIR
if (! -d $BASEDIR) then
    echo could not create $BASEDIR
    exit -1
endif

# Loop over all packages (args 2 - )
foreach pkg (`echo $argv[2-]`)
    if (-e $pkg) then
        set pkgbinname=$pkg:t
        set pkgname=$pkgbinname:r
        set DESTDIR=$BASEDIR/$pkgname
        mkdir -p $DESTDIR
        tar --fast-read -xzf $pkg +CONTENTS -C $DESTDIR
    else
# It is not an error if a package can not be read
        echo "pkgdbextract: warning: $pkg not readable"
    endif
end

exit 0