[xen-tools-discuss] patch: new rinse option to use rpm2tar instead of rpm2cpio
Tapp Darden
tapp.darden at yahoo.com
Fri Mar 9 22:59:27 CET 2012
Hi,
While trying to use Johan's new scripts to make a centos 6 VM (thanks Johan's!) i ran into trouble while extracting the rpm's. I'm not sure if it was my copy of rpm2cpio or cpio or the .rpm's i downloaded from my mirror or soemthing else. But it would take the the rpm's and output garbadge. I would get files and directories starting with '?' charactor.
anyway. I added an option to rinse to use rpm2tar instead. Same goal is reached, but we go through tar instead. I'm not sure if this is the correct spot to post a patch to rinse. (is it?) but i figured xen-tools would need to make a change to take advantage of this new option... and/or maybe somebody has a better idea than this. basically. if --tar is turned on it will use rpm2tar instead.
rinse
@@ -45,6 +45,7 @@ rinse - RPM Installation Entity.
--list-distributions Show installable distributions.
--print-uris Only show the RPMs which should be downloaded.
default files in /usr/lib/rinse/$distro
+ --tar Use rpm2tar instead of rpm2cpio for rpm expansion.
--verbose Enable verbose output.
=cut
@@ -210,7 +211,7 @@ $CONFIG{ 'cache' } = 1;
$CONFIG{ 'cache-dir' } = "/var/cache/rinse/";
$CONFIG{ 'config' } = "/etc/rinse/rinse.conf";
$CONFIG{ 'pkgs-dir' } = "/etc/rinse";
-
+$CONFIG{ 'tar' } = 0;
#
# Find the size of our terminal
@@ -418,6 +419,7 @@ sub parseCommandLineArguments
"before-post-install=s", \$CONFIG{ 'before-post-install' },
"after-post-install=s", \$CONFIG{ 'after-post-install' },
"add-pkg-list=s", \$CONFIG{ 'add-pkg-list' },
+ "tar", \$CONFIG{ 'tar' },
# Help options
"help", \$HELP,
@@ -1093,9 +1095,12 @@ sub unpackPackages
my @rpms = glob( $dir . "/*.rpm" );
@rpms = sort {lc($a) cmp lc($b)} @rpms;
+ # Command to do the extraction
+ my $cmd = "";
# Command to execute after extraction
my $postcmd = "";
+
#
# For each RPM file: convert to .tgz
#
@@ -1125,9 +1130,15 @@ sub unpackPackages
#
# Run the unpacking command.
#
- my $cmd =
- "rpm2cpio $file | (cd $CONFIG{'directory'} ; cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time) 2>/dev/null >/dev/null";
- if ( $file =~ /(fedora|centos|redhat|mandriva)-release-/ )
+ if ($CONFIG{'tar'})
+ {
+ $cmd =
+ "/usr/bin/rpm2tar -O $file | tar -xvpf - -C $CONFIG{'directory'} 2>/dev/null >/dev/null";
+ } else {
+ $cmd =
+ "rpm2cpio $file | (cd $CONFIG{'directory'} ; cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time) 2>/dev/null >/dev/null";
+ }
+ if ( $file =~ /(fedora|centos|redhat|mandriva)-release-/ )
{
my $rpmname = basename($file);
$postcmd =
More information about the xen-tools-discuss
mailing list