~jibel/debian-cd/rename_artefacts_made_generic

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
168
169
170
171
172
173
174
175
#!/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" -o -z "$ARCH" -o -z "$APTTMP" ]; then
	if [ -e CONF.sh ]; then
		source CONF.sh
	else
		echo "Please set the good environment variables before "
		echo "launching this program ..."
		echo "Current values are :"
		echo "CODENAME=$CODENAME"
		echo "ARCH=$ARCH"
		echo "APTTMP=$APTTMP"
	fi
fi
if [ -z "$FULLARCH" ]; then
	FULLARCH="$ARCH"
fi

options=" -q -o Dir::State::status=$APTTMP/$CODENAME-$FULLARCH/status \
          -o Dir::State=$APTTMP/$CODENAME-$FULLARCH/apt-state/ \
	  -o Dir::Cache=$APTTMP/$CODENAME-$FULLARCH/apt-cache/ \
	  -o Dir::Etc=$APTTMP/$CODENAME-$FULLARCH/apt/ \
	  -o APT::Cache::AllVersions=0 \
	  -o APT::Architecture=$ARCH "

sections=main
if [ "${NONFREE:-0}" != "0" -o "${EXTRANONFREE:-0}" != "0" ]; then
	sections="$sections non-free"
fi
if [ "${CONTRIB:-0}" != "0" ]; then
	sections="$sections contrib"
fi
if [ "${RESTRICTED:-0}" != "0" ]; then
	sections="$sections restricted"
fi
if [ "${UNIVERSE:-0}" != "0" ]; then
	sections="$sections universe"
fi
if [ "${MULTIVERSE:-0}" != "0" ]; then
	sections="$sections multiverse"
fi

# Check for the necessary dirs and files ...
if [ ! -d "$APTTMP/$CODENAME-$FULLARCH/apt-state/lists/partial" ]; then
	mkdir -p "$APTTMP/$CODENAME-$FULLARCH/apt-state/lists/partial"
fi
if [ ! -d "$APTTMP/$CODENAME-$FULLARCH/apt-cache/archives/partial" ]; then
	mkdir -p "$APTTMP/$CODENAME-$FULLARCH/apt-cache/archives/partial"
fi
if [ ! -d "$APTTMP/$CODENAME-$FULLARCH/apt" ]; then
	mkdir -p "$APTTMP/$CODENAME-$FULLARCH/apt"
fi
if [ ! -e "$APTTMP/$CODENAME-$FULLARCH/apt/sources.list" ]; then
	# Generating a correct sources.list file
	echo "deb file:$MIRROR $CODENAME $sections" \
	> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	if [ -n "$NONUS" ]; then
	     echo "deb file:$NONUS $CODENAME/non-US $sections" \
	     >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	fi
	# Local packages ...
	if [ -n "$LOCAL" ]; then
	  echo "deb file:${LOCALDEBS:-$MIRROR} $CODENAME local" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	fi
        # Security mirror ...
        if [ -n "$SECURITY" ]; then
	  echo "deb file:${SECURITY:-$MIRROR} $CODENAME-security $sections" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
        fi
	# Post-release updates
	if [ "${UPDATES:-0}" != "0" ]; then
	  echo "deb file:$MIRROR $CODENAME-updates $sections" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	fi
	if [ "${PROPOSED:-0}" != "0" ]; then
	  echo "deb file:$MIRROR $CODENAME-proposed $sections" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	fi
	# Debian-installer
	if [ -e "$MIRROR/dists/$DI_CODENAME/main/debian-installer" ]; then
	  echo "deb file:$MIRROR $DI_CODENAME main/debian-installer" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  if [ -n "$SECURITY" -a -e "$MIRROR/dists/$DI_CODENAME-security/main/debian-installer" ]; then
	    echo "deb file:${SECURITY:-$MIRROR} $DI_CODENAME-security main/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${UPDATES:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-updates/main/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-updates main/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${PROPOSED:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-proposed/main/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-proposed main/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	fi
	if [ "${RESTRICTED:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME/restricted/debian-installer" ]; then
	  echo "deb file:$MIRROR $DI_CODENAME restricted/debian-installer" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  if [ -n "$SECURITY" -a -e "$MIRROR/dists/$DI_CODENAME-security/restricted/debian-installer" ]; then
	    echo "deb file:${SECURITY:-$MIRROR} $DI_CODENAME-security restricted/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${UPDATES:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-updates/restricted/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-updates restricted/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${PROPOSED:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-proposed/restricted/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-proposed restricted/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	fi
	if [ "${UNIVERSE:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME/universe/debian-installer" ]; then
	  echo "deb file:$MIRROR $DI_CODENAME universe/debian-installer" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  if [ -n "$SECURITY" -a -e "$MIRROR/dists/$DI_CODENAME-security/universe/debian-installer" ]; then
	    echo "deb file:${SECURITY:-$MIRROR} $DI_CODENAME-security universe/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${UPDATES:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-updates/universe/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-updates universe/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	  if [ "${PROPOSED:-0}" != "0" -a -e "$MIRROR/dists/$DI_CODENAME-proposed/universe/debian-installer" ]; then
	    echo "deb file:$MIRROR $DI_CODENAME-proposed universe/debian-installer" \
	    >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	  fi
	fi
	if [ -n "$LOCAL" -a -e "${LOCALDEBS:-$MIRROR}/dists/$DI_CODENAME/local/debian-installer" ]; then
	  echo "deb file:${LOCALDEBS:-$MIRROR} $DI_CODENAME local/debian-installer" \
	  >> $APTTMP/$CODENAME-$FULLARCH/apt/sources.list
	fi
fi

temp=$APTTMP/$CODENAME-$FULLARCH/temp.apt-selection

# Launch the command
if [ "$1" = "update" -o "$1" = "check" ]; then
	apt-get $options $@
	exit $?
elif [ "$1" = "cache" ]; then
	shift
	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