1
0
mirror of synced 2026-01-26 19:51:56 +00:00

Added cachedir option for manually setting a cache directory

This way .debs actually get copied somewhere on non
Debian/Ubuntu systems, and also this way the cache directory
can be overriden, so that the host's apt-cache doesn't get
cluttered with guest .debs.
This commit is contained in:
Dmitry Nedospasov
2010-06-02 16:43:48 +02:00
parent 04acc115ab
commit f356b6065c
3 changed files with 24 additions and 5 deletions

View File

@@ -1269,6 +1269,7 @@ sub setupDefaultOptions
$CONFIG{ 'size' } = '2000Mb';
$CONFIG{ 'swap' } = '128M';
$CONFIG{ 'cache' } = 'yes';
$CONFIG{ 'cachedir' } = '/var/cache/apt/archives/';
$CONFIG{ 'image' } = 'sparse';
$CONFIG{ 'vcpus' } = '1';
@@ -1515,6 +1516,7 @@ sub parseCommandLineArguments
"fs=s", \$CONFIG{ 'fs' },
"boot", \$CONFIG{ 'boot' },
"cache=s", \$CONFIG{ 'cache' },
"cachedir=s", \$CONFIG{ 'cachedir' },
"config=s", \$CONFIG{ 'config' },
"ide", \$CONFIG{ 'ide' },
"scsi", \$CONFIG{ 'scsi' },
@@ -3251,6 +3253,10 @@ sub installSystem
#
$cmd .= " --cache=$CONFIG{'cache'}" if length( $CONFIG{ 'cache' } );
#
# Add on the current cachedir setting
#
$cmd .= " --cachedir=$CONFIG{'cachedir'}" if length( $CONFIG{ 'cachedir' } );
#
# Propagate --verbose

View File

@@ -391,6 +391,7 @@ sub parseCommandLineArguments
# Misc
"arch=s", \$CONFIG{ 'arch' },
"cache=s", \$CONFIG{ 'cache' },
"cachedir=s", \$CONFIG{ 'cachedir' },
"config=s", \$CONFIG{ 'config' },
"mirror=s", \$CONFIG{ 'mirror' },
@@ -702,7 +703,7 @@ sub do_debootstrap
# to use cdebootstrap.
#
my $cmd = $CONFIG{ 'debootstrap-cmd' };
my $cachepath = '/var/cache/apt/archives/';
my $cachedir = $CONFIG{ 'cachedir' };
if ( !$cmd )
{
if (-x '/usr/sbin/debootstrap') {
@@ -724,12 +725,16 @@ 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";
unless( -d $cachedir ) {
my $xtcache = '/var/cache/xen-tools/archives/';
print("$cachedir not found, defaulting to $xtcache\n");
unless ( -d $xtcache ) {
system "mkdir -p $xtcache";
}
$cachedir = $xtcache;
}
runCommand("mkdir -p $CONFIG{'location'}/var/cache/apt/archives");
copyDebFiles( "$cachepath",
copyDebFiles( "$cachedir",
"$CONFIG{'location'}/var/cache/apt/archives" );
print("Done\n");
}

View File

@@ -180,6 +180,14 @@ image = sparse # Specify sparse vs. full disk images.
# cache = no
#
#
# The default cachedir is, /var/cache/apt/archives/, however if it
# does not exist it will default to /var/cache/xen-tools/archives/
# Uncomment the line below to set it to something else.
#
# cachedir = /var/cache/xen-tools/archives/
#
#
# Uncomment the following line if you wish to interactively setup
# a new root password for images.