-
-
Save mschmitt/5116582afa7d00c8c89dc7cdeee763d0 to your computer and use it in GitHub Desktop.
Script for checking a remote APT repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
repos[0]='deb http://de.deb.devuan.org/merged ascii main contrib non-free' | |
repos[1]='deb http://de.deb.devuan.org/merged ascii-security main contrib non-free' | |
pgpkey[0]='https://git.devuan.org/devuan-packages/devuan-keyring/raw/master/keyrings/devuan-archive-keyring.gpg?inline=false' | |
pgpkey[1]='https://git.devuan.org/devuan-packages/devuan-keyring/raw/master/keyrings/devuan-archive-keyring.gpg?inline=false' | |
function cleanup() { | |
printf "Cleaning up %s\n" "${tempdir}" | |
( | |
rmdir "${tempdir}/etc/apt/apt.conf.d" | |
rm "${tempdir}/etc/apt/"* | |
rmdir "${tempdir}/etc/apt" | |
rmdir "${tempdir}/etc" | |
rm "${tempdir}/state/lists/auxfiles/"* | |
rmdir "${tempdir}/state/lists/auxfiles" | |
rm "${tempdir}/state/lists/partial/"* | |
rmdir "${tempdir}/state/lists/partial" | |
rm "${tempdir}/state/lists/lock" | |
rm "${tempdir}/state/lists/"* | |
rmdir "${tempdir}/state/lists" | |
rm "${tempdir}/cache/"* | |
rmdir "${tempdir}/cache" | |
rm "${tempdir}/state/"* | |
rmdir "${tempdir}/state" | |
) > /dev/null 2>&1 | |
rmdir "${tempdir}" | |
exit | |
} | |
trap cleanup INT QUIT TERM EXIT | |
tempdir="$(mktemp -d)" | |
install -d "${tempdir}/state" | |
install -d "${tempdir}/etc/apt" | |
install -d "${tempdir}/etc/apt/apt.conf.d" | |
install -d "${tempdir}/state/lists/partial" | |
install /dev/null "${tempdir}/etc/apt/trusted.gpg" | |
install /dev/null "${tempdir}/state/status" | |
cat > "${tempdir}/etc/apt/apt.conf" <<End | |
Dir::Etc "${tempdir}/etc/apt"; | |
Dir::Cache "${tempdir}/cache"; | |
Dir::State "${tempdir}/state"; | |
Dir::State::status "${tempdir}/state/status"; | |
End | |
for (( index = 0; index < ${#repos[@]}; index++ )) | |
do | |
echo "${repos[$index]}" >> "${tempdir}/etc/apt/sources.list" | |
curl "${pgpkey[$index]}" | | |
gpg --no-default-keyring \ | |
--keyring "${tempdir}/etc/apt/trusted.gpg" --import | |
done | |
export APT_CONFIG="${tempdir}/etc/apt/apt.conf" | |
apt-get update | |
apt-cache stats | |
#printf "\nPackages in repository:\n" | |
#apt-cache pkgnames | sort | |
#printf "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment