With feisty coming up, those who prefer to fresh install may want to know all the packages you have installed yourself outside of the base installation to allow you to pick up very quickly where you left off.
I have created this script, that works in ubuntu, xubuntu, and kubuntu that allows you to do that. It not only allows you to pair down the installed packages to the one's you added yourself, but also allows you the choice to omit libraries (seeing as those are generally dependencies) as well as the choice to omit the long list of kernel and module versions that have likely been installed and allows you to output the package list to a file.
The script works by amassing a long list of packages using timestamps as well as using the core meta packages and then removing those packages from the list of installed packages.
To use this script, make sure you are in the home directory and do the following: (make sure word wrap is turned off by the way)
Then copy and paste the script:Code:gedit user_installed_packages # or use kate for kde and mousepad for xfce
Save and exit, thenCode:#!/bin/bash #Ask for version to set DESKTOP while [ "$answer" != "ubuntu" -a "$answer" != "kubuntu" -a "$answer" != "xubuntu" ]; do echo "Was your install cd ubuntu, kubuntu, or xubuntu (type out exactly)?" read answer done #Get the installed packages INSTALLED_PACKAGES=$(dpkg --get-selections | grep -v deinstall | awk '{print $1}') #Get date of minimal and use that to find untouched packages INSTALL_DATE=$(ls -l /var/lib/dpkg/info | grep ubuntu-minimal.list | awk '{print $6}') BASE_PKG=$(ls -l /var/lib/dpkg/info | grep $INSTALL_DATE | awk '{print $8}' | sed 's/.list//g') #Get the dependencies of the meta packages used during install STANDARD=$(apt-cache show ubuntu-standard | grep -E ^Depends | sed 's/^Depends: //' | \ sed 's/, /\n/g' | sed 's/ | /\n/g') MINIMAL=$(apt-cache show ubuntu-minimal | grep -E ^Depends | sed 's/^Depends: //' | \ sed 's/, /\n/g' | sed 's/ | /\n/g') DESKTOP=$(apt-cache show $answer"-desktop" | grep -E ^Depends | sed 's/^Depends: //' | \ sed 's/, /\n/g' | sed 's/ | /\n/g') #Set up the grep strings (what a stupid way to do this) GREP_STRING=$(for x in $(echo $BASE_PKG) $(echo $STANDARD) $(echo $MINIMAL) \ $(echo $DESKTOP) ; do echo "$x|" ; done) CLEAN_GREP=$(echo $GREP_STRING | sed 's/\ //g' | sed "s/|$/\'/" | sed "s/^/\'/") # Find the new packages and setup nolib NEW_PACKAGES=$(echo "$INSTALLED_PACKAGES" | grep -Evw $CLEAN_GREP) NOLIB=$(echo "$NEW_PACKAGES" | grep -Ev ^lib) # Ask for libraries or no libraries, kernel or no kernel, and output file or not while [ "$choice" != "y" -a "$choice" != "n" ]; do echo "Include libraries in the results (y/n)?" read choice done if [ "$choice" = "y" ] ; then OUTPUT=$(echo "$NEW_PACKAGES") else OUTPUT=$(echo "$NOLIB") fi while [ "$response" != "y" -a "$response" != "n" ]; do echo "Include every version of the kernels and modules that you have installed (y/n)?" read response done if [ "$response" = "n" ] ; then OUTPUT=$(echo "$OUTPUT" | grep -Ev '^linux-headers-2|^linux-image-2|^linux-restricted-modules-2') fi while [ "$input" != "y" -a "$input" != "n" ]; do echo "Do you want to output the package list to a text file (y/n)?" read input done if [ "$input" = "n" ] ; then echo "$OUTPUT" else echo -e "What should the name of the file be?\n(Make sure you can write \ to it and make sure the path exists)" read file if [ "${file%%/*}" = "~" ] ; then file="/home/$USER$(echo $file | sed 's/~//')" fi echo "$OUTPUT" > $file fi exit
To run it thenCode:chmod +x user_installed_packages
Just follow the prompts and you should get what you want.Code:./user_installed_packages
Note: this is not 100% perfect, a few packages can slip by that were part of the base installation, but generally that is maybe 3-4.



Adv Reply






Bookmarks