Skip to content

Instantly share code, notes, and snippets.

@dazza-codes
Created September 29, 2015 05:42
Show Gist options
  • Save dazza-codes/8cc570ff402f19af7fa4 to your computer and use it in GitHub Desktop.
Save dazza-codes/8cc570ff402f19af7fa4 to your computer and use it in GitHub Desktop.
#!/bin/bash
manifest_url='http://releases.ubuntu.com/releases/trusty/ubuntu-14.04.3-desktop-amd64.manifest'
manifest_file=$(echo $manifest_url | sed -e 's#.*/##g')
if [ ! -e $manifest_file ]; then
wget -q $manifest_url
fi
cat $manifest_file | cut -f1 | sort -u > default_installed.txt
aptitude search '~i !~M' -F '%p' --disable-columns | sort -u > currently_installed.txt
comm -23 currently_installed.txt default_installed.txt > manually_installed.txt
mkdir -p package_files
while read p; do
apt-cache show $p > info.txt
arch=$(grep -m1 'Architecture: ' info.txt | sed -e 's/Architecture: //')
section=$(grep -m1 'Section: ' info.txt | sed -e 's/Section: //' -e 's/\//_/g')
file="${arch}_${section}_packages.txt"
echo $p >> "package_files/$file"
done <manually_installed.txt
rm info.txt
@dazza-codes
Copy link
Author

TODO: Modify the package files so each line is prefixed with apt-get install -y and the file is a bash script. Then all the package files could be included in a vagrant provision loop.

@pnorman
Copy link

pnorman commented Nov 10, 2015

It might be worth using lsb_release to generate the url, which seems to be

"http://releases.ubuntu.com/releases/$(lsb_release -cs)/ubuntu-$(lsb_release -ds | cut -d ' ' -f2)-desktop-amd64.manifest

Though that still assumes desktop and amd64.

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