3 # vim: set ts=4 sw=4 et:
6 # $1 - current pkgname to build [REQUIRED]
7 # $2 - target pkgname (origin) to build [REQUIRED]
8 # $3 - xbps target [REQUIRED]
9 # $4 - cross target [OPTIONAL]
10 # $5 - internal [OPTIONAL]
12 if [ $# -lt 3 -o $# -gt 5 ]; then
13 echo "${0##*/}: invalid number of arguments: pkgname targetpkg target [cross-target]"
18 readonly XBPS_TARGET_PKG
="$2"
19 readonly XBPS_TARGET
="$3"
20 readonly XBPS_CROSS_BUILD
="$4"
21 readonly XBPS_CROSS_PREPARE
="$5"
25 for f
in $XBPS_SHUTILSDIR/*.sh
; do
29 last
="${XBPS_DEPENDS_CHAIN##*,}"
30 case "$XBPS_DEPENDS_CHAIN" in
32 msg_error
"Build-time cyclic dependency$last,${XBPS_DEPENDS_CHAIN##*,$last,} detected.\n"
35 setup_pkg
"$PKGNAME" $XBPS_CROSS_BUILD
36 readonly SOURCEPKG
="$sourcepkg"
40 show_pkg_build_options
41 check_pkg_arch
$XBPS_CROSS_BUILD
43 if [ -z "$XBPS_CROSS_PREPARE" ]; then
44 prepare_cross_sysroot
$XBPS_CROSS_BUILD ||
exit $?
46 # Install dependencies from binary packages
47 if [ "$PKGNAME" != "$XBPS_TARGET_PKG" -o -z "$XBPS_SKIP_DEPS" ]; then
48 install_pkg_deps
$PKGNAME $XBPS_TARGET_PKG pkg
$XBPS_CROSS_BUILD $XBPS_CROSS_PREPARE ||
exit $?
51 if [ "$XBPS_CROSS_BUILD" ]; then
52 install_cross_pkg
$XBPS_CROSS_BUILD ||
exit $?
55 # Fetch distfiles after installing required dependencies,
56 # because some of them might be required for do_fetch().
57 $XBPS_LIBEXECDIR/xbps-src-dofetch.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
58 [ "$XBPS_TARGET" = "fetch" ] && exit 0
60 # Fetch, extract, build and install into the destination directory.
61 $XBPS_LIBEXECDIR/xbps-src-doextract.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
62 [ "$XBPS_TARGET" = "extract" ] && exit 0
65 $XBPS_LIBEXECDIR/xbps-src-dopatch.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
66 [ "$XBPS_TARGET" = "patch" ] && exit 0
69 $XBPS_LIBEXECDIR/xbps-src-doconfigure.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
70 [ "$XBPS_TARGET" = "configure" ] && exit 0
73 $XBPS_LIBEXECDIR/xbps-src-dobuild.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
74 [ "$XBPS_TARGET" = "build" ] && exit 0
77 $XBPS_LIBEXECDIR/xbps-src-docheck.sh
$SOURCEPKG $XBPS_CROSS_BUILD ||
exit 1
78 [ "$XBPS_TARGET" = "check" ] && exit 0
80 # Install pkgs into destdir.
81 $XBPS_LIBEXECDIR/xbps-src-doinstall.sh
$SOURCEPKG no
$XBPS_CROSS_BUILD ||
exit 1
83 for subpkg
in ${subpackages} ${sourcepkg}; do
84 $XBPS_LIBEXECDIR/xbps-src-doinstall.sh
$subpkg yes $XBPS_CROSS_BUILD ||
exit 1
86 for subpkg
in ${subpackages} ${sourcepkg}; do
87 $XBPS_LIBEXECDIR/xbps-src-prepkg.sh
$subpkg $XBPS_CROSS_BUILD ||
exit 1
90 for subpkg
in ${subpackages} ${sourcepkg}; do
91 if [ "$PKGNAME" = "${subpkg}" -a "$XBPS_TARGET" = "install" ]; then
96 # Clean list of preregistered packages
97 printf "" > ${XBPS_STATEDIR}/.
${sourcepkg}_register_pkg
98 # If install went ok generate the binpkgs.
99 for subpkg
in ${subpackages} ${sourcepkg}; do
100 $XBPS_LIBEXECDIR/xbps-src-dopkg.sh
$subpkg "$XBPS_REPOSITORY" "$XBPS_CROSS_BUILD" ||
exit 1
103 # Registering packages at once per repository. This makes sure that staging is
104 # triggered for all new packages if any of them introduces inconsistencies.
105 cut
-d: -f 1,2 ${XBPS_STATEDIR}/.
${sourcepkg}_register_pkg |
sort -u | \
106 while IFS
=: read -r arch repo
; do
107 paths
=$
(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
108 cut
-d : -f 2,3 |
tr ':' '/')
109 if [ -z "$XBPS_PRESERVE_PKGS" ] ||
[ "$XBPS_BUILD_FORCEMODE" ]; then
112 if [ -n "${arch}" ]; then
113 msg_normal
"Registering new packages to $repo ($arch)\n"
114 XBPS_TARGET_ARCH
=${arch} $XBPS_RINDEX_CMD \
115 ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${force} -a ${paths}
117 msg_normal
"Registering new packages to $repo\n"
118 if [ -n "$XBPS_CROSS_BUILD" ]; then
119 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
122 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
129 if declare -f do_clean
>/dev
/null
; then
133 if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
136 remove_pkg
$XBPS_CROSS_BUILD