[SLL] how to maintain same pkgs/versions on two machines with APT?

Lee Colleton lee at colleton.net
Thu Feb 28 02:38:37 PST 2008


On Thu, Feb 28, 2008 at 1:33 AM, Will Mengarini <seldon at eskimo.com> wrote:

> * Phil Mocek <pmocek-sll at mocek.org> [2008-02-27 09:41]:
> > I know how to get a list of packages with dpkg (use --get-selections
> > switch) but I haven't found a way to also show versions.
>
> `dpkg -l >$file` should do it, but note that `dpkg -l` is different;
> that is, the presence of output redirection alters the output format,
> because if output is to a terminal, dpkg squeezes its output
> according to the terminal's line width.


Note the five leading lines of column headers and formatting provided by dpkg
-l, which could throw off a scripted sync.

This may work better for your purposes:
for i in `dpkg --get-selections | cut -f 1` ; do dpkg -l $i | tail -n 1 |
awk '{ print $2 " " $3 }' ; done > $FILE

You can also use the -G option of dpkg to prevent downgrades.

--Lee


More information about the linux-list mailing list