2 # Copyright 1999-2006 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Id: /var/cvsroot/gentoo-src/portage/bin/quickpkg,v 1.13.2.6 2005/08/10 22:08:48 vapier Exp $
6 # This script tries to quickly create a Gentoo binary package using the
7 # VDB_PATH/category/pkg/* files
9 # Resulting tbz2 file will be created in ${PKGDIR} ...
10 # default is /usr/portage/packages/All/
12 if [ "`whoami`" != "root" ] ; then
13 echo "You must run this as root"
17 export PORTAGE_DB=$(portageq vdb_path)
18 export ROOT=$(portageq envvar ROOT)
19 export ROOT=${ROOT%/}/
21 if [ -z "$1" ] || [ $1 == "-h" ] || [ $1 == "--help" ] ; then
22 echo "QUICKPKG ver 1.2"
23 echo "USAGE: quickpkg <list of pkgs>"
24 echo " a pkg can be of the form:"
25 echo " - ${PORTAGE_DB}/<CATEGORY>/<PKG-VERSION>/"
26 echo " - single depend-type atom ..."
27 echo " if portage can emerge it, quickpkg can make a package"
28 echo " for exact definitions of depend atoms, see ebuild(5)"
31 echo " quickpkg ${PORTAGE_DB}/net-www/apache-1.3.27-r1"
32 echo " package up apache, just version 1.3.27-r1"
33 echo " quickpkg apache"
34 echo " package up apache, all versions of apache installed"
35 echo " quickpkg =apache-1.3.27-r1"
36 echo " package up apache, just version 1.3.27-r1"
40 export PKGDIR=$(portageq envvar PKGDIR)
41 export PORTAGE_TMPDIR=$(portageq envvar PORTAGE_TMPDIR)
43 source /sbin/functions.sh
45 # here we make a package given a little info
46 # $1 = package-name w/version
49 mkdir -p "${PORTAGE_TMPDIR}/portage-pkg" || exit 1
50 chmod 0750 "${PORTAGE_TMPDIR}/portage-pkg"
51 MYDIR="${PORTAGE_TMPDIR}/portage-pkg/$1"
52 SRCDIR="${PORTAGE_DB}/$2/$1"
53 LOG="${PORTAGE_TMPDIR}/portage-pkg/$1-quickpkglog"
55 ebegin "Building package for $1"
57 # clean up temp directory
61 mkdir -p "${MYDIR}"/temp
62 cp "${SRCDIR}"/* "${MYDIR}"/temp/
64 # create filelist and a basic tbz2
73 }' "${SRCDIR}"/CONTENTS | cut -f2- -d" " - | sed -e 's:^/:./:' > "${MYDIR}"/filelist
74 tar vjcf "${MYDIR}"/bin.tar.bz2 -C "${ROOT}" --files-from="${MYDIR}"/filelist --no-recursion
76 # join together the basic tbz2 and the pkg info files
77 xpak "${MYDIR}"/temp "${MYDIR}"/inf.xpak
78 tbz2tool join "${MYDIR}"/bin.tar.bz2 "${MYDIR}"/inf.xpak "${MYDIR}"/$1.tbz2
80 # move the final binary package to PKGDIR
81 [ -d "${PKGDIR}"/All ] || mkdir -p "${PKGDIR}"/All
82 [ -d "${PKGDIR}/$2" ] || mkdir -p "${PKGDIR}/$2"
83 mv "${MYDIR}"/$1.tbz2 "${PKGDIR}"/All
84 ( cd "${PKGDIR}/$2" && ln -s ../All/$1.tbz2 )
90 if [ -e "${PKGDIR}/All/$1.tbz2" ] ; then
92 PKGSTATS="${PKGSTATS}"$'\n'"$(einfo $1: $(du -h "${PKGDIR}/All/$1.tbz2" | gawk '{print $1}'))"
96 PKGSTATS="${PKGSTATS}"$'\n'"$(ewarn $1: not created)"
101 # here we parse the parameters given to use on the cmdline
106 # they gave us full path
107 if [ -e "${x}"/CONTENTS ] ; then
109 pkg=$(echo ${x} | cut -d/ -f6)
110 cat=$(echo ${x} | cut -d/ -f5)
111 do_pkg "${pkg}" "${cat}"
113 # lets figure out what they want
115 DIRLIST=$(portageq match "${ROOT}" "${x}")
116 if [ -z "${DIRLIST}" ] ; then
117 eerror "Could not find anything to match '${x}'; skipping"
118 export PKGERROR="${PKGERROR} ${x}"
122 for d in ${DIRLIST} ; do
123 pkg=$(echo ${d} | cut -d/ -f2)
124 cat=$(echo ${d} | cut -d/ -f1)
125 if [ -f "${PORTAGE_DB}/${cat}/${pkg}/CONTENTS" ] ; then
127 elif [ -d "${PORTAGE_DB}/${cat}/${pkg}" ] ; then
128 ewarn "Package '${cat}/${pkg}' was injected; skipping"
130 eerror "Unhandled case (${cat}/${pkg}) !"
131 eerror "Please file a bug at http://bugs.gentoo.org/"
139 if [ -z "${PKGSTATS}" ] ; then
140 eerror "No packages found"
143 echo $'\n'"$(einfo Packages now in ${PKGDIR}:)${PKGSTATS}"
145 if [ ! -z "${PKGERROR}" ] ; then
146 ewarn "The following packages could not be found:"