summaryrefslogtreecommitdiff
path: root/pkgtools/gimme
diff options
context:
space:
mode:
authoragc <agc@pkgsrc.org>2015-11-22 21:57:38 +0000
committeragc <agc@pkgsrc.org>2015-11-22 21:57:38 +0000
commit5c23770a37f512df971fe1b2c5a93daac625aa43 (patch)
treef647fbc2dbf514cc5388f2ddaccd77bd76451d88 /pkgtools/gimme
parentbdb563af34f45fc185c5ad9a085a3ecd5ae2da4b (diff)
downloadpkgsrc-5c23770a37f512df971fe1b2c5a93daac625aa43.tar.gz
Import gimme-20151122, a tool for building packages in a chroot, into the
packages collection. Sometimes there's a need to just build a package without any of the installed pre-requisites being used. Or building a one-off package which can then be used elsewhere. This package helps to produce other binary packages, using pkg_comp to build them in a chroot. The chroot is populated either by cloning the current operating system, or by using pre-existing binary sets. As an example: # gimme -c vip will clone the current operating system on this host, and use it to make a chroot in which the sysutils/vip package will be built. Similarly, to build packages and all their pre-requisites afresh, something like # gimme -c mercurial git-base would be used.
Diffstat (limited to 'pkgtools/gimme')
-rw-r--r--pkgtools/gimme/DESCR20
-rw-r--r--pkgtools/gimme/Makefile29
-rw-r--r--pkgtools/gimme/PLIST3
-rw-r--r--pkgtools/gimme/distinfo1
-rw-r--r--pkgtools/gimme/files/gimme.175
-rwxr-xr-xpkgtools/gimme/files/gimme.sh187
6 files changed, 315 insertions, 0 deletions
diff --git a/pkgtools/gimme/DESCR b/pkgtools/gimme/DESCR
new file mode 100644
index 00000000000..dbdf3580735
--- /dev/null
+++ b/pkgtools/gimme/DESCR
@@ -0,0 +1,20 @@
+Sometimes, there's a need to just build a package without any of the
+installed pre-requisites being used. Or building a one-off package
+which can then be used elsewhere.
+
+This package helps to produce other binary packages, using pkg_comp to
+build them in a chroot. The chroot is populated either by cloning the
+current operating system, or by using pre-existing binary sets. As an
+example:
+
+ # gimme -c vip
+
+will clone the current operating system on this host, and use it to
+make a chroot in which the sysutils/vip package will be built.
+
+Similarly, to build packages and all their pre-requisites afresh,
+something like
+
+ # gimme -c mercurial git-base
+
+would be used.
diff --git a/pkgtools/gimme/Makefile b/pkgtools/gimme/Makefile
new file mode 100644
index 00000000000..8f038366d8c
--- /dev/null
+++ b/pkgtools/gimme/Makefile
@@ -0,0 +1,29 @@
+# $NetBSD: Makefile,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
+
+DISTNAME= gimme-20151122
+CATEGORIES= pkgtools
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= agc@NetBSD.org
+HOMEPAGE= http://www.NetBSD.org/
+COMMENT= Script to make binary packages in a chroot
+LICENSE= modified-bsd
+
+ONLY_FOR_PLATFORM= NetBSD-*-*
+
+DEPENDS+= pkg_comp>=1.38nb1:../../pkgtools/pkg_comp
+
+AUTO_MKDIRS= yes
+
+do-extract:
+ ${CP} -R ${FILESDIR} ${WRKSRC}
+
+do-build:
+ @${ECHO} "Build done"
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/gimme.sh ${DESTDIR}${PREFIX}/bin/gimme
+ ${INSTALL_MAN} ${WRKSRC}/gimme.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/gimme.1
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/gimme/PLIST b/pkgtools/gimme/PLIST
new file mode 100644
index 00000000000..b954a3006d3
--- /dev/null
+++ b/pkgtools/gimme/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
+bin/gimme
+man/man1/gimme.1
diff --git a/pkgtools/gimme/distinfo b/pkgtools/gimme/distinfo
new file mode 100644
index 00000000000..8531a2fb983
--- /dev/null
+++ b/pkgtools/gimme/distinfo
@@ -0,0 +1 @@
+$NetBSD: distinfo,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
diff --git a/pkgtools/gimme/files/gimme.1 b/pkgtools/gimme/files/gimme.1
new file mode 100644
index 00000000000..3c4fafdfde3
--- /dev/null
+++ b/pkgtools/gimme/files/gimme.1
@@ -0,0 +1,75 @@
+.\" $NetBSD: gimme.1,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
+.\"
+.\" Copyright (c) 2015 Alistair Crooks <agc@NetBSD.org>
+.\" 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 ``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 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.
+.\"
+.Dd November 22, 2015
+.Dt GIMME 1
+.Os
+.Sh NAME
+.Nm gimme
+.Nd script to build binary packages in a chroot
+.Sh SYNOPSIS
+.Nm
+.Op Fl cv
+.Op Fl d Ar distribdir
+.Ar package ...
+.Sh DESCRIPTION
+The
+.Nm
+uses
+.Xr pkg_comp
+to manage a chroot environment in which binary packages can
+be built easily.
+Pre-existing binary sets can be used, or a clone of the
+operating system in the current environment can be used.
+.Pp
+To use a clone of the current operating system in the chroot,
+the
+.Fl c
+argument is used.
+Alternatively, one can use pre-existing sets, which will
+be taken from the directory specified by the
+.Fl d
+argument.
+.Pp
+Packages can be specified by the one-word base name of the
+package, like
+.Dq mercurial
+or by specifying the category and directory name, like
+.Dq devel/mercurial .
+.Sh EXIT STATUS
+The
+.Nm
+utility will return 0 for a successful verification,
+1 if the file's signature does not match what was expected,
+or 2 if any other error occurs.
+.Sh SEE ALSO
+.Xr pkg_comp 1
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Nx 8.0 .
+.Sh AUTHORS
+.An Alistair Crooks Aq agc@NetBSD.org .
diff --git a/pkgtools/gimme/files/gimme.sh b/pkgtools/gimme/files/gimme.sh
new file mode 100755
index 00000000000..94855274e5b
--- /dev/null
+++ b/pkgtools/gimme/files/gimme.sh
@@ -0,0 +1,187 @@
+#! /bin/sh
+
+# $NetBSD: gimme.sh,v 1.1.1.1 2015/11/22 21:57:38 agc Exp $
+
+# Copyright (c) 2015 Alistair Crooks <agc@NetBSD.org>
+# 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 ``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 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.
+#
+
+# small script to be used to provide binary packages
+# args:
+# -c use current host to provide base operating system
+# -d use the sets in this dir as base operating system
+# -v be verbose in operation
+
+current=false
+distribdir=''
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -c) current=true ;;
+ -d) distribdir="$2"; shift ;;
+ -v) set -x ;;
+ *) break ;;
+ esac
+ shift
+done
+
+# check whether sudo is needed
+case "$(id -u)" in
+0) sudo="" ;;
+*) sudo=sudo ;;
+esac
+
+# function to clean up stuff
+cleanup() {
+ case "${conf}" in
+ "") ;;
+ *) if [ -f /root/pkg_comp/${conf} ]; then
+ ${sudo} rm -f /root/pkg_comp/${conf}
+ fi
+ ;;
+ esac
+ if ${current}; then
+ case "${distribdir}" in
+ "") ;;
+ *) if [ -d ${distribdir} ]; then
+ ${sudo} rm -rf ${distribdir}
+ fi
+ ;;
+ esac
+ fi
+}
+
+trap cleanup 9 15
+
+pkgsdir=/usr/pkgsrc/packages/All
+
+conf=gimme.$$
+
+# don't need the chatty message about editing by hand
+${sudo} pkg_comp -c ${conf} maketemplate >/dev/null
+
+base_files='
+./altroot
+./bin
+./lib
+./libdata
+./libexec
+./rescue
+./sbin
+./usr/bin
+./usr/lib
+./usr/libdata
+./usr/libexec
+./usr/mdec
+./usr/sbin
+./var/chroot
+./var/db
+./var/games
+./var/heimdal
+./var/log/rdist
+./var/mail
+./var/msgs
+./var/preserve
+./var/quotas
+./var/run
+./var/rwho
+./var/shm
+./var/spool
+./var/tmp/vi.recover
+./var/tpm
+./var/www
+./var/yp/binding
+'
+
+etc_files='
+.cshrc
+.profile
+boot.cfg
+./dev/MAKEDEV
+./dev/MAKEDEV.local
+./etc
+./var/at/at.deny
+./var/crash/minfree
+./var/cron/tabs/root
+./var/games
+./var/log
+./var/msgs
+./var/run/utmp
+./var/run/utmpx
+./var/yp/Makefile.yp
+./var/yp/nicknames
+'
+
+# current means to use current os as basis for compilation
+if ${current}; then
+ echo "creating temporary set files for operating system"
+ distribdir=$(${sudo} mktemp -d /tmp/gimmesets.XXXXXX)
+ ${sudo} mkdir -p ${distribdir}/binary/sets
+ tmptmpdir=$(${sudo} mktemp -d /tmp/tmptmp.XXXXXX)
+ ${sudo} chmod 1777 ${tmptmpdir}
+ vartmptmpdir=$(${sudo} mktemp -d /tmp/tmptmp.XXXXXX)
+ ${sudo} chmod 1777 ${vartmptmpdir}
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/base.tgz -s '|'./${tmptmpdir}'|./tmp|' -s '|'./${vartmptmpdir}'|./var/tmp|' ${base_files} ./${tmptmpdir} ./${vartmptmpdir})
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/comp.tgz ./usr/include)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/etc.tgz ${etc_files})
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/kern-GENERIC.tgz ./netbsd)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/text.tgz ./usr/share)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xbase.tgz ./usr/X11R7/bin ./usr/X11R7/lib ./usr/X11R7/man ./usr/libdata/debug/usr/X11R7)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xcomp.tgz ./usr/X11R7/include)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xetc.tgz ./etc/X11 ./etc/fonts ./etc/rc.d/fccache ./etc/rc.d/xdm ./etc/rc.d/xfs)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xfont.tgz ./usr/X11R7/lib/X11/fonts)
+ (cd / && ${sudo} tar -czf ${distribdir}/binary/sets/xserver.tgz ./usr/X11R7/bin/X ./usr/X11R7/bin/Xnest ./usr/X11R7/bin/Xorg ./usr/X11R7/bin/Xvfb ./usr/X11R7/share)
+ ${sudo} rm -rf ${tmptmpdir} ${vartmptmpdir}
+fi
+
+# set where the binary sets are
+case "${distribdir}" in
+"") ;;
+*)
+ tmp=$(mktemp /tmp/gimme.XXXXXX)
+ sed -e 's|^DISTRIBDIR=.*|DISTRIBDIR='${distribdir}'|' /root/pkg_comp/${conf}.conf > ${tmp} &&
+ ${sudo} mv ${tmp} /root/pkg_comp/${conf}.conf
+ ;;
+esac
+
+# sanity check for distribdir
+if [ ! -f ${distribdir}/binary/sets/etc.tgz ]; then
+ t1=${distribdir##/binary/sets}
+ if [ -f ${t1}/etc.tgz ]; then
+ echo "Info: no need to specify "/binary/sets" on end of distribdir"
+ distribdir=${t1}
+ else
+ echo "can't find binary sets in ${distribdir}" >&2
+ cleanup
+ exit 1
+ fi
+fi
+
+# use pkg_comp to make the packages
+${sudo} pkg_comp -c ${conf} makeroot
+for p in $@; do
+ ${sudo} pkg_comp -c ${conf} build ${p}
+ ls -al ${pkgsdir}/${p}*
+done
+${sudo} pkg_comp -c ${conf} removeroot
+
+cleanup