| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# debget - Fetch a .deb for a package in APT's database |
| 4 |
|
| 5 |
# Copyright (C) 2001,2002 Matt Zimmerman <[email protected]> |
| 6 |
|
| 7 |
# This program is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 2, or (at your option) |
| 10 |
# any later version. |
| 11 |
|
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
|
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program; if not, write to the Free Software |
| 19 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 |
# 02111-1307, USA. |
| 21 |
# |
| 22 |
|
| 23 |
|
| 24 |
# Set the locale so we can control apt-get errors properly |
| 25 |
LC_ALL=C |
| 26 |
|
| 27 |
usage() |
| 28 |
{ |
| 29 |
echo "Usage: `basename $0` [--help] package" |
| 30 |
} |
| 31 |
|
| 32 |
if [ $# -eq 0 ] ; then |
| 33 |
usage |
| 34 |
exit 1 |
| 35 |
fi |
| 36 |
|
| 37 |
case $1 in |
| 38 |
"-h") usage; exit 0;; |
| 39 |
"--help") usage; exit 0;; |
| 40 |
-*) echo "Unknown option $1"; usage; exit 1;; |
| 41 |
esac |
| 42 |
|
| 43 |
# First check if apt-get is sane enough before proceeding |
| 44 |
if ! ls /var/lib/apt/lists/ |grep Release >/dev/null; then |
| 45 |
echo "ERROR: Your apt lists are empty. Update your package database" |
| 46 |
echo "using 'apt update'" |
| 47 |
fi |
| 48 |
|
| 49 |
error=0 |
| 50 |
for pkgspec in $*; do |
| 51 |
apt-get download "$pkgspec" |
| 52 |
if [ $? -ne 0 ] ; then |
| 53 |
echo "If you believe the package exists then consider updating your" |
| 54 |
echo "package database using 'apt update'." |
| 55 |
error=1 |
| 56 |
continue |
| 57 |
fi |
| 58 |
done |
| 59 |
exit $error |