@@ -171,12 +171,14 @@ main() {
171
171
sharutils \
172
172
gnupg
173
173
174
- # amd64 has conflicting versions of the packages installed, so
174
+ # conflicting versions of some packages will be installed already for the host platform,
175
175
# we need to remove the system installs later. since apt relies
176
176
# on these packages, we need to download them and reinstall
177
177
# using dpkg later, since we cannot redownload via apt.
178
+ local dpkg_arch
179
+ dpkg_arch=$( dpkg --print-architecture)
178
180
local libgcc_packages=(" ${libgcc} :${arch} " " libstdc++6:${arch} " )
179
- if [[ " ${arch} " == " amd64 " ]]; then
181
+ if [[ " ${arch} " == " ${dpkg_arch} " ]]; then
180
182
local libgcc_root=/qemu/libgcc
181
183
mkdir -p " ${libgcc_root} "
182
184
pushd " ${libgcc_root} "
@@ -186,6 +188,7 @@ main() {
186
188
187
189
# Download packages
188
190
mv /etc/apt/sources.list /etc/apt/sources.list.bak
191
+ mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak
189
192
echo -e " ${debsource} " > /etc/apt/sources.list
190
193
191
194
# Old ubuntu does not support --add-architecture, so we directly change multiarch file
@@ -240,10 +243,10 @@ main() {
240
243
ncurses-base" ${ncurses} " \
241
244
" zlib1g:${arch} "
242
245
243
- if [[ " ${arch} " != " amd64 " ]]; then
246
+ if [[ " ${arch} " != " ${dpkg_arch} " ]]; then
244
247
apt-get -d --no-install-recommends download " ${libgcc_packages[@]} "
245
248
else
246
- # amd64 has conflicting versions of the packages installed
249
+ # host arch has conflicting versions of the packages installed
247
250
# this prevents us from downloading them, so we need to
248
251
# simply grab the last version from the debian sources.
249
252
# we're search for a paragraph with:
380
383
find . | cpio --create --format=' newc' --quiet | gzip > ../initrd.gz
381
384
cd -
382
385
383
- if [[ " ${arch} " == " amd64 " ]]; then
386
+ if [[ " ${arch} " == " ${dpkg_arch} " ]]; then
384
387
# need to reinstall these packages, since basic utilities rely on them.
385
388
pushd " ${libgcc_root} "
386
389
dpkg -i --force-depends " ${libgcc_root} " /* .deb
@@ -391,15 +394,16 @@ EOF
391
394
# Clean up
392
395
rm -rf " /qemu/${root} " " /qemu/${arch} "
393
396
mv -f /etc/apt/sources.list.bak /etc/apt/sources.list
397
+ mv -f /etc/apt/sources.list.d.bak /etc/apt/sources.list.d
394
398
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch.bak ]; then
395
399
mv /etc/dpkg/dpkg.cfg.d/multiarch.bak /etc/dpkg/dpkg.cfg.d/multiarch
396
400
fi
397
- # can fail if arch is used (amd64 and/or i386)
401
+ # can fail if arch is used (image arch, such as amd64 and/or i386)
398
402
dpkg --remove-architecture " ${arch} " || true
399
403
apt-get update
400
404
401
405
# need to reinstall the removed libgcc packages, which are required for apt
402
- if [[ " ${arch} " == " amd64 " ]]; then
406
+ if [[ " ${arch} " == " ${dpkg_arch} " ]]; then
403
407
apt-get install --no-install-recommends --assume-yes " ${packages[@]} "
404
408
fi
405
409
0 commit comments