From owner-freebsd-ports Fri Mar 7 19:31:37 2003 Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 576D837B401 for ; Fri, 7 Mar 2003 19:31:33 -0800 (PST) Received: from mail.inka.de (quechua.inka.de [193.197.184.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9D6BA43FE5 for ; Fri, 7 Mar 2003 19:31:30 -0800 (PST) (envelope-from mailnull@mips.inka.de) Received: from kemoauc.mips.inka.de (uucp@) by mail.inka.de with gbsmtp id 18rV3Y-0001uS-03; Sat, 08 Mar 2003 04:31:28 +0100 Received: from kemoauc.mips.inka.de (localhost [127.0.0.1]) by kemoauc.mips.inka.de (8.12.8/8.12.6) with ESMTP id h282VoZ8048250 for ; Sat, 8 Mar 2003 03:31:50 +0100 (CET) (envelope-from mailnull@localhost.mips.inka.de) Received: (from mailnull@localhost) by kemoauc.mips.inka.de (8.12.8/8.12.8/Submit) id h282VoI5048249 for freebsd-ports@freebsd.org; Sat, 8 Mar 2003 03:31:50 +0100 (CET) From: naddy@mips.inka.de (Christian Weisgerber) Subject: Re: USE_AUTOEXTRACT option for bsd.port.mk Date: Sat, 8 Mar 2003 02:31:49 +0000 (UTC) Message-ID: References: <200303060431.h264VAjO082569@green.bikeshed.org> <20030306192318.GB435@rot13.obsecurity.org> Originator: naddy@mips.inka.de (Christian Weisgerber) To: freebsd-ports@freebsd.org Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Kris Kennaway wrote: > Hey, that's pretty cool. I'd be happy with a port of this to FreeBSD. A prototype patch is appended below. It doesn't include any documentation yet and is only lightly tested. extract: If you define USE_AUTOEXTRACT, all EXTRACT_ONLY distfiles will be extracted. The most common archive types are handled automagically. If you need to add additional handlers or override the default ones, you can do so with EXTRACT_CASES. This also obsoletes several traditional variables: * USE_BZIP2, USE_ZIP: handled automatically * EXTRACT_CMD, EXTRACT_BEFORE_ARG, EXTRACT_AFTER_ARGS: superseded by EXTRACT_CASES. patch: This transparently introduces PATCH_CASES, which works analogously to EXTRACT_CASES, and fixes the handling of .bz2 patch files which is currently broken in a subtle way. Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.441 diff -u -r1.441 bsd.port.mk --- bsd.port.mk 2 Mar 2003 02:06:56 -0000 1.441 +++ bsd.port.mk 8 Mar 2003 02:13:15 -0000 @@ -1055,15 +1055,6 @@ MANCOMPRESSED?= no .endif -.if defined(PATCHFILES) -.if ${PATCHFILES:M*.bz2}x != x -PATCH_DEPENDS+= bzip2:${PORTSDIR}/archivers/bzip2 -.endif -.if ${PATCHFILES:M*.zip}x != x -PATCH_DEPENDS+= unzip:${PORTSDIR}/archivers/unzip -.endif -.endif - .if defined(USE_BZIP2) && !exists(/usr/bin/bzip2) EXTRACT_DEPENDS+= bzip2:${PORTSDIR}/archivers/bzip2 .endif @@ -2035,6 +2026,41 @@ # by user. EXTRACT_ONLY?= ${_DISTFILES} +.if defined(PATCHFILES) +PATCH_CASES?= +. if !empty(PATCHFILES:M*.bz2) +. if !exists(/usr/bin/bzip2) +PATCH_DEPENDS+= bzip2:${PORTSDIR}/archivers/bzip2 +. endif +PATCH_CASES+= *.bz2) ${BZCAT} $$patchfile | ${PATCH} ${PATCH_DIST_ARGS};; +. endif +PATCH_CASES+= *.Z|*.gz) ${GZCAT} $$patchfile | ${PATCH} ${PATCH_DIST_ARGS};; +PATCH_CASES+= *) ${PATCH} ${PATCH_DIST_ARGS} < $$patchfile; +.endif + +.if defined(USE_AUTOEXTRACT) +EXTRACT_CASES?= + +_FIX_SHAR= ${AWK} '/^#! *\/bin\/sh/ || /# This is a shell archive/ { do print; while(getline) }' + +. if !empty(EXTRACT_ONLY:M*.zip) +EXTRACT_DEPENDS+= unzip:${PORTSDIR}/archivers/unzip +EXTRACT_CASES+= *.zip) ${UNZIP} -q ${_DISTDIR}/$$archive -d ${WRKDIR};; +. endif +. if !empty(EXTRACT_ONLY:M*.tar.bz2) +. if !exists(/usr/bin/bzip2) +EXTRACT_DEPENDS+= bzip2:${PORTSDIR}/archivers/bzip2 +. endif +EXTRACT_CASES+= *.tar.bz2) ${BZCAT} ${_DISTDIR}/$$archive | ${TAR} -xf -;; +. endif +EXTRACT_CASES+= *.tar) ${TAR} -xf ${_DISTDIR}/$$archive;; +EXTRACT_CASES+= *.shar.gz|*.shar.Z|*.sh.gz|*.sh.Z) ${GZCAT} ${_DISTDIR}/$$archive | ${_FIX_SHAR} | ${SH};; +EXTRACT_CASES+= *.shar|*.sh) ${_FIX_SHAR} ${_DISTDIR}/$$archive | ${SH};; +EXTRACT_CASES+= *.tar.gz) ${GZCAT} ${_DISTDIR}/$$archive | ${TAR} -xf -;; +EXTRACT_CASES+= *.gz) ${GZCAT} ${_DISTDIR}/$$archive >`basename $$archive .gz`;; +EXTRACT_CASES+= *) ${GZCAT} ${_DISTDIR}/$$archive | ${TAR} -xf -;; +.endif # USE_AUTOEXTRACT + # Documentation MAINTAINER?= ports@FreeBSD.org @@ -2610,12 +2636,21 @@ do-extract: @${RM} -rf ${WRKDIR} @${MKDIR} ${WRKDIR} +.if defined(USE_AUTOEXTRACT) + @set -e; cd ${WRKDIR}; \ + for archive in ${EXTRACT_ONLY}; do \ + case $$archive in \ + ${EXTRACT_CASES} \ + esac; \ + done +.else @for file in ${EXTRACT_ONLY}; do \ if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ then \ exit 1; \ fi \ done +.endif .if !defined(EXTRACT_PRESERVE_OWNERSHIP) @if [ `id -u` = 0 ]; then \ ${CHMOD} -R ug-s ${WRKDIR}; \ @@ -2631,20 +2666,12 @@ .if defined(PATCHFILES) @${ECHO_MSG} "===> Applying distribution patches for ${PKGNAME}" @(cd ${_DISTDIR}; \ - for i in ${_PATCHFILES}; do \ + for patchfile in ${_PATCHFILES}; do \ if [ ${PATCH_DEBUG_TMP} = yes ]; then \ - ${ECHO_MSG} "===> Applying distribution patch $$i" ; \ + ${ECHO_MSG} "===> Applying distribution patch $$patchfile" ; \ fi; \ - case $$i in \ - *.Z|*.gz) \ - ${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ - ;; \ - *.bz2) \ - ${BZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ - ;; \ - *) \ - ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ - ;; \ + case $$patchfile in \ + ${PATCH_CASES} \ esac; \ done) .endif -- Christian "naddy" Weisgerber naddy@mips.inka.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message