diff options
author | tron <tron@pkgsrc.org> | 2004-05-27 10:28:00 +0000 |
---|---|---|
committer | tron <tron@pkgsrc.org> | 2004-05-27 10:28:00 +0000 |
commit | d682e72d67a88ae8f408a69998b118160cfba7a1 (patch) | |
tree | 4356a17b8ba7a036e8f73f980a448a47f615b721 | |
parent | 8ac5b626c285d66139a5379bcbf42e9c491ecc30 (diff) | |
download | pkgsrc-d682e72d67a88ae8f408a69998b118160cfba7a1.tar.gz |
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.
-rw-r--r-- | pkgtools/rpm2pkg/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/rpm2pkg/files/rpm2pkg.c | 75 |
2 files changed, 54 insertions, 25 deletions
diff --git a/pkgtools/rpm2pkg/Makefile b/pkgtools/rpm2pkg/Makefile index ce0ad1711fc..bf75864cef7 100644 --- a/pkgtools/rpm2pkg/Makefile +++ b/pkgtools/rpm2pkg/Makefile @@ -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 --git a/pkgtools/rpm2pkg/files/rpm2pkg.c b/pkgtools/rpm2pkg/files/rpm2pkg.c index b7ee246de18..4230d55e723 100644 --- a/pkgtools/rpm2pkg/files/rpm2pkg.c +++ b/pkgtools/rpm2pkg/files/rpm2pkg.c @@ -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 @@ typedef struct FileHandleStruct { } 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 @@ PListEntryFile(PListEntry *Node, FILE *Out) (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 @@ MakeTargetDir(char *Name, PListEntry **Dirs, int MarkNonEmpty) 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) { |