diff options
author | J Pipkin <j@dawnrazor.net> | 2013-01-03 00:39:51 -0600 |
---|---|---|
committer | J Pipkin <j@dawnrazor.net> | 2013-01-03 00:39:51 -0600 |
commit | 45b9a3ce3dc15404eca8e140bff45eb62e4d4637 (patch) | |
tree | 2566a7a6ddbca52061fb0eaf42b1602381912a37 | |
parent | 5c142df2317aab55751f1d3c659ee08dc613ddf9 (diff) | |
download | sbotools2-45b9a3ce3dc15404eca8e140bff45eb62e4d4637.tar.xz |
rewrite slackbuilds for compat32 installs to decompress the correct source
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 811243b..d7b8e32 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -447,11 +447,44 @@ sub check_multilib() { return; } +# given a list of downloads, return just the filenames +sub get_dl_fns ($) { + my $fns = shift; + my $return; + push @$return, ($_ =~ qr|/([^/]+)$|)[0] for @$fns; + return $return; +} + +# given a line containing 'tar ', try to return a valid filename regex +sub get_tar_regex ($) { + my $line = shift; + # get rid of initial 'tar x'whatever stuff + $line =~ s/^.*tar\s+[^\s]+\s+//; + # need to know preceeding character - should be safe to assume it's either + # a slash or a space + my $initial = $line =~ qr|/| ? '/' : ' '; + # get rid of initial path info + $line =~ s|^\$[^/]+/||; + # get rid of anything excess at the end + $line =~ s/\s*$//; + # convert any instances of command substitution to [^-]+ + $line =~ s/\$\([^)]+\)/[^-]+/g; + # convert any bash variables to [^-]+ + $line =~ s/\$({|)[A-Za-z0-9_]+(}|)/[^-]+/g; + # fix .?z* at the end + $line =~ s/\.\?z\*/\.[a-z]z.*/; + # return what's left as a regex + my $regex = qr/$initial$line/; + return $regex, $initial; +} + # make a backup of the existent SlackBuild, and rewrite the original as needed sub rewrite_slackbuild { my %args = ( + SBO => '', SLACKBUILD => '', CHANGES => {}, + C32 => 0, @_ ); $args{SLACKBUILD} or script_error 'rewrite_slackbuild requires SLACKBUILD.'; @@ -461,8 +494,28 @@ sub rewrite_slackbuild { die "Unable to backup $slackbuild to $slackbuild.orig\n"; my $libdir_regex = qr/^\s*LIBDIRSUFFIX="64"\s*$/; my $arch_regex = qr/\$VERSION-\$ARCH-\$BUILD/; + my $tar_regex = qr/tar\s+/; # tie the slackbuild, because this is the easiest way to handle this. tie my @sb_file, 'Tie::File', $slackbuild; + # if we're dealing with a compat32, we need to change the tar line(s) so + # that the 32-bit source is untarred + if ($args{C32}) { + my $location = get_sbo_location($args{SBO}); + my %downloads = get_sbo_downloads( + LOCATION => $location, + 32 => 1, + ); + my $fns = get_dl_fns [keys %downloads]; + for my $line (@sb_file) { + if ($line =~ $tar_regex) { + my ($regex, $initial) = get_tar_regex $line; + for my $fn (@$fns) { + $fn = "$initial$fn"; + $line =~ s/$regex/$fn/ if $fn =~ $regex; + } + } + } + } for my $line (@sb_file) { # then check for and apply any other %$changes if (exists $$changes{libdirsuffix}) { @@ -598,8 +651,10 @@ sub perform_sbo { my $fn = get_tmp_extfn $tempfh; $cmd .= " | tee -a $fn"; rewrite_slackbuild( + SBO => $sbo, SLACKBUILD => "$location/$sbo.SlackBuild", CHANGES => \%changes, + C32 => $args{C32}, ); chdir $location, system $cmd; seek $exit_temp, 0, 0; |