Announcement

Collapse
No announcement yet.

Listing Installed Packages

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Listing Installed Packages

    https://wiki.debian.org/ListInstalledPackages

    This page is about the ways to list the installed packages in a Debian system and how to create a file with this list. This file can be uploaded to the web (i.e. from other computer with Internet connection) to download new packages.

    Windows no longer obstructs my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    #2
    I was reading about this recently, because I'm currently considering doing a fresh installation of everything on my server when 16.04 comes out.

    The problem with some of the methods on that page is that they mess up the lists of what is installed by default and what really has been manually installed. After doing a load of research, I wrote a couple of scripts using snippets I found online. I haven't used it in anger yet but tested it with -s flags etc, and it looks like it will work quite nicely!

    generate-installed-packages-list.sh:

    Code:
    #!/bin/bash
    
    # script to generate a list of MANUALLY installed packages
    # http://unix.stackexchange.com/questions/3595/list-explicitly-installed-packages
    #
    # works by comparing packages marked as manually installed (from apt-mark) to the
    # list of packages that were installed by default (these also appear as "manually
    # installed" in apt-mark). The difference between the two lists is what was actually
    # manually installed
    
    # "comm" command compares the two sorted files line by line. "-2" flag suppresses lines
    # unique to file 2, "-3" flag suppresses lines that appear in both files
    
    (comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)) > ~/manually-installed-packages-list.txt
    install-packages-from-list.sh:

    Code:
    sam@samhobbs:~/bin$ cat install-packages-from-list.sh 
    #!/bin/bash
    
    # script to install packages from a list (e.g. after fresh installation)
    # list should be generated using generate-installed-packages-list.sh
    
    # expected location for list of packages to be installed
    list=~/manually-installed-packages-list.txt
    
    # root privileges are required for package installation
    if [ $(id -u) != "0" ]; then
            echo "Package installation requires root" >&2
            exit 1
    fi
    
    # check package list exists
    if [ ! -e $list ]; then
            echo "Package list $list was not found, aborting" >&2
            exit 1
    fi
    
    echo "Refreshing sources"
    sudo apt-get update -qq
    
    cat $list | while read package; do
            echo "installing $package"
            # to simulate
            apt-get install -s -qq $package
            # to install for real
            # apt-get install $package
    done
    
    exit 0
    samhobbs.co.uk

    Comment


      #3
      Cool. I created an alias for your generate-installed-packages-list.sh instead:

      alias mipl="(comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)) > ~/manually-installed-packages-list.txt"

      (I like aliases)
      Windows no longer obstructs my view.
      Using Kubuntu Linux since March 23, 2007.
      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

      Comment


        #4
        Neat! I should use aliases more often.
        samhobbs.co.uk

        Comment


          #5
          Feathers this is a marvy thing!

          I have always wanted this because I do a "virgin" install and then have to add in all those pesky things that I installed before because I keep the data off machine on a usb drive.

          I would ADD for NEW people to Linux that this generates a "text file" which is in one's home folder as in "woodsmoke"........go to the bottom and the text file will be there.

          woodsmoke

          Comment


            #6
            BTW..........I used FOR THE ABSOLUTE FIRST TIME ON ANY LINUX FORUM........the "email" function to e-mail this thread to myself!

            woodgratefulsmoke

            Comment


              #7
              I am wondering if I am missing something, as for years I have used the approach where I have a text file that lists the packages to install. This file is updated for each distribution when I make distribution specific changes. Also, it is one reason why I love the Muon Package Manager as I can enter many packages to install before starting the installation process.

              One query that I have is related to the fact that, if I install say, Kdenlive, there are a large number of dependencies that are also installed. After reading this post, I am wondering if the proposed approach also lists all the dependencies that are installed alongside all the primary applications. If this is so, then how is it dealt with?

              Comment


                #8
                It just lists the manually installed packages, which is preferable IMO because if a dependency changes in a new version the install script will just pull the new one in, instead of installing the old dependency manually and the new one automatically as well.
                samhobbs.co.uk

                Comment

                Working...
                X