2 # vim: set ts=4 sw=4 et:
4 print_cross_targets
() {
6 for f
in "${XBPS_DISTDIR}"/common
/cross-profiles
/*.sh
; do
7 f
=${f%.sh}; f
=${f##*/}; printf "\t$f\n"
12 # copied from main logic because this is run before XBPS_DISTDIR is set normally
13 local _distdir
="$(readlink -f "${0%/*}")"
14 if [ "${_distdir}" = "." ]; then
15 readonly XBPS_DISTDIR
="$(pwd -P)"
17 readonly XBPS_DISTDIR
="${_distdir}"
20 $PROGNAME: [options] <target> [arguments]
22 Targets: (only one may be specified)
25 Install bootstrap packages from host repositories into <masterdir>.
26 If the optional '-A <arch>' flag is set, it will install bootstrap packages
27 from this architecture, and its required xbps utilities. The <masterdir> will
28 be initialized for chroot operations.
31 Build and install from source the bootstrap packages into <masterdir>.
32 If the optional '-A <arch>' flag is set, it will build and install bootstrap
33 packages from this architecture, and its required xbps utilities. The <masterdir>
34 will be initialized for chroot operations.
37 Updates bootstrap packages with latest versions available from registered
38 repositories in the XBPS configuration file.
41 Runs a consistency check on all packages
44 Enter to the chroot in <masterdir>.
47 Removes obsolete packages from <hostdir>/repocache.
50 Download package source distribution file(s).
53 Extract package source distribution file(s) into the build directory.
54 By default set to <masterdir>/builddir.
57 Patch the package sources and perform other operations required to
58 prepare a package for configuring and building
61 Configure a package (fetch + extract + patch + configure).
64 Build package source (fetch + extract + patch + configure + build).
67 Run the package check(s) after building the package source.
70 Install target package into <destdir> but not building the binary package
71 and not removing build directory for inspection purposes.
74 Build binary package for <pkgname> and all required dependencies.
77 Removes auto dependencies, cleans up <masterdir>/builddir and <masterdir>/destdir.
78 If <pkgname> argument is specified, package files from <masterdir>/destdir and its
79 build directory in <masterdir>/buiddir are removed.
82 Lists installed packages in <masterdir>.
85 Remove target package from <destdir>. If <pkgname>-<version> is not matched
86 from build template nothing is removed.
89 Removes all package dependencies that were installed automatically.
92 Removes all obsolete distfiles in <hostdir>/sources.
95 Show information for the specified package.
98 Returns 0 if package can be built for the given architecture,
99 any other error otherwise.
101 show-build-deps <pkgname>
102 Show required build dependencies for <pkgname>.
104 show-check-deps <pkgname>
105 Show required check dependencies for <pkgname>.
108 Show required run-time dependencies for <pkgname>. Package must be
109 installed into destdir.
112 Show files installed by <pkgname>. Package must be installed into destdir.
114 show-hostmakedepends <pkgname>
115 Show required host build dependencies for <pkgname>.
117 show-makedepends <pkgname>
118 Show required target build dependencies for <pkgname>.
120 show-options <pkgname>
121 Show available build options by <pkgname>.
123 show-shlib-provides <pkgname>
124 Show list of provided shlibs for <pkgname>. Package must be installed into destdir.
126 show-shlib-requires <pkgname>
127 Show list of required shlibs for <pkgname>. Package must be installed into destdir.
130 Prints the value of <var> if it's defined in xbps-src.
133 Prints the list of outdated packages in XBPS repositories.
136 Prints the list of outdated packages in your system.
139 Prints the list of outdated packages in your local repositories.
141 sort-dependencies <pkg> <pkgN+1> ...
142 Given a list of packages specified as additional arguments, a sorted dependency
143 list will be returned to stdout.
146 Rebuilds all packages in the system repositories that are outdated.
149 Rebuilds all packages in your system that are outdated and updates them.
152 Rebuilds all packages in your local repositories that are outdated.
154 update-check <pkgname>
155 Check upstream site of <pkgname> for new releases.
158 Update the hash cache with existing source distfiles.
161 Removes a masterdir but preserving ccache, distcc and host directories.
165 -1 If dependencies of target package are missing, fail instead of building them.
168 Use this host machine. Automatically creates masterdir-<host> if it doesn't
169 already exist. Some host machines may require qemu-user and
170 binfmt-support if not natively supported by the processor. Supported hosts:
172 $(print_cross_targets)
175 Cross compile packages for this target machine. Supported targets:
177 $(print_cross_targets)
179 -b Build packages even if marked as broken, nocross, or excluded with archs.
182 If specified, etc/conf.<configuration> will be used as the primary config
183 file name; etc/conf will only be attempted if that does not exist.
185 -C Do not remove build directory, automatic dependencies and
186 package destdir after successful install.
188 -E If a binary package exists in a repository for the target package,
189 do not try to build it, exit immediately.
191 -f Force running the specified stage (configure/build/install/pkg)
192 even if it ran successfully.
194 -G Enable XBPS_USE_GIT_REVS (see etc/defaults.conf for more information).
196 -g Enable building -dbg packages with debugging symbols.
199 Absolute path to a directory to be bind mounted at <masterdir>/host.
200 The host directory stores binary packages, sources and package dependencies
201 downloaded from remote repositories.
202 If unset defaults to void-packages/hostdir.
206 -I Ignore required dependencies, useful for extracting/fetching sources.
208 -i Make xbps-src internal errors non-fatal.
210 -j Number of parallel build jobs to use when building packages.
212 -L Disable ASCII colors.
215 Absolute path to a directory to be used as masterdir.
216 The masterdir is the main directory to build/store/compile packages.
217 If unset defaults to void-packages/masterdir-<host>.
219 -N Disable use of remote repositories to resolve dependencies.
222 Enable or disable (prefixed with ~) package build options. If 'etc/conf'
223 already specifies some, it is merged. Keep in mind that these options
224 apply to all packages within the build, as in if a dependency needs to
225 be built, it will inherit these options.
227 Supported options can be shown with the 'show-options' target.
229 -p <variable,variable2,...>
230 For show target, show specified variables in addition to default ones.
231 Variable is split and each word is printed in separate line by default.
232 In order to print the whole value in one line, append asterisk to variable name.
234 -Q Enable running the check stage.
236 -K Enable running the check stage with longer tests.
238 -q Suppress informational output of xbps-src (build output is still printed).
241 Use an alternative local repository to store generated binary packages.
242 If unset defaults to <hostdir>/binpkgs. If set the binpkgs will
243 be stored into <hostdir>/binpkgs/<repo>.
244 This alternative repository will also be used to resolve dependencies
245 with highest priority order than others.
247 -s Make vsed warnings errors.
249 -t Create a temporary masterdir to not pollute the current one. Note that
250 the existing masterdir must be fully populated with binary-bootstrap first.
251 Once the target has finished, this temporary masterdir will be removed.
252 This flag requires xbps-uchroot(1), and won't work on filesystems that don't
255 -v Show verbose messages (only affects update-check).
257 -V Print version of xbps, then exit.
262 check_reqhost_utils
() {
265 [ "$IN_CHROOT" ] && return 0
267 for f
in ${REQHOST_UTILS}; do
268 if ! command -v ${f} &>/dev
/null
; then
269 echo "${f} is missing in your system, can't continue!" 1>&2
273 [ "$broken" ] && exit 1
274 [ -z "$1" ] && return 0
276 for f
in ${REQHOST_UTILS_BOOTSTRAP}; do
277 if ! command -v ${f} &>/dev
/null
; then
278 echo "${f} is missing in your system, can't continue!" 1>&2
282 [ "$broken" ] && exit 1
285 check_build_requirements
() {
288 case "$XBPS_TARGET" in
289 *bootstrap
*) found
=1;;
292 if [ -z "$found" ]; then
293 xbps-uhelper cmpver
"$XBPS_VERSION" "$XBPS_VERSION_REQ"
294 if [ $?
-eq 255 ]; then
295 echo "ERROR: requires xbps>=${XBPS_VERSION_REQ}" 1>&2
296 echo "Bootstrap packages must be updated with 'xbps-src bootstrap-update'" 1>&2
303 if [ -f $XBPS_MASTERDIR/.xbps_chroot_init
-o "$XBPS_CHROOT_CMD" = "ethereal" ]; then
304 export CHROOT_READY
=1
308 check_native_arch
() {
309 if [ "$CHROOT_READY" ]; then
310 if [ -s $XBPS_MASTERDIR/.xbps_chroot_init
]; then
311 export XBPS_ARCH
=$
(<$XBPS_MASTERDIR/.xbps_chroot_init
)
313 export XBPS_ARCH
=$
(xbps-uhelper arch
)
316 export XBPS_ARCH
="$XBPS_MACHINE"
321 rm -rf "$XBPS_MASTERDIR"
322 mkdir
-p "$XBPS_MASTERDIR"
323 msg_normal
"xbps-src: $XBPS_MASTERDIR masterdir cleaned up.\n"
328 if [ "$sourcepkg" ]; then
329 remove_pkg
$XBPS_CROSS_BUILD
331 if [ -z "$IN_CHROOT" ]; then
332 msg_red
"xbps-src: a failure has occurred! exiting...\n"
338 if [ -z "${XBPS_TARGET_PKG}" ]; then
339 [ ! -r .
/template
] && msg_error
"xbps-src: missing build template in $(pwd).\n"
340 XBPS_TARGET_PKG
=${PWD##*/}
342 setup_pkg
"$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
345 setup_distfiles_mirror
() {
346 local mirror scheme path
348 # Scheme file:// mirror locations only work with uchroot
349 for mirror
in $XBPS_DISTFILES_MIRROR; do
351 if [[ "$mirror" == *://* ]]; then
352 scheme
="${mirror%%://*}"
353 path
="${mirror#${scheme}://}"
357 [ "$scheme" != "file" ] && continue
358 if [ "$XBPS_CHROOT_CMD" == "uchroot" ]; then
359 if [ ! -d "$path" ]; then
360 msg_warn
"xbps-src: Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
363 mkdir
-p "$XBPS_MASTERDIR/$path"
364 XBPS_CHROOT_CMD_ARGS
+=" -b $path:$path"
366 case "$XBPS_TARGET" in
367 fetch|extract|
patch|configure|build|check|
install|pkg|bootstrap|bootstrap-update|update-sys
)
368 msg_warn
"xbps-src: File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
377 readonly PROGNAME
="${0##*/}"
378 readonly XBPS_VERSION_REQ
="0.55"
379 XBPS_VERSION
=$
(xbps-uhelper
-V)
380 XBPS_VERSION
=${XBPS_VERSION%%API*}
381 XBPS_VERSION
=${XBPS_VERSION##*:}
382 readonly XBPS_SRC_VERSION
="113"
383 export XBPS_MACHINE
=$
(xbps-uhelper
-C /dev
/null arch
)
386 XBPS_OPTSTRING
="1A:a:bc:CEfgGhH:iIj:Lm:No:p:qsQKr:tvV"
388 # Preprocess arguments in order to allow options before and after XBPS_TARGET.
389 eval set -- $
(getopt
"$XBPS_OPTSTRING" "$@");
391 # Options are saved as XBPS_ARG_FOO instead of XBPS_FOO for now; this is
392 # because configuration files may override those and we want arguments to
393 # take precedence over configuration files
394 while getopts "$XBPS_OPTSTRING" opt
; do
396 1) XBPS_ARG_BUILD_ONLY_ONE_PKG
=yes; XBPS_OPTIONS
+=" -1";;
397 A
) XBPS_ARG_MACHINE
="$OPTARG"; XBPS_OPTIONS
+=" -A $OPTARG";;
398 a
) XBPS_ARG_CROSS_BUILD
="$OPTARG"; XBPS_OPTIONS
+=" -a $OPTARG";;
399 b
) XBPS_ARG_IGNORE_BROKENNESS
=yes; XBPS_OPTIONS
+=" -b";;
400 c
) XBPS_ARG_CONFIG
="$OPTARG"; XBPS_OPTIONS
+=" -c $OPTARG";;
401 C
) XBPS_ARG_KEEP_ALL
=1; XBPS_OPTIONS
+=" -C";;
402 E
) XBPS_ARG_BINPKG_EXISTS
=1; XBPS_OPTIONS
+=" -E";;
403 f
) XBPS_ARG_BUILD_FORCEMODE
=1; XBPS_OPTIONS
+=" -f";;
404 G
) XBPS_ARG_USE_GIT_REVS
=1; XBPS_OPTIONS
+=" -G";;
405 g
) XBPS_ARG_DEBUG_PKGS
=1; XBPS_OPTIONS
+=" -g";;
406 H
) XBPS_ARG_HOSTDIR
="$OPTARG"; XBPS_OPTIONS
+=" -H $OPTARG";;
408 i
) XBPS_ARG_INFORMATIVE_RUN
=1; XBPS_OPTIONS
+=" -i";;
409 I
) XBPS_ARG_SKIP_DEPS
=1; XBPS_SKIP_REMOTEREPOS
=1; XBPS_OPTIONS
+=" -I -N";;
410 j
) XBPS_ARG_MAKEJOBS
="$OPTARG"; XBPS_OPTIONS
+=" -j $OPTARG";;
411 L
) export NOCOLORS
=1; XBPS_OPTIONS
+=" -L";;
412 m
) XBPS_ARG_MASTERDIR
="$OPTARG"; XBPS_OPTIONS
+=" -m $OPTARG";;
413 N
) XBPS_ARG_SKIP_REMOTEREPOS
=1; XBPS_OPTIONS
+=" -N";;
414 o
) XBPS_ARG_PKG_OPTIONS
="$OPTARG"; XBPS_OPTIONS
+=" -o $OPTARG";;
415 p
) XBPS_ARG_PRINT_VARIABLES
="$OPTARG"; XBPS_OPTIONS
+=" -p $OPTARG";;
416 q
) XBPS_ARG_QUIET
=1; XBPS_OPTIONS
+=" -q";;
417 Q
) XBPS_ARG_CHECK_PKGS
=yes; XBPS_OPTIONS
+=" -Q";;
418 K
) XBPS_ARG_CHECK_PKGS
=full
; XBPS_OPTIONS
+=" -K";;
419 r
) XBPS_ARG_ALT_REPOSITORY
="$OPTARG"; XBPS_OPTIONS
+=" -r $OPTARG";;
420 s
) XBPS_ARG_STRICT
=yes; XBPS_OPTIONS
+=" -s";;
421 t
) XBPS_ARG_TEMP_MASTERDIR
=1; XBPS_OPTIONS
+=" -t -C";;
422 v
) XBPS_ARG_VERBOSE
=1; XBPS_OPTIONS
+=" -v";;
423 V
) echo "xbps-src-$XBPS_SRC_VERSION $(xbps-uhelper -V)" && exit 0;;
427 shift $
(($OPTIND - 1))
429 [ $# -eq 0 ] && usage
&& exit 1
431 # Check if stdout is a tty; if false disable colors.
432 test -t 1 ||
export NOCOLORS
=1
433 # http://no-color.org
434 if [ "${NO_COLOR+x}" ]; then
442 # Check for required utilities in host system.
444 # Required utilities in host system for the bootstrap target.
445 readonly REQHOST_UTILS_BOOTSTRAP
="file objdump find make gawk bash sed gcc g++ gnat \
446 perl bsdtar gzip patch flock pkg-config"
448 # Required utilities in host.
449 readonly REQHOST_UTILS
="xbps-install xbps-query xbps-rindex xbps-uhelper \
450 xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
455 # Set XBPS_CONFIG_FILE, XBPS_DISTDIR, XBPS_MASTERDIR
458 if [ "$IN_CHROOT" ]; then
459 readonly XBPS_CONFIG_FILE
=/etc
/xbps
/xbps-src.conf
460 readonly XBPS_DISTDIR
=/void-packages
461 readonly XBPS_MASTERDIR
=/
462 readonly XBPS_HOSTDIR
=/host
464 _distdir
="$(readlink -f ${0%/*})"
465 if [ "${_distdir}" = "." ]; then
466 readonly XBPS_DISTDIR
="$(pwd -P)"
468 readonly XBPS_DISTDIR
="${_distdir}"
470 # Read defaults and then the local configuration file
471 if [ -f $XBPS_DISTDIR/etc
/defaults.conf
]; then
472 .
$XBPS_DISTDIR/etc
/defaults.conf
474 if [ -n "$XBPS_ARG_CONFIG" -a -s $XBPS_DISTDIR/etc
/conf.
$XBPS_ARG_CONFIG ]; then
475 # If specified, read custom user configuration...
476 readonly XBPS_CONFIG_FILE
=$XBPS_DISTDIR/etc
/conf.
$XBPS_ARG_CONFIG
477 elif [ -s $XBPS_DISTDIR/etc
/conf
]; then
478 # ... otherwise read generic user configuration...
479 readonly XBPS_CONFIG_FILE
=$XBPS_DISTDIR/etc
/conf
480 elif [ -s ${XDG_CONFIG_HOME:-$HOME/.config}/xbps-src.conf
]; then
481 readonly XBPS_CONFIG_FILE
=${XDG_CONFIG_HOME:-$HOME/.config}/xbps-src.conf
482 elif [ -s $HOME/.xbps-src.conf
]; then
483 # ... fallback to ~/.xbps-src.conf otherwise.
484 readonly XBPS_CONFIG_FILE
=$HOME/.xbps-src.conf
487 # Read settings from config file
488 [ -s "$XBPS_CONFIG_FILE" ] && .
$XBPS_CONFIG_FILE &>/dev
/null
490 # show colors unconditionally in CI
491 [ "$XBPS_BUILD_ENVIRONMENT" = void-packages-ci
] && export NOCOLORS
=
493 # Set options passed on command line, after configuration files have been read
494 [ -n "$XBPS_ARG_BUILD_ONLY_ONE_PKG" ] && XBPS_BUILD_ONLY_ONE_PKG
=yes
495 [ -n "$XBPS_ARG_IGNORE_BROKENNESS" ] && XBPS_IGNORE_BROKENNESS
=1
496 [ -n "$XBPS_ARG_SKIP_REMOTEREPOS" ] && XBPS_SKIP_REMOTEREPOS
=1
497 [ -n "$XBPS_ARG_BUILD_FORCEMODE" ] && XBPS_BUILD_FORCEMODE
=1
498 [ -n "$XBPS_ARG_INFORMATIVE_RUN" ] && XBPS_INFORMATIVE_RUN
=1
499 [ -n "$XBPS_ARG_TEMP_MASTERDIR" ] && XBPS_TEMP_MASTERDIR
=1
500 [ -n "$XBPS_ARG_BINPKG_EXISTS" ] && XBPS_BINPKG_EXISTS
=1
501 [ -n "$XBPS_ARG_USE_GIT_REVS" ] && XBPS_USE_GIT_REVS
=1
502 [ -n "$XBPS_ARG_DEBUG_PKGS" ] && XBPS_DEBUG_PKGS
=1
503 [ -n "$XBPS_ARG_SKIP_DEPS" ] && XBPS_SKIP_DEPS
=1
504 [ -n "$XBPS_ARG_KEEP_ALL" ] && XBPS_KEEP_ALL
=1
505 [ -n "$XBPS_ARG_QUIET" ] && XBPS_QUIET
=1
506 [ -n "$XBPS_ARG_PRINT_VARIABLES" ] && XBPS_PRINT_VARIABLES
="$XBPS_ARG_PRINT_VARIABLES"
507 [ -n "$XBPS_ARG_ALT_REPOSITORY" ] && XBPS_ALT_REPOSITORY
="$XBPS_ARG_ALT_REPOSITORY"
508 [ -n "$XBPS_ARG_STRICT" ] && XBPS_STRICT
="$XBPS_ARG_STRICT"
509 [ -n "$XBPS_ARG_MACHINE" ] && XBPS_MACHINE
="$XBPS_ARG_MACHINE"
510 [ -n "$XBPS_ARG_CROSS_BUILD" ] && XBPS_CROSS_BUILD
="$XBPS_ARG_CROSS_BUILD"
511 [ -n "$XBPS_ARG_CHECK_PKGS" ] && XBPS_CHECK_PKGS
="$XBPS_ARG_CHECK_PKGS"
512 [ -n "$XBPS_ARG_MAKEJOBS" ] && XBPS_MAKEJOBS
="$XBPS_ARG_MAKEJOBS"
513 [ -n "$XBPS_ARG_VERBOSE" ] && XBPS_VERBOSE
="$XBPS_ARG_VERBOSE"
515 # Default to nproc for XBPS_MAKEJOBS if not set and nproc is available
516 if command -v nproc
>/dev
/null
; then
517 : ${XBPS_MAKEJOBS:=$(nproc)}
519 : ${XBPS_MAKEJOBS:=1}
522 export XBPS_BUILD_ONLY_ONE_PKG XBPS_SKIP_REMOTEREPOS XBPS_BUILD_FORCEMODE \
523 XBPS_INFORMATIVE_RUN XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
524 XBPS_USE_GIT_REVS XBPS_CHECK_PKGS XBPS_DEBUG_PKGS XBPS_SKIP_DEPS \
525 XBPS_KEEP_ALL XBPS_QUIET XBPS_ALT_REPOSITORY XBPS_STRICT XBPS_CROSS_BUILD \
526 XBPS_MAKEJOBS XBPS_PRINT_VARIABLES XBPS_IGNORE_BROKENNESS
528 # The masterdir/hostdir variables are forced and readonly in chroot
529 if [ -z "$IN_CHROOT" ]; then
530 [ -n "$XBPS_ARG_MASTERDIR" ] && XBPS_MASTERDIR
="$XBPS_ARG_MASTERDIR"
531 [ -n "$XBPS_ARG_HOSTDIR" ] && XBPS_HOSTDIR
="$XBPS_ARG_HOSTDIR"
533 # Sanitize masterdir/hostdir once set for real (resolve links)
534 export XBPS_MASTERDIR
="$(readlink -f $XBPS_MASTERDIR 2>/dev/null)"
535 export XBPS_HOSTDIR
="$(readlink -f $XBPS_HOSTDIR 2>/dev/null)"
538 # Forbid root unless XBPS_ALLOW_CHROOT_BREAKOUT is set
540 if [ -z "$IN_CHROOT" -a "$UID" -eq 0 -a -z "$XBPS_ALLOW_CHROOT_BREAKOUT" ]; then
541 echo "ERROR: xbps-src cannot be used as root." 1>&2
545 # if XBPS_MASTERDIR unset, defaults to $XBPS_DISTDIR/masterdir-<host machine>
546 # unless in a container for simplicity of container/CI usage
547 if [ "$XBPS_CHROOT_CMD" = ethereal
]; then
548 : "${XBPS_MASTERDIR:=$XBPS_DISTDIR/masterdir}"
549 elif [ -n "$XBPS_ARG_MASTERDIR" ]; then
550 : # Don't mess with masterdir in argv
552 : "${XBPS_MASTERDIR:=$XBPS_DISTDIR/masterdir-$XBPS_MACHINE}"
553 # but use $XBPS_DISTDIR/masterdir if it exists and the new style doesn't
554 if [ ! -d "${XBPS_MASTERDIR}" ] && [ -r "${XBPS_DISTDIR}/masterdir/.xbps_chroot_init" ] \
555 && [ "$(cat "${XBPS_DISTDIR}/masterdir
/.xbps_chroot_init
")" = "$XBPS_MACHINE" ]; then
556 XBPS_MASTERDIR
="${XBPS_DISTDIR}/masterdir"
559 [ ! -d "$XBPS_MASTERDIR" ] && mkdir
-p "$XBPS_MASTERDIR"
561 # if XBPS_HOSTDIR unset, defaults to $XBPS_DISTDIR/hostdir.
562 : ${XBPS_HOSTDIR:=$XBPS_DISTDIR/hostdir}
563 [ ! -d $XBPS_HOSTDIR ] && mkdir
-p $XBPS_HOSTDIR
565 if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then
566 echo "ERROR: can't write to masterdir $XBPS_MASTERDIR." 1>&2
570 # Try using chroot-git then git from the host system
571 XBPS_GIT_CMD
="$(PATH="/usr
/libexec
/chroot-git
:$PATH:$XBPS_MASTERDIR/usr
/libexec
/chroot-git
" command -v git 2>/dev/null)"
572 if [ -n "$XBPS_GIT_CMD" ]; then
574 elif [ -z "$XBPS_USE_BUILD_MTIME" ] ||
[ "$XBPS_USE_GIT_REVS" ]; then
575 echo "neither chroot-git or git are available in your system!" 1>&2
581 if [ -n "$XBPS_HOSTDIR" ]; then
582 export XBPS_REPOSITORY
=$XBPS_HOSTDIR/binpkgs
583 readonly XBPS_SRCDISTDIR
=$XBPS_HOSTDIR/sources
585 export XBPS_REPOSITORY
=$XBPS_MASTERDIR/host
/binpkgs
586 readonly XBPS_SRCDISTDIR
=$XBPS_MASTERDIR/host
/sources
589 # Set XBPS_REPOSITORY to our current branch.
590 if [ -z "$XBPS_ALT_REPOSITORY" ]; then
591 pushd "$PWD" &>/dev
/null
593 _gitbranch
="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
594 if [ "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
595 export XBPS_ALT_REPOSITORY
="${_gitbranch}"
596 export XBPS_REPOSITORY
="${XBPS_REPOSITORY}/${_gitbranch}"
600 export XBPS_REPOSITORY
="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}"
603 readonly XBPS_SRCPKGDIR
=$XBPS_DISTDIR/srcpkgs
604 readonly XBPS_COMMONDIR
=$XBPS_DISTDIR/common
605 readonly XBPS_SHUTILSDIR
=$XBPS_COMMONDIR/xbps-src
/shutils
606 readonly XBPS_TRIGGERSDIR
=$XBPS_SRCPKGDIR/xbps-triggers
/files
607 readonly XBPS_CROSSPFDIR
=$XBPS_COMMONDIR/cross-profiles
608 readonly XBPS_BUILDSTYLEDIR
=$XBPS_COMMONDIR/build-style
609 readonly XBPS_LIBEXECDIR
=$XBPS_COMMONDIR/xbps-src
/libexec
610 readonly XBPS_BUILDHELPERDIR
=$XBPS_COMMONDIR/build-helper
612 readonly XBPS_TARGET
="$1"
614 XBPS_TARGET_PKG
="${2##*/}"
617 # Check for CHROOT_READY and set up XBPS_ARCH environment var for xbps.
621 # test if to use linux32 for 32-bit masterdirs in 64-bit environments
622 # x86_64, ppc64 (BE) and aarch64 are capable of this, others are not
627 x86_64
*) if [[ "$tgtarch" == i686
* ]]; then return 0; fi ;;
628 ppc64le
*) if [[ "$tgtarch" == ppcle
* ]]; then return 0; fi ;;
635 aarch64
*) if [[ "$tgtarch" == armv
* ]]; then return 0; fi ;;
640 # Reconfigure pkgs for 32bit on 64-bit systems and reexec itself.
641 if [ -z "$XBPS_REINIT" -a -s $XBPS_MASTERDIR/.xbps_chroot_init
]; then
642 export XBPS_ARCH
=${XBPS_ARCH:-$(<$XBPS_MASTERDIR/.xbps_chroot_init)}
643 if linux32_check
"$XBPS_MACHINE" "$XBPS_ARCH"; then
644 # reconfigure pkgs via linux32
645 linux32 xbps-reconfigure
-r ${XBPS_MASTERDIR} -a &>/dev
/null
646 # reexec itself via linux32
648 exec linux32
$0 ${XBPS_OPTIONS} "$@"
651 if [ -n "$XBPS_ARCH" ]; then
652 export XBPS_MACHINE
=$XBPS_ARCH
654 # At this point if XBPS_TARGET_MACHINE isn't defined we assume
655 # it's a native build.
656 if [ -z "$XBPS_TARGET_MACHINE" ]; then
657 export XBPS_TARGET_MACHINE
=$XBPS_MACHINE
660 if [ "$IN_CHROOT" ]; then
661 readonly XBPS_UHELPER_CMD
="xbps-uhelper"
662 readonly XBPS_INSTALL_CMD
="xbps-install -c /host/repocache-$XBPS_MACHINE"
663 readonly XBPS_QUERY_CMD
="xbps-query -c /host/repocache-$XBPS_MACHINE"
664 readonly XBPS_RECONFIGURE_CMD
="xbps-reconfigure"
665 readonly XBPS_REMOVE_CMD
="xbps-remove"
666 readonly XBPS_CHECKVERS_CMD
="xbps-checkvers"
667 readonly XBPS_DESTDIR
=/destdir
668 readonly XBPS_BUILDDIR
=/builddir
670 readonly XBPS_UHELPER_CMD
="xbps-uhelper -r $XBPS_MASTERDIR"
671 readonly XBPS_INSTALL_CMD
="xbps-install -c $XBPS_HOSTDIR/repocache-$XBPS_MACHINE -r $XBPS_MASTERDIR -C etc/xbps.d"
672 readonly XBPS_QUERY_CMD
="xbps-query -c $XBPS_HOSTDIR/repocache-$XBPS_MACHINE -r $XBPS_MASTERDIR -C etc/xbps.d"
673 readonly XBPS_RECONFIGURE_CMD
="xbps-reconfigure -r $XBPS_MASTERDIR"
674 readonly XBPS_REMOVE_CMD
="xbps-remove -r $XBPS_MASTERDIR"
675 readonly XBPS_CHECKVERS_CMD
="xbps-checkvers -r $XBPS_MASTERDIR"
676 readonly XBPS_DESTDIR
=$XBPS_MASTERDIR/destdir
677 readonly XBPS_BUILDDIR
=$XBPS_MASTERDIR/builddir
679 readonly XBPS_RINDEX_CMD
="xbps-rindex"
680 readonly XBPS_FETCH_CMD
="xbps-fetch"
681 readonly XBPS_DIGEST_CMD
="xbps-digest"
682 readonly XBPS_CMPVER_CMD
="xbps-uhelper cmpver"
684 export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
685 XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR \
686 XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_STRICT XBPS_SRCDISTDIR XBPS_DIGEST_CMD \
687 XBPS_UHELPER_CMD XBPS_INSTALL_CMD XBPS_QUERY_CMD XBPS_BUILD_ONLY_ONE_PKG \
688 XBPS_RINDEX_CMD XBPS_RECONFIGURE_CMD XBPS_REMOVE_CMD XBPS_CHECKVERS_CMD \
689 XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_BUILDSTYLEDIR \
690 XBPS_CPPFLAGS XBPS_CFLAGS XBPS_CXXFLAGS XBPS_FFLAGS XBPS_LDFLAGS \
691 XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \
692 XBPS_CHECK_PKGS XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
693 XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_ARG_PKG_OPTIONS XBPS_CONFIG_FILE \
694 XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR XBPS_SRC_VERSION \
695 XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
696 XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
697 XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
698 XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
699 XBPS_PRESERVE_PKGS XBPS_IGNORE_BROKENNESS
701 for i
in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR
; do
703 if [ ! -d "$val" ]; then
709 # A temporary masterdir requires xbps-uchroot(1) and -O to use overlayfs
710 # on tmpfs (available with xbps-0.45).
711 if [ -z "$IN_CHROOT" -a -n "$XBPS_TEMP_MASTERDIR" ]; then
712 export XBPS_CHROOT_CMD
="uchroot"
713 export XBPS_CHROOT_CMD_ARGS
+=" -O"
718 if [ -z "$IN_CHROOT" ]; then
719 # In non chroot case always prefer host tools.
720 export PATH
="$PATH:$XBPS_MASTERDIR/usr/bin"
726 if [ "$XBPS_CCACHE" ]; then
727 export CCACHEPATH
="/usr/lib/ccache/bin"
728 export CCACHE_DIR
="$XBPS_HOSTDIR/ccache"
729 # Avoid not using cached files just due to compiler mtime
730 # changes when e.g. bootstrapping
731 export CCACHE_COMPILERCHECK
=content CCACHE_COMPRESS
=1
732 export PATH
="$CCACHEPATH:$PATH"
739 if [ "$XBPS_DISTCC" ]; then
740 if [ "$XBPS_CCACHE" ]; then
741 export CCACHE_PREFIX
="/usr/bin/distcc"
743 DISTCCPATH
="/usr/lib/distcc/bin"
744 export PATH
="$DISTCCPATH:$PATH"
746 export DISTCC_DIR
="$XBPS_HOSTDIR/distcc-${XBPS_CROSS_BUILD:-${XBPS_MACHINE}}"
747 export DISTCC_HOSTS
="$XBPS_DISTCC_HOSTS"
751 check_build_requirements
754 # Read funcs from helpers
756 for f
in ${XBPS_SHUTILSDIR}/*.sh
; do
760 if [ -z "$IN_CHROOT" ]; then
761 trap 'exit_func' INT TERM
762 if [ -n "$XBPS_DISTFILES_MIRROR" ]; then
763 setup_distfiles_mirror
767 reconfigure_base_chroot
772 case "$XBPS_TARGET" in
774 if [ -n "$XBPS_TARGET_PKG" ]; then
775 msg_error
"xbps-src: binary-bootstrap <arch> is no longer supported, use '-A <arch>' instead\n"
778 install_base_chroot
"$XBPS_MACHINE"
781 if [ -n "$XBPS_CHECK_PKGS" ]; then
782 msg_error
"xbps-src: disable tests for bootstrap\n"
785 if [ -n "$XBPS_TARGET_PKG" ]; then
786 msg_error
"xbps-src: bootstrap <arch> is no longer supported, use '-A <arch>' instead\n"
789 # base-chroot building on host
790 # check for required host utils
791 check_reqhost_utils bootstrap
793 export XBPS_ARCH
=$XBPS_MACHINE
794 export XBPS_SKIP_REMOTEREPOS
=1
796 $XBPS_LIBEXECDIR/build.sh \
797 base-chroot base-chroot
$XBPS_TARGET ||
exit 1
799 [ -d $XBPS_MASTERDIR ] && rm -rf $XBPS_MASTERDIR
800 install_base_chroot
"$XBPS_MACHINE"
803 if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
804 chroot_handler bootstrap-update
812 chroot_handler chroot dummy
815 if [ -z "$XBPS_TARGET_PKG" ]; then
816 if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
817 chroot_handler remove-autodeps
821 msg_normal
"xbps-src: cleaning up masterdir...\n"
822 # Needed to remove Go Modules
823 [ -d "$XBPS_BUILDDIR" ] && chmod -R +wX
$XBPS_BUILDDIR
827 rm -rf $XBPS_MASTERDIR/tmp
828 mkdir
-p $XBPS_MASTERDIR/tmp
831 if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
832 chroot_handler
$XBPS_TARGET $XBPS_TARGET_PKG ||
exit $?
834 if declare -f do_clean
>/dev
/null
; then
840 remove_pkg
$XBPS_CROSS_BUILD
844 export XBPS_TARGET_ARCH
="${XBPS_CROSS_BUILD:-$XBPS_TARGET_MACHINE}"
845 $XBPS_REMOVE_CMD -C /dev
/null
-c $XBPS_HOSTDIR/repocache-
${XBPS_TARGET_ARCH} -O
851 if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
852 chroot_handler remove-autodeps
857 fetch|extract|
patch|configure|build|check|
install|pkg
)
858 if [ "$XBPS_TARGET" = "check" ] && [ -z "$XBPS_CHECK_PKGS" ]; then
859 export XBPS_CHECK_PKGS
=full
862 if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
863 chroot_handler
$XBPS_TARGET $XBPS_TARGET_PKG
867 # prevent update_base_chroot from removing the builddir/destdir
868 update_base_chroot keep-all-force
869 $XBPS_LIBEXECDIR/build.sh
$XBPS_TARGET_PKG $XBPS_TARGET_PKG \
870 $XBPS_TARGET $XBPS_CROSS_BUILD ||
exit $?
873 remove|remove-destdir
)
875 remove_pkg
$XBPS_CROSS_BUILD
884 read_pkg ignore-problems
885 show_pkg
$XBPS_PRINT_VARIABLES
892 read_pkg ignore-problems
896 read_pkg ignore-problems
900 read_pkg ignore-problems
903 show-hostmakedepends
)
904 read_pkg ignore-problems
905 show_pkg_hostmakedepends
908 read_pkg ignore-problems
912 read_pkg ignore-problems
913 show_pkg_checkdepends
916 read_pkg ignore-problems
917 for sub_name
in $subpackages; do
918 if [ $sub_name = $XBPS_TARGET_PKG ]; then
919 .
${XBPS_COMMONDIR}/environment
/setup-subpkg
/subpkg.sh
923 printf "archs: %s\n\n" "$archs"
924 printf "bootstrap: %s\n\n" "$bootstrap"
925 printf "broken: %s\n\n" "$broken"
926 printf "depends: %s\n\n" "$depends"
927 printf "hostmakedepends: %s\n\n" "$hostmakedepends"
928 printf "makedepends: %s\n\n" "$makedepends"
929 printf "nocross: %s\n\n" "$nocross"
930 printf "pkgname: %s\n\n" "$pkgname"
931 printf "restricted: %s\n\n" "$restricted"
932 printf "revision: %s\n\n" "$revision"
933 printf "subpackages: %s\n\n" "$subpackages"
934 printf "version: %s\n\n" "$version"
935 printf "provides: %s\n\n" "$provides"
936 printf "lib32disabled: %s\n\n" "$lib32disabled"
937 printf "nodebug: %s\n\n" "$nodebug"
940 read_pkg ignore-problems
941 for sub_name
in $subpackages; do
942 if [ $sub_name = $XBPS_TARGET_PKG ]; then
943 .
${XBPS_COMMONDIR}/environment
/setup-subpkg
/subpkg.sh
947 while IFS
= read -r pkg_var
; do
950 archs
) print_var
="$archs ";;
951 bootstrap
) print_var
="$bootstrap ";;
952 broken
) print_var
="$broken ";;
953 depends
) print_var
="$depends ";;
954 hostmakedepends
) print_var
="$hostmakedepends ";;
955 makedepends
) print_var
="$makedepends ";;
956 nocross
) print_var
="$nocross ";;
957 pkgname
) print_var
="$pkgname ";;
958 restricted
) print_var
="$restricted ";;
959 revision
) print_var
="$revision ";;
960 subpackages
) print_var
="$subpackages ";;
961 version
) print_var
="$version ";;
962 provides
) print_var
="$provides ";;
963 lib32disabled
) print_var
="$lib32disabled ";;
964 nodebug
) print_var
="$nodebug ";;
965 esac # the space at the end of each is essential for unset vars
966 if [ -n "$print_var" ]; then
967 printf "%s\n" "$(printf "${print_var% }" | tr -t '\n\r' ' ')"
968 fi # The trailing space gets stripped before printing anyway
973 check_pkg_arch
"$XBPS_CROSS_BUILD"
974 for x
in pkgname version revision
; do
975 printf '%s: %s\n' "$x" "${!x}"
977 for x
in bootstrap
; do
978 [[ ${!x} ]] && printf '%s: %s\n' "$x" "${!x}"
980 for x
in hostmakedepends makedepends
; do
982 if [[ ${#arr} -gt 0 ]]; then
984 printf ' %s\n' "${arr[@]}"
987 _cleandeps
=$
(setup_pkg_depends
"" 1 1 |
{ grep -vF "$(printf "%s
\n" $pkgname $subpackages)" ||
:; } |
sort -u) ||
exit 1
988 if [[ $_cleandeps ]]; then
990 printf ' %s\n' $_cleandeps
992 if [[ $subpackages ]]; then
993 printf 'subpackages:\n'
994 printf ' %s\n' $subpackages
998 read_pkg ignore-problems
999 show_pkg_build_options
1001 show-shlib-provides
)
1002 read_pkg ignore-problems
1003 show_pkg_shlib_provides
1005 show-shlib-requires
)
1006 read_pkg ignore-problems
1007 show_pkg_shlib_requires
1010 for f
in ${XBPS_COMMONDIR}/environment
/setup
/*.sh
; do
1013 if [ "$XBPS_CROSS_BUILD" ]; then
1014 source ${XBPS_COMMONDIR}/cross-profiles
/${XBPS_CROSS_BUILD}.sh
1016 source ${XBPS_COMMONDIR}/build-profiles
/${XBPS_MACHINE}.sh
1018 eval value
="\${$XBPS_TARGET_PKG}"
1025 bulk_build installed
1031 bulk_sortdeps
${@/$XBPS_TARGET/}
1037 bulk_update installed
1043 read_pkg ignore-problems
1053 msg_red
"xbps-src: invalid target $XBPS_TARGET.\n"