2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
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 [[ ${UID} != "0" ]] ; then
13 echo "You must run this as root"
17 # We need to ensure a sane umask for the packages that will be created.
20 # We need this portage cruft to be before --help output because
21 # we utilize some of these vars in the usage info :/
22 eval $(portageq envvar -v NOCOLOR PKGDIR PORTAGE_BIN_PATH PORTAGE_NICENESS \
23 PORTAGE_PYM_PATH PORTAGE_TMPDIR ROOT)
24 export PKGDIR PORTAGE_TMPDIR ROOT
26 [[ -n ${PORTAGE_NICENESS} ]] && renice $PORTAGE_NICENESS $$ > /dev/null
28 # Make sure the xpak module is in PYTHONPATH
29 export PYTHONPATH=${PORTAGE_PYM_PATH}
30 export PORTAGE_DB=$(portageq vdb_path)
35 echo "quickpkg-${svnrev% *}"
40 Usage: quickpkg [options] <list of pkgs>
43 -C, --nocolor Disable color output
44 -x, --debug Run with shell debug turned on
45 -V, --version Print version and exit
46 -h, --help This cruft output
48 A pkg can be of the form:
49 - ${PORTAGE_DB}/<CATEGORY>/<PKG-VERSION>/
50 - single depend-type atom ...
51 if portage can emerge it, quickpkg can make a package
52 for exact definitions of depend atoms, see ebuild(5)
55 quickpkg ${PORTAGE_DB}/net-www/apache-1.3.27-r1
56 package up apache, just version 1.3.27-r1
58 package up apache, all versions of apache installed
59 quickpkg =apache-1.3.27-r1
60 quickpkg =apache-1.3.27-r1
64 echo "Unknown arguments: $*" 1>&2
72 while [[ -n $1 ]] ; do
74 -C|--nocolor) export NOCOLOR="true";;
75 -x|--debug) SET_X="yes";;
76 -V|--version) version;;
83 [[ ${SET_X} == "yes" ]] && set -x
85 source "${PORTAGE_BIN_PATH}/isolated-functions.sh"
87 # here we make a package given a little info
88 # $1 = package-name w/version
91 mkdir -p "${PORTAGE_TMPDIR}/binpkgs" || exit 1
92 chmod 0750 "${PORTAGE_TMPDIR}/binpkgs"
93 MYDIR="${PORTAGE_TMPDIR}/binpkgs/$1"
94 SRCDIR="${PORTAGE_DB}/$2/$1"
95 LOG="${PORTAGE_TMPDIR}/binpkgs/$1-quickpkglog"
97 ebegin "Building package for $1"
99 # clean up temp directory
103 mkdir -p "${MYDIR}"/temp
104 cp "${SRCDIR}"/* "${MYDIR}"/temp/
105 [ -d "${PKGDIR}"/All ] || mkdir -p "${PKGDIR}"/All
106 local pkg_dest="${PKGDIR}/All/${1}.tbz2"
107 local pkg_tmp="${PKGDIR}/All/${1}.tbz2.$$"
109 # create filelist and a basic tbz2
114 else if ($1 == "sym")
118 }' "${SRCDIR}"/CONTENTS | cut -f2- -d" " - | sed -e 's:^/:./:' | \
120 [ -d "${ROOT}/${f}" ] && [ -h "${ROOT}/${f}" ] && continue
122 done > "${MYDIR}"/filelist
123 tar vjcf "${pkg_tmp}" -C "${ROOT}" --files-from="${MYDIR}"/filelist --no-recursion
125 # join together the basic tbz2 and the pkg info files
126 python -c "import xpak; t=xpak.tbz2('${pkg_tmp}'); t.recompose('${MYDIR}/temp')"
128 # move the final binary package to PKGDIR
129 mv -f "${pkg_tmp}" "${pkg_dest}"
130 [ -d "${PKGDIR}/$2" ] || mkdir -p "${PKGDIR}/$2"
131 ( cd "${PKGDIR}/$2" && ln -s ../All/$1.tbz2 )
137 if [ -e "${PKGDIR}/All/$1.tbz2" ] ; then
139 PKGSTATS="${PKGSTATS}"$'\n'"$(einfo $1: $(du -h "${PKGDIR}/All/$1.tbz2" | gawk '{print $1}'))"
143 PKGSTATS="${PKGSTATS}"$'\n'"$(ewarn $1: not created)"
148 # here we parse the parameters given to use on the cmdline
153 # they gave us full path
154 if [ -e "${x}"/CONTENTS ] ; then
156 pkg=$(echo ${x} | cut -d/ -f6)
157 cat=$(echo ${x} | cut -d/ -f5)
158 do_pkg "${pkg}" "${cat}"
160 # lets figure out what they want
162 DIRLIST=$(portageq match "${ROOT}" "${x}")
163 if [ -z "${DIRLIST}" ] ; then
164 eerror "Could not find anything to match '${x}'; skipping"
165 export PKGERROR="${PKGERROR} ${x}"
169 for d in ${DIRLIST} ; do
170 pkg=$(echo ${d} | cut -d/ -f2)
171 cat=$(echo ${d} | cut -d/ -f1)
172 if [ -f "${PORTAGE_DB}/${cat}/${pkg}/CONTENTS" ] ; then
174 elif [ -d "${PORTAGE_DB}/${cat}/${pkg}" ] ; then
175 ewarn "Package '${cat}/${pkg}' was injected; skipping"
177 eerror "Unhandled case (${cat}/${pkg}) !"
178 eerror "Please file a bug at http://bugs.gentoo.org/"
186 if [ -z "${PKGSTATS}" ] ; then
187 eerror "No packages found"
190 echo $'\n'"$(einfo Packages now in ${PKGDIR}:)${PKGSTATS}"
192 if [ ! -z "${PKGERROR}" ] ; then
193 ewarn "The following packages could not be found:"