| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# This is a little shell script that will launch apt-get in dry-run mode |
| 4 |
# to find all the dependencies of a specific package |
| 5 |
|
| 6 |
# There's not set -e here because this script may fail ! |
| 7 |
# Apt doesn't always work ... |
| 8 |
# set -e |
| 9 |
|
| 10 |
# Get the configuration information if necessary |
| 11 |
if [ -z "$CODENAME" ] || [ -z "$ARCH" ] || [ -z "$APTTMP" ]; then |
| 12 |
if [ -e CONF.sh ]; then |
| 13 |
. CONF.sh |
| 14 |
else |
| 15 |
echo "Please set up environment variables before " |
| 16 |
echo "launching this program ..." |
| 17 |
echo "Current values are :" |
| 18 |
echo "CODENAME=$CODENAME" |
| 19 |
echo "ARCH=$ARCH" |
| 20 |
echo "APTTMP=$APTTMP" |
| 21 |
echo "USE_BP=$USE_BP" |
| 22 |
fi |
| 23 |
fi |
| 24 |
|
| 25 |
if [ $ARCH = "source" ] ; then |
| 26 |
ADEB="deb-src" |
| 27 |
ALLVERSIONS=1 |
| 28 |
else |
| 29 |
ADEB="deb" |
| 30 |
ALLVERSIONS=0 |
| 31 |
fi |
| 32 |
|
| 33 |
if [ "$USE_BP"x = "1"x ] ; then |
| 34 |
THIS_PKGSET="$CODENAME-backports-$ARCH" |
| 35 |
else |
| 36 |
THIS_PKGSET="$CODENAME-$ARCH" |
| 37 |
fi |
| 38 |
|
| 39 |
options=" -q -o Dir::State::status=$APTTMP/$THIS_PKGSET/status \ |
| 40 |
-o Dir::State=$APTTMP/$THIS_PKGSET/apt-state/ \ |
| 41 |
-o Dir::Cache=$APTTMP/$THIS_PKGSET/apt-cache/ \ |
| 42 |
-o Dir::Etc=$APTTMP/$THIS_PKGSET/apt/ \ |
| 43 |
-o APT::Cache::AllVersions=$ALLVERSIONS \ |
| 44 |
-o APT::Cache::ShowVersion=1 \ |
| 45 |
-o APT::Architecture=$ARCH \ |
| 46 |
-o APT::Architectures::=$ARCH \ |
| 47 |
-o Acquire::Languages=none" |
| 48 |
|
| 49 |
sections=main |
| 50 |
if [ "${CONTRIB:-0}" != "0" ]; then |
| 51 |
sections="$sections contrib" |
| 52 |
fi |
| 53 |
if [ "${NONFREE:-0}" != "0" ] || [ "${EXTRANONFREE:-0}" != "0" ] || [ "${FORCE_FIRMWARE:-0}" != "0" ]; then |
| 54 |
sections="$sections $NONFREE_COMPONENTS" |
| 55 |
fi |
| 56 |
|
| 57 |
# Check for the necessary dirs and files ... |
| 58 |
if [ ! -d "$APTTMP/$THIS_PKGSET/apt-state/lists/partial" ]; then |
| 59 |
mkdir -p "$APTTMP/$THIS_PKGSET/apt-state/lists/partial" |
| 60 |
fi |
| 61 |
if [ ! -d "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial" ]; then |
| 62 |
mkdir -p "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial" |
| 63 |
fi |
| 64 |
if [ ! -d "$APTTMP/$THIS_PKGSET/apt" ]; then |
| 65 |
mkdir -p "$APTTMP/$THIS_PKGSET/apt" |
| 66 |
fi |
| 67 |
if [ ! -e "$APTTMP/$THIS_PKGSET/status" ]; then |
| 68 |
touch "$APTTMP/$THIS_PKGSET/status" |
| 69 |
fi |
| 70 |
if [ ! -e "$APTTMP/$THIS_PKGSET/apt/sources.list" ]; then |
| 71 |
|
| 72 |
# Backports |
| 73 |
if [ -n "$USE_BP" ]; then |
| 74 |
echo "$ADEB file:$MIRROR $CODENAME-backports $sections" \ |
| 75 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 76 |
if [ $ARCH != source ] ; then |
| 77 |
if [ -e "$MIRROR/dists/$CODENAME-backports/main/debian-installer" ]; then |
| 78 |
echo "$ADEB file:$MIRROR $CODENAME-backports main/debian-installer" \ |
| 79 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 80 |
fi |
| 81 |
fi |
| 82 |
else |
| 83 |
# Generating a correct sources.list file |
| 84 |
echo "$ADEB file:$MIRROR $CODENAME $sections" \ |
| 85 |
> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 86 |
|
| 87 |
if [ -n "$PROPOSED_UPDATES" ]; then |
| 88 |
echo "$ADEB file:$MIRROR $PROPOSED_UPDATES $sections" \ |
| 89 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 90 |
fi |
| 91 |
|
| 92 |
# Local packages ... |
| 93 |
if [ -n "$LOCAL" ]; then |
| 94 |
echo "$ADEB [trusted=yes] file:${LOCALDEBS:-$MIRROR} $CODENAME local" \ |
| 95 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 96 |
fi |
| 97 |
|
| 98 |
# Security mirror ... |
| 99 |
if [ -n "$SECURITY" ]; then |
| 100 |
case $CODENAME in |
| 101 |
stretch|buster) SEC=$CODENAME/updates;; |
| 102 |
*) SEC=$CODENAME-security;; |
| 103 |
esac |
| 104 |
|
| 105 |
echo "$ADEB file:${SECURITY:-$MIRROR} $SEC $sections" \ |
| 106 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 107 |
fi |
| 108 |
|
| 109 |
# Debian Ports unreleased packages ... |
| 110 |
if [ -n "$UNRELEASED" ]; then |
| 111 |
echo "$ADEB file:$MIRROR unreleased main" \ |
| 112 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 113 |
fi |
| 114 |
|
| 115 |
# Debian-installer |
| 116 |
if [ $ARCH != source ] ; then |
| 117 |
if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer" ]; then |
| 118 |
echo "$ADEB file:$MIRROR $DI_CODENAME main/debian-installer" \ |
| 119 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 120 |
fi |
| 121 |
if [ -n "$UNRELEASED" ]; then |
| 122 |
echo "$ADEB file:$MIRROR unreleased main/debian-installer" \ |
| 123 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 124 |
fi |
| 125 |
if [ -n "$LOCAL" ] && [ -e "${LOCALDEBS:-$MIRROR}/dists/$DI_CODENAME/local/debian-installer" ]; then |
| 126 |
echo "$ADEB [trusted=yes] file:${LOCALDEBS:-$MIRROR} $DI_CODENAME local/debian-installer" \ |
| 127 |
>> $APTTMP/$THIS_PKGSET/apt/sources.list |
| 128 |
fi |
| 129 |
fi |
| 130 |
fi |
| 131 |
fi |
| 132 |
|
| 133 |
temp=$APTTMP/$THIS_PKGSET/temp.apt-selection |
| 134 |
|
| 135 |
# Launch the command |
| 136 |
if [ "$1" = "update" ] || [ "$1" = "check" ]; then |
| 137 |
apt-get $options $@ |
| 138 |
exit $? |
| 139 |
elif [ "$1" = "cache" ]; then |
| 140 |
shift |
| 141 |
if [ "$1" = "showsrc" ]; then |
| 142 |
options="$options --only-source" |
| 143 |
fi |
| 144 |
apt-cache $options $@ |
| 145 |
exit $? |
| 146 |
elif [ "$1" = "deselected" ]; then |
| 147 |
shift |
| 148 |
apt-get $options -s $@ > $temp |
| 149 |
num=$? |
| 150 |
#if [ $num -ne 0 ]; then |
| 151 |
#echo ": Param: apt-selection deselected $@" >&2; |
| 152 |
#exit $num; |
| 153 |
#fi |
| 154 |
perl -ne 'print "$1\n" if /^Remv (\S+).*/' $temp | sort |
| 155 |
elif [ "$1" = "selected" ]; then |
| 156 |
shift |
| 157 |
apt-get $options -s $@ > $temp |
| 158 |
num=$? |
| 159 |
#if [ $num -ne 0 ]; then |
| 160 |
# echo "ERROR: Param: apt-selection selected $@" >&2; |
| 161 |
# exit $num; |
| 162 |
#fi |
| 163 |
perl -ne 'print "$1\n" if /^Inst (\S+).*/' $temp | sort |
| 164 |
else |
| 165 |
apt-get $options -s $@ |
| 166 |
exit $? |
| 167 |
fi |