Adam Funk wrote:
> On Tuesday 18 May 2004 10:40, Bob Proulx wrote:
> 
> > I would backup /var/backups.  That directory includes a copy of the
> 
> I already back up /etc.  Where do the /var/backups/dpkg.status.* files
> come from?

The come from:

  /var/lib/dpkg/status

> > dpkg status file and a few other tidbits from the system.  From that
> > you can recreate your system.  I use my own script to parse the data.
> > I can post that if there is interest.
> 
> Yes, I'm interested.

It is a simple little ruby script from before I learned about
dpkg-ruby or any of the other parsing routines.  The copyright
statement is bigger than the entire code.  It is really a trivial
little script.  But in any case it should give you a hint of what is
possible.

Bob

#!/usr/bin/env ruby
#
# Process a Debian status file and print out installed package names.
#
# Examples:
#   dpkg.status.print-installed /var/lib/dpkg/status
#   dpkg.status.print-installed /var/backups/dpkg.status.0
#   zcat /var/backups/dpkg.status.1.gz | dpkg.status.print-installed
#   dpkg.status.print-installed <(zcat /var/backups/dpkg.status.1.gz)
#
# The one-liner which is way too long but very useful.
#
# diff <(dpkg.status.print-installed /var/lib/dpkg/status | sort) \
#   <(dpkg.status.print-installed <(zcat /var/backups/dpkg.status.1.gz) | sort)
#
################################################################
#
# Copyright (C) 2003 Bob Proulx <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
################################################################

# Lines look like this:
#   Package: telnet
#   Status: install ok installed
#   Package: wdiff
#   Status: purge ok not-installed

packagename = ""

ARGF.each do |line|  # Walk each line of all input files.

  line.chomp!  # Remove the newline from the end of the line.

  if line =~ /^Package: +/
    # Keep track of the current package name.
    packagename = line.sub(/^Package: +/,'')
  end

  if line =~ /^Status: /

    # Remove the header.  Split the line into the three fields.
    desired, status, state = line.sub(/^Status: +/,'').split

    if status == "ok" && state == "installed"
      # If the pkg was okay and installed then print the package name.
      puts packagename
    end

  end

end

Attachment: pgpp3ncSvlU03.pgp
Description: PGP signature

Reply via email to