pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Updated pkgclean to 20051116.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/490c551993ba
branches:  trunk
changeset: 503295:490c551993ba
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Nov 17 22:30:09 2005 +0000

description:
Updated pkgclean to 20051116.

- Replaced the C implementation by a shell program, as the latter is
  more portable.

Fixes PR 26970.

Ok'ed by maintainer.

diffstat:

 doc/CHANGES                         |    3 +-
 pkgtools/pkgclean/Makefile          |   17 ++--
 pkgtools/pkgclean/files/pkgclean.1  |    7 +-
 pkgtools/pkgclean/files/pkgclean.c  |  126 ------------------------------------
 pkgtools/pkgclean/files/pkgclean.sh |   79 ++++++++++++++++++++++
 5 files changed, 93 insertions(+), 139 deletions(-)

diffs (292 lines):

diff -r 9dc50e91ab58 -r 490c551993ba doc/CHANGES
--- a/doc/CHANGES       Thu Nov 17 22:29:51 2005 +0000
+++ b/doc/CHANGES       Thu Nov 17 22:30:09 2005 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.11967 2005/11/17 22:29:51 minskim Exp $
+$NetBSD: CHANGES,v 1.11968 2005/11/17 22:36:39 rillig Exp $
 
 Changes to the packages collection and infrastructure in 2005:
 
@@ -5269,3 +5269,4 @@
        Updated emulators/ZIPIdent to 2.5 [wiz 2005-11-17]
        Updated security/MyPasswordSafe to 20050615 [wiz 2005-11-17]
        Added print/hugeotp2ocp version 3.0 [minskim 2005-11-17]
+       Updated pkgtools/pkgclean to 20050118 [rillig 2005-11-17]
diff -r 9dc50e91ab58 -r 490c551993ba pkgtools/pkgclean/Makefile
--- a/pkgtools/pkgclean/Makefile        Thu Nov 17 22:29:51 2005 +0000
+++ b/pkgtools/pkgclean/Makefile        Thu Nov 17 22:30:09 2005 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.7 2005/04/11 21:47:05 tv Exp $
+# $NetBSD: Makefile,v 1.8 2005/11/17 22:30:09 rillig Exp $
 
-DISTNAME=      pkgclean-20050118
+DISTNAME=      pkgclean-20051116
 CATEGORIES=    pkgtools
 MASTER_SITES=  # empty
 DISTFILES=     # empty
@@ -10,25 +10,24 @@
 
 PKG_INSTALLATION_TYPES=        overwrite pkgviews
 
+NO_CHECKSUM=   yes
 NO_CONFIGURE=  yes
-NO_CHECKSUM=   yes
+NO_BUILD=      yes
 
 INSTALLATION_DIRS=     bin man/man1
 
 do-extract:
        @${CP} -R ${FILESDIR} ${WRKSRC}
 
-do-build:
-       ${CC} ${CFLAGS} -o ${WRKSRC}/pkgclean ${WRKSRC}/pkgclean.c
-
 do-install:
-       ${INSTALL_PROGRAM} ${WRKSRC}/pkgclean ${PREFIX}/bin/pkgclean
+       ${INSTALL_SCRIPT} ${WRKSRC}/pkgclean.sh ${PREFIX}/bin/pkgclean
        ${INSTALL_MAN} ${WRKSRC}/pkgclean.1 ${PREFIX}/man/man1/pkgclean.1
 
 SUBST_CLASSES=          path
 SUBST_STAGE.path=       post-patch
-SUBST_FILES.path=       pkgclean.c pkgclean.1
-SUBST_SED.path=         -e "s,@PKGSRCDIR@,${PKGSRCDIR},g"
+SUBST_FILES.path=       pkgclean.sh pkgclean.1
+SUBST_SED.path+=       -e 's,@SH@,${SH},g'
+SUBST_SED.path+=       -e 's,@PKGSRCDIR@,${PKGSRCDIR},g'
 SUBST_MESSAGE.path=     "Adjusting pkgsrc directory."
 
 .include "../../mk/bsd.pkg.mk"
diff -r 9dc50e91ab58 -r 490c551993ba pkgtools/pkgclean/files/pkgclean.1
--- a/pkgtools/pkgclean/files/pkgclean.1        Thu Nov 17 22:29:51 2005 +0000
+++ b/pkgtools/pkgclean/files/pkgclean.1        Thu Nov 17 22:30:09 2005 +0000
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 16, 2004
+.Dd November 16, 2005
 .Dt PKGCLEAN 1
 .Sh NAME
 .Nm pkgclean
@@ -51,5 +51,6 @@
 .Pa PKGSRCDIR .
 .Sh SEE ALSO
 http://www.pkgsrc.org/
