Skip to content

Instantly share code, notes, and snippets.

@rcj4747
Created January 26, 2018 21:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rcj4747/acdd0b7931d97a0600a63751e48f0dc1 to your computer and use it in GitHub Desktop.
Save rcj4747/acdd0b7931d97a0600a63751e48f0dc1 to your computer and use it in GitHub Desktop.
Add a package from a private PPA to a chroot and strip references to the private PPA
REPO_LINE="deb https://${LP_USER}:${PPA_PASSWORD}@${PRIVATE_PPA_URL} ${SUITE} main"
REPO_KEY_FINGERPRINT=832749327429CADB77842973ED72947203471037
# Add the private ppa to the system
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-add-repository "${REPO_LINE}"
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key adv --keyserver keyserver.ubuntu.com --recv ${REPO_KEY_FINGERPRINT}
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get update
# Install from private PPA HERE
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get install -qqy awesome_package_but_super_secret
# Remove the repo
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-add-repository --remove "${REPO_LINE}"
# Delete the key (using the last 8 characters of the full fingerprint)
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key list
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key del ${REPO_KEY_FINGERPRINT:(-8)}
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key list
# Delete backups that would reveal our private PPA
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" cat /etc/apt/sources.list
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" rm /etc/apt/sources.list.save
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" rm /etc/apt/trusted.gpg~
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get update
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get clean
@rcj4747
Copy link
Author

rcj4747 commented Jan 26, 2018

This has to be in bash because of my ugly method for getting the last 8 characters of the key fingerprint on line 17.

@philroche
Copy link

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment