Skip to content

Commit

Permalink
Fall back to sid rustc if rustup isn't available
Browse files Browse the repository at this point in the history
Rustup only has a limited number of architectures,
when the root_image we are creating isn't supported,
try to install the debian rustc compiler.
this will be older, but >95% of time, it should be ok.

Signed-off-by: Janpieter Sollie <[email protected]>
  • Loading branch information
jpsollie committed Nov 15, 2023
1 parent 1a98355 commit a899c47
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions root_image
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ install_fix_deps()
echo 'cd /tmpbuild/; $@' >> "$MNT"/tmpbuild/executer.sh
chmod ago+x "$MNT"/tmpbuild/executer.sh
_chroot "$MNT" /tmpbuild/executer.sh apt-get -qq build-dep --allow-unauthenticated --no-install-recommends $i || intervene install-deps $i;
_chroot "$MNT" /tmpbuild/executer.sh apt-get -qq -b source --allow-unauthenticated $i || intervene build $i;
[ -f "${MNT}/tmpbuild/${i}*.deb" ] && _chroot "$MNT" apt-get -qq install /tmpbuild/${i}*.deb;
#in case the intervention also installed it, continue:
if [[ $(_chroot "$MNT" dpkg -l | grep "^ii $i") == "" ]]; then
_chroot "$MNT" /tmpbuild/executer.sh apt-get -qq -b source --allow-unauthenticated $i || intervene build $i;
[ -f "${MNT}/tmpbuild/${i}*.deb" ] && _chroot "$MNT" apt-get -qq install /tmpbuild/${i}*.deb;
fi
umount ${MNT}/tmpbuild;
rmdir ${MNT}/tmpbuild;
done
Expand Down Expand Up @@ -286,25 +289,32 @@ ZZ

update_packages()
{
NO_RUSTUP=0
# systemd... !?
mkdir -p "$MNT"/run/user/0
cp /etc/resolv.conf "$MNT/etc/resolv.conf"

[[ $(curl -qq -I "https://static.rust-lang.org/rustup/${RUST_TRIPLE}/rustup-init" 2>/dev/null | grep "HTTP/2 200") == "" ]] && NO_RUSTUP=1
[ $NO_RUSTUP ] && PACKAGES+=(rustc rustc-dbgsym rustfmt rustfmt-dbgsym) #don't do rustup on unsupported architectures, just try from debian repositories

_chroot "$MNT" mount -t proc none /proc
if [[ $MIRROR == *"debian-ports"* ]]; then
install_fix_deps
else
_chroot "$MNT" apt-get -qq --allow-unauthenticated --allow-insecure-repositories update --fix-missing
_chroot "$MNT" apt-get -qq --allow-unauthenticated upgrade
_chroot "$MNT" apt-get -qq install -f
_chroot "$MNT" apt-get -qq install -m --allow-unauthenticated --no-install-recommends "${PACKAGES[@]}"
_chroot "$MNT" apt-get -qq --allow-unauthenticated --allow-insecure-repositories update --fix-missing
_chroot "$MNT" apt-get -qq --allow-unauthenticated upgrade
_chroot "$MNT" apt-get -qq install -f
_chroot "$MNT" apt-get -qq install -m --allow-unauthenticated --no-install-recommends "${PACKAGES[@]}"
fi
rm -f "$MNT/var/cache/apt/archives/*.deb"

if [ ! $NO_RUSTUP ]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > "$MNT"/tmp/rustup.sh
chmod 755 "$MNT"/tmp/rustup.sh

_chroot "$MNT" /tmp/rustup.sh --default-host $RUST_TRIPLE -y
echo 'export PATH="$HOME/.cargo/bin:$PATH"' > $MNT/etc/profile.d/rustup.sh
fi;
}

trim_image()
Expand Down Expand Up @@ -353,7 +363,6 @@ cmd_create()
echo "$ktest_image already exists"
exit 1
fi
set -o xtrace
(cd "$ktest_dir"; git submodule update --init debootstrap)

MNT=$(mktemp --tmpdir -d $(basename "$0")-XXXXXXXXXX)
Expand Down

0 comments on commit a899c47

Please sign in to comment.