-.Sh AUTHOR
-.An Peter Postma Aq peter%pointless.nl@localhost
+.Sh AUTHORS
+.An Peter Postma Aq peter%pointless.nl@localhost ,
+.An Roland Illig Aq rillig%NetBSD.org@localhost .
diff -r 9dc50e91ab58 -r 490c551993ba pkgtools/pkgclean/files/pkgclean.c
--- a/pkgtools/pkgclean/files/pkgclean.c        Thu Nov 17 22:29:51 2005 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2004 Peter Postma <peter%pointless.nl@localhost>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define PKGSRCDIR      "@PKGSRCDIR@"
-
-static const char * const skip[] = {
-       ".", "..", "CVS", "bootstrap", "doc", "distfiles",
-       "licenses", "mk", "packages", NULL
-};
-
-static void    pkgclean(const char *, const char *);
-static int     checkskip(const struct dirent *);
-
-int
-main(int argc, char *argv[])
-{
-       const char *path, *work = "work";
-
-       if ((path = getenv("PKGSRCDIR")) == NULL)
-               path = PKGSRCDIR;
-
-       if (argc > 1)
-               work = argv[1];
-
-       pkgclean(path, work);
-
-       return 0;
-}
-
-static void
-pkgclean(const char *path, const char *work)
-{
-       struct dirent **cat, **list;
-       int status, ncat, nlist, i, j;
-       char tmp[PATH_MAX];
-       struct stat sb;
-       pid_t pid;
-
-       if ((ncat = scandir(path, &cat, checkskip, alphasort)) < 0)
-               err(EXIT_FAILURE, "scandir: %s", path);
-
-       for (i = 0; i < ncat; i++) {
-               if (snprintf(tmp, sizeof(tmp), "%s/%s", path, cat[i]->d_name)
-                   >= sizeof(tmp)) {
-                       warnx("filename too long: %s", tmp);
-                       continue;
-               }
-               if (stat(tmp, &sb) < 0 || !S_ISDIR(sb.st_mode))
-                       continue;
-               if ((nlist = scandir(tmp, &list, checkskip, alphasort)) < 0) {
-                       warn("scandir: %s", tmp);
-                       continue;
-               }
-               for (j = 0; j < nlist; j++) {
-                       if (snprintf(tmp, sizeof(tmp), "%s/%s/%s/%s", path,
-                           cat[i]->d_name, list[j]->d_name, work) >= sizeof(tmp)) {
-                               warnx("filename too long: %s", tmp);
-                               continue;
-                       }
-                       if (stat(tmp, &sb) < 0 || !S_ISDIR(sb.st_mode))
-                               continue;
-                       (void)printf("Deleting %s\n", tmp);
-                       pid = fork();
-                       if (pid < 0) {
-                               warn("fork");
-                               continue;
-                       } else if (pid == 0)
-                               (void)execl("/bin/rm", "rm", "-rf", tmp, NULL);
-                       if (waitpid(pid, &status, 0) == -1)
-                               err(EXIT_FAILURE, "waitpid");
-                       if (WEXITSTATUS(status))
-                               warn("/bin/rm terminated abnormally");
-                       free(list[j]);
-               }
-               free(cat[i]);
-       }
-       free(list);
-       free(cat);
-}
-
-static int
-checkskip(const struct dirent *dp)
-{
-       const char * const *p;
-
-       for (p = skip; *p != NULL; p++)
-               if (strcmp(dp->d_name, *p) == 0)
-                       return 0;
-       return 1;
-}
diff -r 9dc50e91ab58 -r 490c551993ba pkgtools/pkgclean/files/pkgclean.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkgclean/files/pkgclean.sh       Thu Nov 17 22:30:09 2005 +0000
@@ -0,0 +1,79 @@
+#! @SH@
+# $NetBSD: pkgclean.sh,v 1.1 2005/11/17 22:30:30 rillig Exp $
+#
+
+# Copyright (c) 2005 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Roland Illig <rillig%NetBSD.org@localhost>.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#        This product includes software developed by the NetBSD
+#        Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+#    contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# Command line parsing
+#
+
+pkgsrcdir=${PKGSRCDIR-@PKGSRCDIR@}
+
+case $# in
+0)     wrkdir_basename="work";;
+1)     wrkdir_basename="$1";;
+esac
+
+#
+# Sanity checks
+#
+
+case $pkgsrcdir in
+/*)    ;;
+*)     echo "$0: error: PKGSRCDIR must be an absolute path." 1>&2
+       exit 1;;
+esac
+case $wrkdir_basename in
+*/*)   echo "$0: error: wrkdir_basename must not contain slashes." 1>&2
+       exit 1;;
+esac
+
+#
+# Clean up the pkgsrc directory
+#
+
+for wrkdir in "${pkgsrcdir}"/*/*/"${wrkdir_basename}"; do
+       echo "===> Cleaning in ${wrkdir}"
+
+       # When WRKOBJDIR is set, ${wrkdir_basename} is just a symlink to
+       # a real directory, so both must be removed properly.
+       if real_wrkdir=`cd "${wrkdir}"/. 2>/dev/null && exec pwd`; then
+               rm -rf "${real_wrkdir}"
+       fi
+
+       rm -rf "${wrkdir}"
+done



Home | Main Index | Thread Index | Old Index