NetBSD Problem Report #54485

From hf@spg.tu-darmstadt.de  Wed Aug 21 12:37:58 2019
Return-Path: <hf@spg.tu-darmstadt.de>
Received: from mail.netbsd.org (unknown [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 045827A152
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 21 Aug 2019 12:37:57 +0000 (UTC)
Message-Id: <201908211237.x7LCbaGE029808@Hochstuhl.nt.e-technik.tu-darmstadt.de>
Date: Wed, 21 Aug 2019 14:37:36 +0200 (CEST)
From: hf@spg.tu-darmstadt.de
Reply-To: hf@spg.tu-darmstadt.de
To: gnats-bugs@NetBSD.org
Subject: mkpatches (pkgtools/pkgdiff) shortcomings
X-Send-Pr-Version: 3.95

>Number:         54485
>Category:       pkg
>Synopsis:       mkpatches (pkgtools/pkgdiff) shortcomings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    hauke
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 21 12:40:00 +0000 2019
>Closed-Date:    Wed Aug 21 13:23:50 +0000 2019
>Last-Modified:  Wed Aug 21 13:23:50 +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>) {

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->wiz
Responsible-Changed-By: hauke@NetBSD.org
Responsible-Changed-When: Wed, 21 Aug 2019 12:46:29 +0000
Responsible-Changed-Why:
Over to maintainer.


Responsible-Changed-From-To: wiz->hauke
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Wed, 21 Aug 2019 12:54:01 +0000
Responsible-Changed-Why:
please commit and bump version. Thanks!


From: "Hauke Fath" <hauke@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54485 CVS commit: pkgsrc/pkgtools/pkgdiff
Date: Wed, 21 Aug 2019 13:00:06 +0000

 Module Name:	pkgsrc
 Committed By:	hauke
 Date:		Wed Aug 21 13:00:06 UTC 2019

 Modified Files:
 	pkgsrc/pkgtools/pkgdiff: Makefile
 	pkgsrc/pkgtools/pkgdiff/files: mkpatches.pl

 Log Message:
 Properly preserve patch comments when working with a readonly pkgsrc tree.
 Do not prefix an absolute path argument with $cwd.
 Declare a handful of variables, and 'use warnings'.

 Fixes PR pkg/54485


 To generate a diff of this commit:
 cvs rdiff -u -r1.94 -r1.95 pkgsrc/pkgtools/pkgdiff/Makefile
 cvs rdiff -u -r1.21 -r1.22 pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: hauke@NetBSD.org
State-Changed-When: Wed, 21 Aug 2019 13:23:50 +0000
State-Changed-Why:
Fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.