File: apt-selection

package info (click to toggle)
debian-cd 3.2.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,848 kB
  • sloc: sh: 6,129; perl: 4,129; makefile: 413
file content (167 lines) | stat: -rwxr-xr-x 4,733 bytes parent folder | download | duplicates (2)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/sh

# This is a little shell script that will launch apt-get in dry-run mode
# to find all the dependencies of a specific package

# There's not set -e here because this script may fail !
# Apt doesn't always work ... 
# set -e

# Get the configuration information if necessary
if [ -z "$CODENAME" ] || [ -z "$ARCH" ] || [ -z "$APTTMP" ]; then
	if [ -e CONF.sh ]; then
		. CONF.sh
	else
		echo "Please set up environment variables before "
		echo "launching this program ..."
		echo "Current values are :"
		echo "CODENAME=$CODENAME"
		echo "ARCH=$ARCH"
		echo "APTTMP=$APTTMP"
		echo "USE_BP=$USE_BP"
	fi
fi

if [ $ARCH = "source" ] ; then
	ADEB="deb-src"
	ALLVERSIONS=1
else
	ADEB="deb"
	ALLVERSIONS=0
fi

if [ "$USE_BP"x = "1"x ] ; then
    THIS_PKGSET="$CODENAME-backports-$ARCH"
else
    THIS_PKGSET="$CODENAME-$ARCH"
fi

options=" -q -o Dir::State::status=$APTTMP/$THIS_PKGSET/status \
		  -o Dir::State=$APTTMP/$THIS_PKGSET/apt-state/ \
		  -o Dir::Cache=$APTTMP/$THIS_PKGSET/apt-cache/ \
		  -o Dir::Etc=$APTTMP/$THIS_PKGSET/apt/ \
		  -o APT::Cache::AllVersions=$ALLVERSIONS \
		  -o APT::Cache::ShowVersion=1 \
		  -o APT::Architecture=$ARCH \
		  -o APT::Architectures::=$ARCH \
		  -o Acquire::Languages=none"

sections=main
if [ "${CONTRIB:-0}" != "0" ]; then
	sections="$sections contrib"
fi
if [ "${NONFREE:-0}" != "0" ] || [ "${EXTRANONFREE:-0}" != "0" ] || [ "${FORCE_FIRMWARE:-0}" != "0" ]; then
	sections="$sections $NONFREE_COMPONENTS"
fi

# Check for the necessary dirs and files ...
if [ ! -d "$APTTMP/$THIS_PKGSET/apt-state/lists/partial" ]; then
	mkdir -p "$APTTMP/$THIS_PKGSET/apt-state/lists/partial"
fi
if [ ! -d "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial" ]; then
	mkdir -p "$APTTMP/$THIS_PKGSET/apt-cache/archives/partial"
fi
if [ ! -d "$APTTMP/$THIS_PKGSET/apt" ]; then
	mkdir -p "$APTTMP/$THIS_PKGSET/apt"
fi
if [ ! -e "$APTTMP/$THIS_PKGSET/status" ]; then
    touch "$APTTMP/$THIS_PKGSET/status"
fi
if [ ! -e "$APTTMP/$THIS_PKGSET/apt/sources.list" ]; then

	# Backports
	if [ -n "$USE_BP" ]; then
		echo "$ADEB file:$MIRROR $CODENAME-backports $sections" \
			>> $APTTMP/$THIS_PKGSET/apt/sources.list
		if [ $ARCH != source ] ; then
		    if [ -e "$MIRROR/dists/$CODENAME-backports/main/debian-installer" ]; then
			echo "$ADEB file:$MIRROR $CODENAME-backports main/debian-installer" \
			     >> $APTTMP/$THIS_PKGSET/apt/sources.list
		    fi
		fi
	else
	# Generating a correct sources.list file
	echo "$ADEB file:$MIRROR $CODENAME $sections" \
	> $APTTMP/$THIS_PKGSET/apt/sources.list

	if [ -n "$PROPOSED_UPDATES" ]; then
		echo "$ADEB file:$MIRROR $PROPOSED_UPDATES $sections" \
			>> $APTTMP/$THIS_PKGSET/apt/sources.list
	fi

	# Local packages ...
	if [ -n "$LOCAL" ]; then
		echo "$ADEB [trusted=yes] file:${LOCALDEBS:-$MIRROR} $CODENAME local" \
			>> $APTTMP/$THIS_PKGSET/apt/sources.list
	fi

	# Security mirror ...
	if [ -n "$SECURITY" ]; then
		case $CODENAME in
			stretch|buster) SEC=$CODENAME/updates;;
			*)		SEC=$CODENAME-security;;
		esac

		echo "$ADEB file:${SECURITY:-$MIRROR} $SEC $sections" \
		>> $APTTMP/$THIS_PKGSET/apt/sources.list
	fi

	# Debian Ports unreleased packages ...
	if [ -n "$UNRELEASED" ]; then
		echo "$ADEB file:$MIRROR unreleased main" \
			>> $APTTMP/$THIS_PKGSET/apt/sources.list
	fi

	# Debian-installer
	if [ $ARCH != source ] ; then
		if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer" ]; then
			echo "$ADEB file:$MIRROR $DI_CODENAME main/debian-installer" \
				>> $APTTMP/$THIS_PKGSET/apt/sources.list
		fi
		if [ -n "$UNRELEASED" ]; then
			echo "$ADEB file:$MIRROR unreleased main/debian-installer" \
				>> $APTTMP/$THIS_PKGSET/apt/sources.list
		fi
		if [ -n "$LOCAL" ] && [ -e "${LOCALDEBS:-$MIRROR}/dists/$DI_CODENAME/local/debian-installer" ]; then
			echo "$ADEB [trusted=yes] file:${LOCALDEBS:-$MIRROR} $DI_CODENAME local/debian-installer" \
				>> $APTTMP/$THIS_PKGSET/apt/sources.list
		fi
	fi
	fi
fi

temp=$APTTMP/$THIS_PKGSET/temp.apt-selection

# Launch the command
if [ "$1" = "update" ] || [ "$1" = "check" ]; then
	apt-get $options $@
	exit $?
elif [ "$1" = "cache" ]; then
	shift
	if [ "$1" = "showsrc" ]; then
		options="$options --only-source"
	fi
	apt-cache $options $@
	exit $?
elif [ "$1" = "deselected" ]; then
	shift
	apt-get $options -s $@ > $temp
	num=$?
	#if [ $num -ne 0 ]; then 
		#echo ": Param: apt-selection deselected $@" >&2; 
	#exit $num;  
	#fi
	perl -ne 'print "$1\n" if /^Remv (\S+).*/' $temp | sort
elif [ "$1" = "selected" ]; then
	shift
	apt-get $options -s $@ > $temp 
	num=$?
	#if [ $num -ne 0 ]; then 
	#    echo "ERROR: Param: apt-selection selected $@" >&2; 
	#    exit $num;  
	#fi
	perl -ne 'print "$1\n" if /^Inst (\S+).*/' $temp | sort
else
	apt-get $options -s $@
	exit $?
fi