From 8b777877968f5a21fe4974cd3c99bf41137b7806 Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Mon, 31 Dec 2012 08:13:04 -0600 Subject: remove no-longer-used get_readme_path() --- sboupgrade | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sboupgrade b/sboupgrade index 43ad2c5..135e9f4 100755 --- a/sboupgrade +++ b/sboupgrade @@ -114,12 +114,6 @@ for my $sbo (@$build_queue) { defined $locations{$sbo}; } -sub get_readme_path($) { - exists $_[0] or script_error 'get_readme_path requires an argument.'; - my $sbo = shift; - return $locations{$sbo} .'/README'; -} - # look for any (user|group)add commands in the README sub get_user_group($) { exists $_[0] or script_error 'get_user_group requires an argument'; -- cgit v1.2.3 From 5c142df2317aab55751f1d3c659ee08dc613ddf9 Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Mon, 31 Dec 2012 08:18:40 -0600 Subject: die if -p is specified without -N --- sboupgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/sboupgrade b/sboupgrade index 135e9f4..3f9dcfe 100755 --- a/sboupgrade +++ b/sboupgrade @@ -88,6 +88,7 @@ if ($jobs) { if ($compat32) { die "compat32 only works on x86_64.\n" unless get_arch eq 'x86_64'; + die "-p|--compat32 requires -N|--installnew\n" unless $install_new; } # if we can't find SLACKBUILDS.TXT in $config{HOME}, prompt to fetch the tree -- cgit v1.2.3 From 45b9a3ce3dc15404eca8e140bff45eb62e4d4637 Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Thu, 3 Jan 2013 00:39:51 -0600 Subject: rewrite slackbuilds for compat32 installs to decompress the correct source --- SBO-Lib/lib/SBO/Lib.pm | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) 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; -- cgit v1.2.3 From a8866498912614b62205866cc8f237a0c704a8d9 Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Thu, 3 Jan 2013 00:42:25 -0600 Subject: tests for changes to rewrite slackbuilds for compat32 installs --- t/test.t | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/t/test.t b/t/test.t index d69ef34..0f2b371 100755 --- a/t/test.t +++ b/t/test.t @@ -204,7 +204,7 @@ is(get_distfile '5434f948fdea6406851c77bebbd0ed19'), 1, 'get_distfile is good'); unlink $distfile; -# rewrite_slackbuilds/revert_slackbuild tests +# rewrite_slackbuild/revert_slackbuild tests my $rewrite_dir = tempdir(CLEANUP => 1); copy("$sbo_home/system/ifuse/ifuse.SlackBuild", $rewrite_dir); my $slackbuild = "$rewrite_dir/ifuse.SlackBuild"; @@ -218,18 +218,22 @@ is(revert_slackbuild $slackbuild, 1, 'revert_slackbuild is good'); $changes{libdirsuffix} = ''; $changes{make} = '-j 5'; $changes{arch_out} = 'i486'; -is(rewrite_slackbuild (SLACKBUILD => $slackbuild, TEMPFN => $tempfn, - CHANGES => \%changes), 1, 'rewrite_slackbuild with all %changes good'); +is(rewrite_slackbuild (SLACKBUILD => $slackbuild, CHANGES => \%changes, + C32 => 1, SBO => 'ifuse'), 1, 'rewrite_slackbuild test w/ all %changes'); ok(-f "$slackbuild.orig", 'rewrite_slackbuild backing up original is good.'); -my $expected_out = "55c55 -< LIBDIRSUFFIX=\"64\" +my $expected_out = '55c55 +< LIBDIRSUFFIX="64" +--- +> LIBDIRSUFFIX="" +67c67 +< tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2 --- -> LIBDIRSUFFIX=\"\" +> tar xvf $CWD/ifuse-1.1.1.tar.bz2 103c103 -< /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz} +< /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} --- -> /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-i486-\$BUILD\$TAG.\${PKGTYPE:-tgz} -"; +> /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-i486-$BUILD$TAG.${PKGTYPE:-tgz} +'; is(diff("$slackbuild.orig", $slackbuild, {STYLE => 'OldStyle'}), $expected_out, 'all changed lines rewritten correctly'); is(revert_slackbuild $slackbuild, 1, 'revert_slackbuild is good again'); @@ -389,5 +393,40 @@ confirm_remove('zdoom'); $count = @SBO::Lib::confirmed; is($count, 4, 'confirm_remove good for duplicate sbo'); +# test get_dl_fns +my $downloads = [ + 'http://developer.download.nvidia.com/cg/Cg_3.1/Cg-3.1_April2012_x86.tgz' +]; +my $fns = get_dl_fns $downloads; +is($$fns[0], 'Cg-3.1_April2012_x86.tgz', 'get_dl_fns test, one input'); +$downloads = [ + 'http://download.virtualbox.org/virtualbox/4.2.0/VirtualBox-4.2.0.tar.bz2', + 'http://download.virtualbox.org/virtualbox/4.2.0/VBoxGuestAdditions_4.2.0.iso', + 'http://download.virtualbox.org/virtualbox/4.2.0/UserManual.pdf', + 'http://download.virtualbox.org/virtualbox/4.2.0/SDKRef.pdf', +]; +$fns = get_dl_fns $downloads; +is($$fns[0], 'VirtualBox-4.2.0.tar.bz2', 'get_dl_fns test, multiple inputs 01'); +is($$fns[2], 'UserManual.pdf', 'get_dl_fns test, multiple inputs 02'); + +# test get_tar_regex - multiple tests for various types of input +my $line = 'tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*'; +my ($regex, $initial) = get_tar_regex $line; +is($regex, '(?^u:/[^-]+-[^-]+.tar.[a-z]z.*)', 'get_tar_regex test 01.1'); +is($initial, '/', 'get_tar_regex test 01.2'); +$line = 'tar xvf $CWD/Oracle_VM_VirtualBox_Extension_Pack-$VERSION.vbox-extpack'; +($regex, $initial) = get_tar_regex $line; +is($regex, '(?^u:/Oracle_VM_VirtualBox_Extension_Pack-[^-]+.vbox-extpack)', + 'get_tar_regex test 02.1'); +is($initial, '/', 'get_tar_regex test 02.2'); +$line = 'tar xvf $CWD/${PRGNAM}-source-$(echo $VERSION).tar.gz'; +($regex, $initial) = get_tar_regex $line; +is($regex, '(?^u:/[^-]+-source-[^-]+.tar.gz)', 'get_tar_regex test 03.1'); +is($initial, '/', 'get_tar_regex test 03.2'); +$line = '( tar xvf xapian-bindings-$VERSION.tar.gz'; +($regex, $initial) = get_tar_regex $line; +is($regex, '(?^u: xapian-bindings-[^-]+.tar.gz)', 'get_tar_regex test 04.1'); +is($initial, ' ', 'get_tar_regex test 04.2'); + # end of tests. done_testing(); -- cgit v1.2.3 From e2a88cd9c57c16552b7c72f4eb58b9a8d93954ac Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Thu, 3 Jan 2013 01:20:41 -0600 Subject: support other archive formats besides just tar --- SBO-Lib/lib/SBO/Lib.pm | 17 +++++++++-------- t/test.t | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index d7b8e32..37c3b73 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -455,22 +455,23 @@ sub get_dl_fns ($) { return $return; } -# given a line containing 'tar ', try to return a valid filename regex -sub get_tar_regex ($) { +# given a line that looks like it's decompressing something, try to return a +# valid filename regex +sub get_dc_regex { my $line = shift; # get rid of initial 'tar x'whatever stuff - $line =~ s/^.*tar\s+[^\s]+\s+//; + $line =~ s/^.*(? Date: Thu, 3 Jan 2013 03:08:46 -0600 Subject: elide space between get_dc_regex and ($) --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 37c3b73..bc396d4 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -448,7 +448,7 @@ sub check_multilib() { } # given a list of downloads, return just the filenames -sub get_dl_fns ($) { +sub get_dl_fns($) { my $fns = shift; my $return; push @$return, ($_ =~ qr|/([^/]+)$|)[0] for @$fns; -- cgit v1.2.3