blob: 3d0c7553cb6ab810b561df3f7414299137ad84de (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/sh
# wrapper to download a binary package from a full APT repository
# (hopefully checking the archive signatures while at it)
#
# Copyright 2016 Niko Tyni <ntyni@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# TODO: apt-key handling?
#
set -e
while getopts s:p:d:v: f
do
case $f in
p) package="$OPTARG";;
s) sources="$OPTARG";;
d) debdir="$OPTARG";;
v) version="$OPTARG";;
esac
done
shift `expr $OPTIND - 1`
if [ ! -n "$package" ] && [ -r debian/control ]; then
package=$(sed -n 's/^Package: *\(libperl5\..*\)/\1/ p' debian/control)
fi
if [ ! -n "$package" ]; then
echo "cannot guess name of package to download, aborting" 1>&2
exit 1
fi
if [ ! -n "$sources" ]; then
sources="deb http://httpredir.debian.org/debian unstable main"
fi
if [ ! -n "$version" ]; then
version=$(dpkg-parsechangelog -Sversion)
fi
if [ ! -n "$debdir" ]; then
debdir=.
fi
if [ $# = 0 ]; then
echo "Usage: $0 [ -p <package>[,<package2>,...] ] [ -d <debdir> ] [ -v <version> ] [ -s '<full sources.list line>' ] <arch> [...]" 1>&2
exit 1
fi
EXITCODE=0
for ARCH in "$@"
do
APTTMP=$(mktemp -d)
echo "$sources" > $APTTMP/sources.list
APTOPTIONS="-o APT::Architecture=$ARCH -o Dir::State=$APTTMP \
-o Dir::Cache=$APTTMP -o Debug::NoLocking=true \
-o Acquire::Languages=none \
-o Dir::Etc::Sourcelist=$APTTMP/sources.list"
apt-get $APTOPTIONS update
for p in $(echo $package | sed 's/,/ /g'); do
(cd "$debdir"; apt-get $APTOPTIONS download $p:$ARCH=$version) || EXITCODE=$?
done
rm -rf "$APTTMP"
done
exit $EXITCODE
|