1 # This hook generates a XBPS binary package from an installed package in destdir.
4 local pkgdir
="$1" arch
="$2" desc
="$3" pkgver
="$4" binpkg
="$5"
5 local _preserve _deps _shprovides _shrequires _gitrevs _provides _conflicts
6 local _replaces _reverts _mutable_files _conf_files f
7 local _pkglock
="$pkgdir/${binpkg}.lock"
9 if [ ! -d "${PKGDESTDIR}" ]; then
10 msg_warn
"$pkgver: cannot find pkg destdir... skipping!\n"
14 [ ! -d $pkgdir ] && mkdir
-p $pkgdir
16 while [ -f "$_pkglock" ]; do
17 msg_warn
"${pkgver}: binpkg is being created, waiting for 1s...\n"
21 # Don't overwrite existing binpkgs by default, skip them.
22 if [ -e $pkgdir/$binpkg ] && [ "$XBPS_PRESERVE_PKGS" ] && [ -z "$XBPS_BUILD_FORCEMODE" ]; then
23 msg_normal
"${pkgver}: skipping existing $binpkg pkg...\n"
28 trap "rm -f '$_pkglock'" ERR EXIT
31 if [ ! -d $pkgdir ]; then
36 _preserve
=${preserve:+-p}
37 if [ -s ${PKGDESTDIR}/rdeps
]; then
38 _deps
="$(<${PKGDESTDIR}/rdeps)"
40 if [ -s ${PKGDESTDIR}/shlib-provides
]; then
41 _shprovides
="$(<${PKGDESTDIR}/shlib-provides)"
43 if [ -s ${PKGDESTDIR}/shlib-requires
]; then
44 _shrequires
="$(<${PKGDESTDIR}/shlib-requires)"
46 if [ -s ${XBPS_STATEDIR}/gitrev
]; then
47 _gitrevs
="$(<${XBPS_STATEDIR}/gitrev)"
50 # Stripping whitespaces
51 local _provides
="$(echo $provides)"
52 local _conflicts
="$(echo $conflicts)"
53 local _replaces
="$(echo $replaces)"
54 local _reverts
="$(echo $reverts)"
55 local _mutable_files
="$(echo $mutable_files)"
56 local _conf_files
="$(expand_destdir "$conf_files")"
57 local _alternatives
="$(echo $alternatives)"
58 local _tags
="$(echo $tags)"
59 local _changelog
="$(echo $changelog)"
61 msg_normal
"Creating $binpkg for repository $pkgdir ...\n"
64 # Create the XBPS binary package.
67 ${_provides:+--provides "${_provides}"} \
68 ${_conflicts:+--conflicts "${_conflicts}"} \
69 ${_replaces:+--replaces "${_replaces}"} \
70 ${_reverts:+--reverts "${_reverts}"} \
71 ${_mutable_files:+--mutable-files "${_mutable_files}"} \
72 ${_deps:+--dependencies "${_deps}"} \
73 ${_conf_files:+--config-files "${_conf_files}"} \
74 ${PKG_BUILD_OPTIONS:+--build-options "${PKG_BUILD_OPTIONS}"} \
75 ${_gitrevs:+--source-revisions "${_gitrevs}"} \
76 ${_shprovides:+--shlib-provides "${_shprovides}"} \
77 ${_shrequires:+--shlib-requires "${_shrequires}"} \
78 ${_alternatives:+--alternatives "${_alternatives}"} \
79 ${_preserve:+--preserve} \
80 ${tags:+--tags "${tags}"} \
81 ${_changelog:+--changelog "${_changelog}"} \
82 ${XBPS_PKG_COMPTYPE:+--compression $XBPS_PKG_COMPTYPE} \
83 --architecture ${arch} \
84 --homepage "${homepage}" \
85 --license "${license}" \
86 --maintainer "${maintainer}" \
88 --pkgver "${pkgver}" \
97 if [ $rval -ne 0 ]; then
99 msg_error
"Failed to created binary package: $binpkg!\n"
104 local arch
= binpkg
= repo
= _pkgver
= _desc
= _pkgn
= _pkgv
= _provides
= \
105 _replaces
= _reverts
= f
= found_dbg_subpkg
=
107 arch
=$XBPS_TARGET_MACHINE
108 binpkg
=${pkgver}.
${arch}.xbps
110 if [ -n "$repository" ]; then
111 repo
=$XBPS_REPOSITORY/$repository
113 repo
=$XBPS_REPOSITORY
116 genpkg
${repo} ${arch} "${short_desc}" ${pkgver} ${binpkg}
118 for f
in ${provides}; do
119 _pkgn
="$($XBPS_UHELPER_CMD getpkgname $f)"
120 _pkgv
="$($XBPS_UHELPER_CMD getpkgversion $f)"
121 _provides
+=" ${_pkgn}-32bit-${_pkgv}"
123 for f
in ${replaces}; do
124 _pkgn
="$($XBPS_UHELPER_CMD getpkgdepname $f)"
125 _pkgv
="$($XBPS_UHELPER_CMD getpkgdepversion $f)"
126 _replaces
+=" ${_pkgn}-32bit${_pkgv}"
130 for f
in ${subpackages}; do
131 # If there's an explicit subpkg named ${pkgname}-dbg, don't generate
132 # it automagically (required by linuxX.X).
133 if [ "${sourcepkg}-dbg" = "$f" ]; then
138 if [ -z "$found_dbg_subpkg" -a -d "${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}" ]; then
139 source ${XBPS_COMMONDIR}/environment
/setup-subpkg
/subpkg.sh
140 repo
=$XBPS_REPOSITORY/debug
141 _pkgver
=${pkgname}-dbg-${version}_${revision}
142 _desc
="${short_desc} (debug files)"
143 binpkg
=${_pkgver}.
${arch}.xbps
144 PKGDESTDIR
="${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}"
145 genpkg
${repo} ${arch} "${_desc}" ${_pkgver} ${binpkg}
147 # Generate 32bit pkg.
148 if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
151 if [ -d "${XBPS_DESTDIR}/${pkgname}-32bit-${version}" ]; then
152 source ${XBPS_COMMONDIR}/environment
/setup-subpkg
/subpkg.sh
153 if [ -n "$repository" ]; then
154 repo
=$XBPS_REPOSITORY/multilib
/$repository
156 repo
=$XBPS_REPOSITORY/multilib
158 _pkgver
=${pkgname}-32bit-${version}_${revision}
159 _desc
="${short_desc} (32bit)"
160 binpkg
=${_pkgver}.x86_64.xbps
161 PKGDESTDIR
="${XBPS_DESTDIR}/${pkgname}-32bit-${version}"
162 [ -n "${_provides}" ] && export provides
="${_provides}"
163 [ -n "${_replaces}" ] && export replaces
="${_replaces}"
164 genpkg
${repo} x86_64 "${_desc}" ${_pkgver} ${binpkg}