Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Mar 2003 17:41:44 +0000 (UTC)
From:      naddy@mips.inka.de (Christian Weisgerber)
To:        freebsd-ports@freebsd.org
Subject:   Re: USE_AUTOEXTRACT option for bsd.port.mk
Message-ID:  <b4818o$1j3v$1@kemoauc.mips.inka.de>
References:  <200303060431.h264VAjO082569@green.bikeshed.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Brian Fundakowski Feldman <green@FreeBSD.org> wrote:

>    I implemented a USE_AUTOEXTRACT option which extracts files just like 
> normal, except it would use the suffix to determine the extraction method, 
> and thus be able to support more than one distribution file format in the 
> same port without any further work by the port maintainer.  Am I nutty for 
> thinking of it, or is it possibly a good idea?

I think it is a good idea, and it may even deserve to eventually become
the default behavior as it is on OpenBSD.

OpenBSD uses a variable EXTRACT_CASES to hold a shell fragment.  You can
prepend cases to it in order to add to the default handlers or to
override them.

Some relevant snippet's from OpenBSD's bsd.port.mk are:

.if !empty(EXTRACT_ONLY:M*.zip)
_USE_ZIP?=      Yes
.endif
.if !empty(EXTRACT_ONLY:M*.tar.bz2) || (defined(PATCHFILES) && !empty(_PATCHFILE
S:M*.bz2))
_USE_BZIP2?=    Yes
.endif 
_USE_ZIP?=      No
_USE_BZIP2?=    No

EXTRACT_CASES?=

.if ${_USE_ZIP:L} != "no"
BUILD_DEPENDS+= :unzip-*:archivers/unzip
EXTRACT_CASES+= *.zip) ${UNZIP} -q ${FULLDISTDIR}/$$archive -d ${WRKDIR};;
.endif
.if ${_USE_BZIP2:L} != "no"
BUILD_DEPENDS+= :bzip2-*:archivers/bzip2
EXTRACT_CASES+= *.tar.bz2) ${BZIP2} -dc ${FULLDISTDIR}/$$archive | ${TAR} xf -;;
.endif
EXTRACT_CASES+= *.tar) ${TAR} xf ${FULLDISTDIR}/$$archive;;
EXTRACT_CASES+= *.shar.gz|*.shar.Z|*.sh.gz|*.sh.Z) ${GZIP_CMD} -dc ${FULLDISTDIR}/$$archive | ${_PERL_FIX_SHAR} | /bin/sh;;
EXTRACT_CASES+= *.shar | *.sh) ${_PERL_FIX_SHAR} ${FULLDISTDIR}/$$archive | /bin/sh;;
EXTRACT_CASES+= *.tar.gz) ${GZIP_CMD} -dc ${FULLDISTDIR}/$$archive | ${TAR} xf - ;;
EXTRACT_CASES+= *.gz) ${GZIP_CMD} -dc ${FULLDISTDIR}/$$archive >`basename $$archive .gz`;;
EXTRACT_CASES+= *) ${GZIP_CMD} -dc ${FULLDISTDIR}/$$archive | ${TAR} xf -;;

...
[and for the action]

# What EXTRACT normally does:
        @PATH=${PORTPATH}; set -e; cd ${WRKDIR}; \
        for archive in ${EXTRACT_ONLY}; do \
                case $$archive in \
                ${EXTRACT_CASES} \
                esac; \
        done
...

In a port Makefile you just use something like this:

...
MASTER_SITES=   http://www.rdrop.com/users/billmc/
DISTFILES=      adcomplain.pl.uu
EXTRACT_CASES=  *.uu) uudecode ${FULLDISTDIR}/$$archive;;
...

There is also a similar PATCH_CASES.

-- 
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b4818o$1j3v$1>