From 04acc115aba19a803ec93265bcec7f6a85fbd8e5 Mon Sep 17 00:00:00 2001 From: Dmitry Nedospasov Date: Wed, 2 Jun 2010 15:32:27 +0200 Subject: [PATCH] Create .deb cache directory on systems lacking one This patch creates a cache directory on systems which do not have a /var/cache/apt/archives/ directory. Currently it creates a /var/cache/xen-tools/archives/ directory, however this can easily be set to a variable which is parsed from the configuration file. --- bin/xt-install-image | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/xt-install-image b/bin/xt-install-image index 843f453..3aab3ab 100755 --- a/bin/xt-install-image +++ b/bin/xt-install-image @@ -702,6 +702,7 @@ sub do_debootstrap # to use cdebootstrap. # my $cmd = $CONFIG{ 'debootstrap-cmd' }; + my $cachepath = '/var/cache/apt/archives/'; if ( !$cmd ) { if (-x '/usr/sbin/debootstrap') { @@ -723,8 +724,12 @@ sub do_debootstrap if ( $CONFIG{ 'cache' } eq "yes" ) { print "\nCopying files from host to image.\n"; + unless( -d $cachepath ) { + $cachepath = '/var/cache/xen-tools/archives'; + system "mkdir -p $cachepath"; + } runCommand("mkdir -p $CONFIG{'location'}/var/cache/apt/archives"); - copyDebFiles( "/var/cache/apt/archives", + copyDebFiles( "$cachepath", "$CONFIG{'location'}/var/cache/apt/archives" ); print("Done\n"); } @@ -767,7 +772,7 @@ sub do_debootstrap { print "\nCopying files from new installation to host.\n"; copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives", - "/var/cache/apt/archives" ); + "$cachepath" ); print("Done\n"); }