I wrote a simple script to add a package + recursive dependencies (dpkg 
only).  You may find it useful.

-- 
Make April 15 just another day, visit http://fairtax.org
#!/usr/bin/perl
#
# pkg-overlay
# Copyright (C) 2006 Joshua Nathaniel Pritikin
#
# 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

use strict;
use warnings;

our $opt_n;
if ($ARGV[0] eq '-n') {
  shift @ARGV;
  $opt_n = 1;
}

@ARGV == 2 or die "usage: $0 pkg dir\n";

our $target;
if (!$opt_n) {
  $target = $ARGV[1];
  die "'$target' must start with a slash" if $target !~ m,^/,;
  chdir '/' or die "Can't chdir to /";
}

sub dpkg_cp {
  my ($pkg) = @_;
  print "$pkg ..";
  open my $files, "dpkg-query -L $pkg|";
  while (defined(my $f = <$files>)) {
    chomp $f;
    $f =~ s,^/,,;
    next if -d $f;
    next if $f =~ /diverted by/; # hopefully not important
    next if -e "$target/$f";

    our $cp;
    if (!defined $cp) {
      open $cp, "| tar --files-from=- -cpf - | (cd $target; tar -xpf -)"
        or die "Can't fork tar";
    }
    print $cp "$f\n";
  }
  print "ok\n";
}

sub choose_alt {
  my ($alt) = @_;

  my @alt = split /\|/, $alt;
  my $ok;
  for my $a (@alt) {
    $a =~ s/\(.*?\)//;
    $a =~ s/\s//g;

    my $fmt = q{'${Status}'};
    my $st = `dpkg-query --showformat $fmt --show $a`;
    next if $st =~ /not-installed/;

    overlay($a);
    $ok = 1;
    last;
  }
  die "Can't satisfy $alt" if !$ok;
}

our %seen = ('libc6' => 1, debconf => 1, perl => 1, 'perl-base' => 1);

sub overlay {
  my ($pkg) = @_;

  return if $seen{$pkg};
  if ($opt_n) {
    print "$pkg\n";
  } else {
    dpkg_cp($pkg);
  }
  $seen{$pkg} = 1;
  
  my $fmt = q{'${Depends}'};
  my $dep = `dpkg-query --showformat $fmt --show $pkg`;
  my @dep = split /,/, $dep;
  for my $d (@dep) {
    if ($d =~ /\|/) {
      choose_alt($d);
    } else {
      $d =~ s/\(.*?\)//;
      $d =~ s/\s//g;

      my $fmt = q{'${Status}'};
      my $st = `dpkg-query --showformat $fmt --show $d`;
      if ($st =~ /not-installed/) {
        print "Can't find $d, is it a virtual package?\n";
        next;
      }

      overlay($d);
    }
  }
}

overlay($ARGV[0]);

Attachment: signature.asc
Description: Digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_____________________________________________________________________
Ltsp-discuss mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help,   try #ltsp channel on irc.freenode.net

Reply via email to