Skip to content

Instantly share code, notes, and snippets.

@Justman100
Created January 6, 2025 19:45
Show Gist options
  • Save Justman100/1105f5d8ba050e9f8d25c9ab4e200267 to your computer and use it in GitHub Desktop.
Save Justman100/1105f5d8ba050e9f8d25c9ab4e200267 to your computer and use it in GitHub Desktop.
Generate fake APT packages
if [[ $1 == "-a" ]]; then
! [[ $2 ]] && echo "You must give a package name" && exit
echo $2 >> packages.txt
apt-cache show $2 | grep Depends | sed -e 's/Depends: //' -e 's/ ([^)]*)//g' -e 's/,/\n/g' -e 's/ *//g' -e 's/ *$//' >> packages.txt
exit 0
fi
rm *.deb
rm *.buildinfo
rm *.changes
for pack in $(cat packages.txt); do
equivs-control $pack
getVersion=$(apt-cache show $pack | grep Version | sed 's/Version: //g' | head -n 1)
getMaintainer=$(apt-cache show $pack | grep Maintainer | sed 's/Maintainer: //g' | head -n 1)
sed -i "s/Package: <package name; defaults to equivs-dummy>/Package: $pack/g" $pack
[[ $getVersion ]] && sed -i "s/# Version: <enter version here; defaults to 1.0>/Version: $getVersion/g" $pack
[[ $getMaintainer ]] && sed -i "s/# Maintainer: Your Name <[email protected]>/Maintainer: $getMaintainer/g" $pack
sed -i '27d' $pack
sed -i '27d' $pack
sed -i '27d' $pack
sed -i '27d' $pack
sed -i '27d' $pack
equivs-build $pack
done
for pack in $(cat packages.txt); do
apt-mark hold $pack
done
dpkg -i *.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment