pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/54485: mkpatches (pkgtools/pkgdiff) shortcomings



>Number:         54485
>Category:       pkg
>Synopsis:       mkpatches (pkgtools/pkgdiff) shortcomings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 21 12:40:00 +0000 2019
>Originator:     Hauke Fath
>Release:        NetBSD 8.0_STABLE
>Organization:
Technische Universitaet Darmstadt
>Environment:
	
	
System: NetBSD Hochstuhl 8.0_STABLE NetBSD 8.0_STABLE (MONOLITHIC-$Revision$) #1: Wed Apr 10 11:45:59 CEST 2019 hf@Hochstuhl:/var/obj/netbsd-builds/8/amd64/sys/arch/amd64/compile/MONOLITHIC amd64
Architecture: x86_64
Machine: amd64
>Description:

	When working with a read-only pkgsrc tree, mkpatches(8) offers
	to create the patches in a writable directory. While doing so,
	it does not preserve comments in existing patches, which is a
	major feature of the tool. The responsible create_patchdir()
	is broken in two important ways.
	
	In addition, the tool should not prefix an absolute path for
	the patches directory with $pwd, even if the directory does
	not yet exist - in fact, create_patchdir() will only populate
	it with the existing, commented patch files if it is allowed
	to create it.

	While here, I enabled warnings, and declared a handful of variables.

	
>How-To-Repeat:

	Create package patches with a read-only pkgsrc tree. Wonder
	where pre-existing patch comments went. Dust off Perl skills.

	
>Fix:
	

	Please apply

Index: mkpatches.pl
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl,v
retrieving revision 1.21
diff -u -u -r1.21 mkpatches.pl
--- mkpatches.pl	10 Feb 2016 16:00:10 -0000	1.21
+++ mkpatches.pl	21 Aug 2019 12:35:16 -0000
@@ -39,24 +39,29 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
+use warnings;
+
 use Getopt::Std;
 use Cwd;
 use File::Spec;
 
+my $prog;
+my $patchfile;
 my $patchdir;
+my $origpatchdir;
 my $old_patchdir;
 my $wrkdir;
 my $wrksrc;
 my %old_filename;
 my %old_header;
 
-# create patchdir, or empty it if already existing
+# create patchdir, and populate with existing patches
 
 sub create_patchdir {
     if (! -d $patchdir) {
 	mkdir($patchdir, 0755);
-	if (-d $origpatchdir && "$origpatchdir" != "$patchdir") {
-	    system("cp", "$origpatchdir/p*", "$patchdir");
+	if (-d $origpatchdir && "$origpatchdir" ne "$patchdir") {
+	    system("cp $origpatchdir/p* $patchdir");
 	}
     }
 }
@@ -114,7 +119,8 @@
 if ($opt_D) {
     $patchdir = "$wrkdir/.newpatches";
 } elsif ($opt_d) {
-    if (-d "/$opt_d") {
+    if ($opt_d =~ /^\//) {
+        # Do not prefix an absolute path
 	$patchdir = $opt_d;
     } else {
 	my $pwd = cwd();
@@ -168,6 +174,7 @@
 # create patches
 
 foreach (sort <HANDLE>) {
+    my $diff;
     my ($path, $complete);
     my ($new, $old);
     chomp();
@@ -231,6 +238,8 @@
 
 sub move_away_old_patches
 {
+    my $filename;
+
     open(HANDLE, "ls $patchdir/patch-* 2>/dev/null |");
 
     while ($filename = <HANDLE>) {

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index