Merge ~mwhudson/debian-cd/+git/ubuntu:a-bit-less-hardcoding into ~ubuntu-cdimage/debian-cd/+git/ubuntu:main

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 6ffeaa8495946c8e72e0239a1a38c17152e43339
Proposed branch: ~mwhudson/debian-cd/+git/ubuntu:a-bit-less-hardcoding
Merge into: ~ubuntu-cdimage/debian-cd/+git/ubuntu:main
Diff against target: 154 lines (+45/-17)
5 files modified
CONF.sh (+0/-2)
tools/apt-selection (+8/-2)
tools/list2src (+6/-1)
tools/scanpackages (+18/-6)
tools/scansources (+13/-6)
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+456815@code.launchpad.net

Commit message

reduce reliance on environment variables for locating apt state

And instead read values via apt-config instead.

Description of the change

This is all in aid of my plan to have ubuntu-cdimage taking over the "set up apt for pool creation" stuff

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Thanks, addressed comments (and rebased).

Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/CONF.sh b/CONF.sh
2index fadfb22..1b63e19 100644
3--- a/CONF.sh
4+++ b/CONF.sh
5@@ -148,8 +148,6 @@ export OUT=$CDIMAGE_ROOT/scratch/$PROJECT/$DIST/$IMAGE_TYPE/debian-cd
6 # Where we keep the temporary apt stuff.
7 # This cannot reside on an NFS mount.
8 export APTTMP=$CDIMAGE_ROOT/scratch/$PROJECT/$DIST/$IMAGE_TYPE/apt
9-export APT_STATE=$APTTMP/$CODENAME-$FULLARCH/apt-state/
10-export APT_CACHE=$APTTMP/$CODENAME-$FULLARCH/apt-cache/
11
12 # Where extracted debootstrap scripts live
13 export DEBOOTSTRAP=$CDIMAGE_ROOT/scratch/$PROJECT/$DIST/$IMAGE_TYPE/debootstrap
14diff --git a/tools/apt-selection b/tools/apt-selection
15index 7a25ee8..e373858 100755
16--- a/tools/apt-selection
17+++ b/tools/apt-selection
18@@ -24,8 +24,10 @@ if [ -z "$FULLARCH" ]; then
19 FULLARCH="$ARCH"
20 fi
21
22-options=" -q -o Dir::State::status=/dev/null
23- -o Dir::State=$APT_STATE -o Dir::Cache=$APT_CACHE \
24+options=" -q -o Dir=$APTTMP/$CODENAME-$FULLARCH/ \
25+ -o Dir::State::status=/dev/null \
26+ -o Dir::State=$APTTMP/$CODENAME-$FULLARCH/apt-state/ \
27+ -o Dir::Cache=$APTTMP/$CODENAME-$FULLARCH/apt-cache/ \
28 -o Dir::Etc=$APTTMP/$CODENAME-$FULLARCH/apt/ \
29 -o APT::Cache::AllVersions=0 \
30 -o APT::Architecture=$ARCH "
31@@ -103,6 +105,10 @@ elif [ "$1" = "cache" ]; then
32 shift
33 apt-cache $options $@
34 exit $?
35+elif [ "$1" = "config" ]; then
36+ shift
37+ apt-config $options $@
38+ exit $?
39 elif [ "$1" = "deselected" ]; then
40 shift
41 apt-get $options -s $@ > $temp
42diff --git a/tools/list2src b/tools/list2src
43index 6ccbe6a..af37212 100755
44--- a/tools/list2src
45+++ b/tools/list2src
46@@ -28,7 +28,12 @@ my $bdir = "$ENV{'TDIR'}/$ENV{'CODENAME'}-$ENV{'FULLARCH'}";
47 my $sdir = "$ENV{'TDIR'}/$ENV{'CODENAME'}-src";
48 my $verbose = $ENV{'VERBOSE'} || 0;
49
50-my $apt_lists = "$ENV{'APT_STATE'}/lists";
51+my $apt = "$ENV{'BASEDIR'}/tools/apt-selection";
52+
53+# Appending /d to the name of the configuration item gets apt-config
54+# to expand the item into a full directory path.
55+my $apt_lists_cmd = `$apt config shell LISTS Dir::State::lists/d`;
56+my $apt_lists = `eval $apt_lists_cmd; echo \$LISTS`;
57 my $mirror = $ENV{'MIRROR'};
58 my $codename = $ENV{'CODENAME'};
59
60diff --git a/tools/scanpackages b/tools/scanpackages
61index 9fed6ac..84c25d3 100755
62--- a/tools/scanpackages
63+++ b/tools/scanpackages
64@@ -50,18 +50,24 @@ if [ "$1" = "install" ]; then
65
66 $BASEDIR/tools/apt-selection update
67
68-if [ -e $APT_STATE/lists/*_dists_${CODENAME}_InRelease ]; then
69+# Appending /d to the name of the configuration item gets apt-config
70+# to expand the item into a full directory path.
71+eval "$($BASEDIR/tools/apt-selection config shell APT_LISTS_DIR Dir::state::lists/d)"
72+
73+IN_RELEASE=$APT_LISTS_DIR/*_dists_${CODENAME}_InRelease
74+
75+if [ -e $IN_RELEASE ]; then
76 # Strip the MD5Sum, SHA1, and SHA256 fields
77 # Update some other information as well
78- gpg --verify --output - $APT_STATE/lists/*_dists_${CODENAME}_InRelease 2>/dev/null | \
79+ gpg --verify --output - $IN_RELEASE 2>/dev/null | \
80 sed -e "s/^Architectures: .*$/Architectures: $ALL_ARCHES/" | \
81 sed -e "s|^Components: .*$|Components: $COMPONENTS|" | \
82- perl -ne 'if (/^(MD5Sum|SHA1|SHA256):/i) { $f=1; next }
83- if ($f) {
84+ perl -ne 'if (/^(MD5Sum|SHA1|SHA256):/i) { $f=1; next }
85+ if ($f) {
86 unless (/^ /) { print; $f=0 }
87 } else { print }' > dists/$CODENAME/Release
88 else
89- echo "ERROR: Release file ($MIRROR/dists/$CODENAME/Release) is missing !"
90+ echo "ERROR: Release file ($IN_RELEASE) is missing !"
91 exit 1
92 fi
93
94@@ -108,11 +114,17 @@ for SECT in $SECTIONS; do
95 done
96 done
97 done
98+
99+# Appending /d to the name of the configuration item gets apt-config
100+# to expand the item into a full directory path.
101+eval "$($BASEDIR/tools/apt-selection config shell APT_DIR Dir/d)"
102+mkdir -p $APT_DIR/apt-ftparchive-db
103+
104 # Creating the config files
105 cat >$PREFIX.generate-binary <<EOF
106 Dir::ArchiveDir "$2";
107 Dir::OverrideDir "$BDIR/indices";
108-Dir::CacheDir "$APTTMP/$CODENAME-$FULLARCH/apt-ftparchive-db";
109+Dir::CacheDir "$APT_DIR/apt-ftparchive-db";
110
111 TreeDefault::Contents " ";
112
113diff --git a/tools/scansources b/tools/scansources
114index 6a84317..f0fc703 100755
115--- a/tools/scansources
116+++ b/tools/scansources
117@@ -47,13 +47,17 @@ done
118
119 $BASEDIR/tools/apt-selection update
120
121-if [ -e $APT_STATE/lists/*_dists_${CODENAME}_InRelease ]; then
122+eval "$($BASEDIR/tools/apt-selection config shell APT_LISTS_DIR Dir::state::lists/d)"
123+
124+IN_RELEASE=$APT_LISTS_DIR/*_dists_${CODENAME}_InRelease
125+
126+if [ -e $IN_RELEASE ]; then
127 # Strip the MD5Sum, SHA1, and SHA256 fields
128+ gpg --verify --output - $IN_RELEASE 2>/dev/null | \
129 perl -ne 'if (/^(MD5Sum|SHA1|SHA256):/) { $f=1; next; }
130- if ($f) {
131- unless (/^ /) { print; $f=0 }
132- } else { print }' \
133- $APT_STATE/lists/*_dists_${CODENAME}_InRelease | \
134+ if ($f) {
135+ unless (/^ /) { print; $f=0 }
136+ } else { print }' | \
137 sed -e "s|^Codename: .*$|Codename: $CODENAME|" \
138 > dists/$CODENAME/Release
139 fi
140@@ -71,11 +75,14 @@ for SECT in $SECTIONS; do
141 done
142 done
143
144+eval "$($BASEDIR/tools/apt-selection config shell APT_DIR Dir/d)"
145+mkdir -p $APT_DIR/apt-ftparchive-db
146+
147 # Creating the config files
148 cat >$PREFIX.generate-source <<EOF
149 Dir::ArchiveDir "$1";
150 Dir::OverrideDir "$SDIR/indices";
151-Dir::CacheDir "$APTTMP/$CODENAME-$FULLARCH/apt-ftparchive-db";
152+Dir::CacheDir "$APT_DIR/apt-ftparchive-db";
153
154 TreeDefault::Contents " ";
155

Subscribers

People subscribed via source and target branches