File: download-deb

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (67 lines) | stat: -rwxr-xr-x 1,650 bytes parent folder | download
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
#!/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> ] [ -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
    (cd "$debdir"; apt-get $APTOPTIONS download $package:$ARCH=$version) || EXITCODE=$?
    rm -rf "$APTTMP"
done
exit $EXITCODE