File: debget

package info (click to toggle)
debian-goodies 0.84
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 376 kB
  • sloc: sh: 875; python: 769; perl: 565; makefile: 14
file content (59 lines) | stat: -rwxr-xr-x 1,614 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
#!/bin/sh

# debget - Fetch a .deb for a package in APT's database

# Copyright (C) 2001,2002 Matt Zimmerman <mdz@debian.org>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#


# Set the locale so we can control apt-get errors properly
LC_ALL=C

usage()
{
    echo "Usage: `basename $0` [--help] package"
}

if [ $# -eq 0 ] ; then
	usage
	exit 1
fi

case $1 in
    "-h")     usage; exit 0;;
    "--help") usage; exit 0;;
    -*) echo "Unknown option $1"; usage; exit 1;;
esac

# First check if apt-get is sane enough before proceeding
if ! ls /var/lib/apt/lists/ |grep Release >/dev/null; then
    echo "ERROR: Your apt lists are empty. Update your package database"
    echo "using 'apt-get update'"
fi

error=0
for pkgspec in $*; do
   apt-get download "$pkgspec"
   if [ $? -ne 0 ] ; then
        echo "If you believe the package exists then consider updating your"
        echo "package database using 'apt-get update'."
        error=1
	continue
   fi
done
exit $error