pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/rpm2pkg Update "rpm2pkg" package to version 2.1:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0eda23fe6ddc
branches:  trunk
changeset: 475821:0eda23fe6ddc
user:      tron <tron%pkgsrc.org@localhost>
date:      Thu May 27 10:28:00 2004 +0000

description:
Update "rpm2pkg" package to version 2.1:
- Improve I/O buffer mangement.
- Don't put "@exec" and "@unexec" in the package list for symbolic links
  which point to normal files. This allows the automatic manual
  decompression to handle symbolic links to manual pages correctly.

The update fixes PR pkg/25723 by Kouichirou Hiratsuka.

diffstat:

 pkgtools/rpm2pkg/Makefile        |   4 +-
 pkgtools/rpm2pkg/files/rpm2pkg.c |  75 +++++++++++++++++++++++++++------------
 2 files changed, 54 insertions(+), 25 deletions(-)

diffs (121 lines):

diff -r bfa7217e8c59 -r 0eda23fe6ddc pkgtools/rpm2pkg/Makefile
--- a/pkgtools/rpm2pkg/Makefile Thu May 27 09:29:58 2004 +0000
+++ b/pkgtools/rpm2pkg/Makefile Thu May 27 10:28:00 2004 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.23 2004/04/25 11:50:39 wiz Exp $
+# $NetBSD: Makefile,v 1.24 2004/05/27 10:28:00 tron Exp $
 
-DISTNAME=      rpm2pkg-2.0
+DISTNAME=      rpm2pkg-2.1
 CATEGORIES=    pkgtools
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r bfa7217e8c59 -r 0eda23fe6ddc pkgtools/rpm2pkg/files/rpm2pkg.c
--- a/pkgtools/rpm2pkg/files/rpm2pkg.c  Thu May 27 09:29:58 2004 +0000
+++ b/pkgtools/rpm2pkg/files/rpm2pkg.c  Thu May 27 10:28:00 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpm2pkg.c,v 1.4 2004/02/18 21:29:37 tron Exp $ */
+/*     $NetBSD: rpm2pkg.c,v 1.5 2004/05/27 10:28:00 tron Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -128,12 +128,18 @@
 } FileHandle;
 
 static int
-InitBuffer(void **Buffer,int *BufferSize)
+InitBuffer(void **Buffer, int *BufferSizePtr)
 {
        if (*Buffer == NULL) {
-               *BufferSize = sysconf(_SC_PAGESIZE) * 256;
-               if ((*Buffer = malloc(*BufferSize)) == NULL)
-                       return FALSE;
+               int     BufferSize;
+
+               BufferSize = sysconf(_SC_PAGESIZE) * 256;
+               while ((*Buffer = malloc(BufferSize)) == NULL) {
+                       BufferSize >>= 1;
+                       if (BufferSize == 0)
+                               return FALSE;
+               }
+               *BufferSizePtr = BufferSize;
        }
        return TRUE;
 }
@@ -290,10 +296,51 @@
        (void)fputc('\n', Out);
 }
 
+static char *
+StrCat(char *Prefix, char *Suffix)
+{
+       int     Length;
+       char    *Str;
+
+       Length = strlen(Prefix);
+       if ((Str = malloc(Length + strlen(Suffix) + 1)) == NULL) {
+            perror("malloc");
+            exit(EXIT_FAILURE);
+       }
+
+       (void)memcpy(Str, Prefix, Length);
+       (void)strcpy(&Str[Length], Suffix);
+
+       return Str;
+}
+
 static void
 PListEntryLink(PListEntry *Node, FILE *Out)
 
 {
+       char            *Ptr;
+       struct stat     Stat;
+       int             Result;
+
+       if ((Ptr = strrchr(Node->pe_Name, '/')) != NULL) {
+               char    Old, *Targetname;
+
+               Old = Ptr[1];
+               Ptr[1] = '\0';
+               Targetname = StrCat(Node->pe_Name, Node->pe_Link);
+               Ptr[1] = Old;
+
+               Result = stat(Targetname, &Stat);
+               free(Targetname);
+       } else {
+               Result = stat(Node->pe_Link, &Stat);
+       }
+
+       if ((Result == 0) && ((Stat.st_mode & S_IFMT) == S_IFREG)) {
+               PListEntryFile(Node, Out);
+               return;
+       }
+
        (void)fprintf(Out, "@exec ln -fs %s %%D/%s\n@unexec rm -f %%D/%s\n",
            Node->pe_Link, Node->pe_Name, Node->pe_Name);
 }
@@ -472,24 +519,6 @@
        return Result;
 }
 
-static char
-*StrCat(char *Prefix, char *Suffix)
-{
-       int     Length;
-       char    *Str;
-
-       Length = strlen(Prefix);
-       if ((Str = malloc(Length + strlen(Suffix) + 1)) == NULL) {
-            perror("malloc");
-            exit(EXIT_FAILURE);
-       }
-
-       (void)memcpy(Str, Prefix, Length);
-       (void)strcpy(&Str[Length], Suffix);
-
-       return Str;
-}
-
 static int
 MakeDir(char *Name, mode_t Mode, int *OldDir)
 {



Home | Main Index | Thread Index | Old Index