From 22774084ab5cae5fcbd76eee72b30ab9ff0f0949 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 7 May 2010 12:25:24 +0200 Subject: [PATCH] xbps-src: always create logs for configure/build/install stages in $wrksrc. Fixed -C and install-destdir in the chroot, $# wasn't consistent :-) --- xbps-src/libexec/xbps-src-doinst-helper.sh.in | 17 +++++----- xbps-src/shutils/build_funcs.sh | 11 +++--- xbps-src/shutils/chroot.sh.in | 34 +++++++++---------- xbps-src/shutils/configure_funcs.sh | 13 ++++--- xbps-src/shutils/metadata.sh | 18 +++++----- xbps-src/shutils/pkgtarget_funcs.sh.in | 19 +++++------ xbps-src/xbps-src.sh.in | 6 ++-- 7 files changed, 62 insertions(+), 56 deletions(-) diff --git a/xbps-src/libexec/xbps-src-doinst-helper.sh.in b/xbps-src/libexec/xbps-src-doinst-helper.sh.in index 7158ff720c2..3196bc53e58 100644 --- a/xbps-src/libexec/xbps-src-doinst-helper.sh.in +++ b/xbps-src/libexec/xbps-src-doinst-helper.sh.in @@ -90,7 +90,7 @@ install_src_phase() # Run pre_install func. run_func pre_install 2>${wrksrc}/.xbps_pre_install.log \ - || msg_error "pre_install stage failed!" + || msg_error "$pkgname: pre_install() failed! check $wrksrc/.xbps_pre_install.log" msg_normal "Running install phase for $pkgname-$lver." @@ -98,12 +98,12 @@ install_src_phase() case "$build_style" in custom-install) run_func do_install 2>${wrksrc}/.xbps_do_install.log \ - || msg_error "do_install stage failed!" + || msg_error "$pkgname: do_install() failed! check $wrksrc/.xbps_do_install.log" ;; python-module) . $XBPS_HELPERSDIR/python-module.sh run_func do_install 2>${wrksrc}/.xbps_do_install.log \ - || msg_error "python module install failed!" + || msg_error "$pkgname: install failed! check $wrksrc/.xbps_do_install.log" ;; *) make_install $lver 2>${wrksrc}/.xbps_make_install.log @@ -113,7 +113,7 @@ install_src_phase() # Run post_install func. run_func post_install 2>${wrksrc}/.xbps_post_install.log \ - || msg_error "post_install stage failed!" + || msg_error "$pkgname: post_install() failed! check $wrksrc/.xbps_post_install.log" # Remove libtool archives by default. if [ -z "$keep_libtool_archives" ]; then @@ -160,13 +160,13 @@ install_src_phase() set_tmpl_common_vars run_func do_install \ 2>${wrksrc}/.xbps_do_install_${pkgname}.log || \ - msg_error "$pkgname do_install stage failed!" + msg_error "$pkgname: do_install() failed! check $wrksrc/.xbps_do_install_$pkgname.log" done # # Remove $wrksrc if -C not specified. # - if [ -d "$saved_wrksrc" -a -z "$dontrm_builddir" ]; then + if [ -d "$saved_wrksrc" -a "$dontrm_builddir" = "no" ]; then rm -rf $saved_wrksrc && \ msg_normal "Removed $sourcepkg-$lver build directory." fi @@ -192,8 +192,9 @@ make_install() # # Install package via make. # - ${make_cmd} ${make_install_target} \ - ${make_install_args} || msg_error "installing $pkgname-$lver" + { ${make_cmd} ${make_install_target} ${make_install_args} \ + 2>&1 | tee $wrksrc/.xbps_make_install.log; } \ + || msg_error "$pkgname: make install failed! check $wrksrc/.xbps_make_install.log" # Unset build vars. unset_build_vars diff --git a/xbps-src/shutils/build_funcs.sh b/xbps-src/shutils/build_funcs.sh index fa12db056ea..73d5b018af2 100644 --- a/xbps-src/shutils/build_funcs.sh +++ b/xbps-src/shutils/build_funcs.sh @@ -58,7 +58,7 @@ build_src_phase() fi # Run pre_build func. run_func pre_build 2>${wrksrc}/.xbps_pre_build.log \ - || msg_error "pre_build stage failed!" + || msg_error "$pkgname: pre_build() failed! check $wrksrc/.xbps_pre_build.log" . $XBPS_SHUTILSDIR/buildvars_funcs.sh set_build_vars @@ -72,14 +72,15 @@ build_src_phase() # # Build package via make. # - ${make_cmd} ${makejobs} ${make_build_args} \ - ${make_build_target} 2>${wrksrc}/.xbps_make_build.log - [ $? -ne 0 ] && msg_error "building $pkg (build phase)." + { ${make_cmd} ${makejobs} ${make_build_args} \ + ${make_build_target} \ + 2>&1 | tee ${wrksrc}/.xbps_make_build.log; } || \ + msg_error "$pkgname: build phase failed! check $wrksrc/.xbps_make_build.log" fi # Run post_build func. run_func post_build 2>${wrksrc}/.xbps_post_build.log \ - || msg_error "post_build stage failed!" + || msg_error "$pkgname: post_build() failed! check $wrksrc/.xbps_post_build.log" unset makejobs diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index 673376980f6..a0aba64d579 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -218,13 +218,14 @@ xbps_chroot_handler() { local action="$1" local pkg="$2" - local only_destdir="$3" - local norm_builddir="$4" + local norm_builddir="$3" local path="/tools/bin:/usr/local/sbin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin" + [ -z "$action" -o -z "$pkg" ] && return 1 [ "$action" != "configure" -a "$action" != "build" -a \ - "$action" != "install" -a "$action" != "chroot" ] && return 1 + "$action" != "install" -a "$action" != "chroot" -a \ + "$action" != "install-destdir" ] && return 1 if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then echo -n "==> Preparing chroot on $XBPS_MASTERDIR... " @@ -236,8 +237,8 @@ xbps_chroot_handler() create_busybox_links install_xbps_utils - MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ - @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount + { MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ + @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount; } [ $? -ne 0 ] && return $? if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then @@ -247,29 +248,26 @@ xbps_chroot_handler() # Reinstall xbps-src in the chroot if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then msg_normal "Installing xbps-src in the masterdir..." - env in_chroot=yes LANG=C PATH=$path \ + { env in_chroot=yes LANG=C PATH=$path \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \ "cd /xbps/xbps-src && make IN_CHROOT=1 install clean" \ - 2>&1 >/dev/null + 2>&1 >/dev/null; } fi if [ "$action" = "chroot" ]; then - env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \ - ${chroot_cmd} $XBPS_MASTERDIR /bin/sh + { env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \ + ${chroot_cmd} $XBPS_MASTERDIR /bin/sh; } else - local lenv - [ -n "$only_destdir" ] && \ - lenv="install_destdir_target=yes" - [ -n "$norm_builddir" ] && \ + [ "$norm_builddir" = "yes" ] && \ action="-C $action" - env in_chroot=yes LANG=C PATH=$path \ - ${lenv} ${chroot_cmd} $XBPS_MASTERDIR sh -c \ - "cd /xbps/srcpkgs/$pkg && xbps-src $action" + { env in_chroot=yes LANG=C PATH=$path \ + ${chroot_cmd} $XBPS_MASTERDIR sh -c \ + "cd /xbps/srcpkgs/$pkg && xbps-src $action"; } fi msg_normal "Exiting from the chroot on $XBPS_MASTERDIR." - MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ - @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount + { MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ + @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount; } return $? } diff --git a/xbps-src/shutils/configure_funcs.sh b/xbps-src/shutils/configure_funcs.sh index d99a834e5d5..c1e7bcfdd86 100644 --- a/xbps-src/shutils/configure_funcs.sh +++ b/xbps-src/shutils/configure_funcs.sh @@ -59,7 +59,7 @@ configure_src_phase() # Run pre_configure func. run_func pre_configure 2>${wrksrc}/.xbps_pre_configure.log \ - || msg_error "pre_configure stage failed!" + || msg_error "$pkgname: pre_configure() failed! check $wrksrc/.xbps_pre_configure.log" # Export configure_env vars. for f in ${configure_env}; do @@ -83,9 +83,11 @@ configure_src_phase() # # Packages using GNU autoconf # - ${configure_script} --prefix=/usr --sysconfdir=/etc \ + { ${configure_script} --prefix=/usr --sysconfdir=/etc \ --infodir=/usr/share/info --mandir=/usr/share/man \ - ${configure_args} + ${configure_args} 2>&1 \ + | tee ${wrksrc}/.xbps_configure.log; } || \ + msg_error "$pkgname: configure failed! check ${wrksrc}/.xbps_configure.log" ;; configure) # @@ -99,7 +101,8 @@ configure_src_phase() # They are all handled by the helper perl-module.sh. # . $XBPS_HELPERSDIR/perl-module.sh - perl_module_build $pkgname + { perl_module_build $pkgname; } \ + 2>&1 | tee ${wrksrc}/.xbps_configure.log ;; *) # @@ -116,7 +119,7 @@ configure_src_phase() # Run post_configure func. run_func post_configure 2>${wrksrc}/.xbps_post_configure.log \ - || msg_error "post_configure stage failed!" + || msg_error "$pkgname: post_configure() failed! check $wrksrc/.xbps_post_configure.log" # unset configure_env vars. for f in ${configure_env}; do diff --git a/xbps-src/shutils/metadata.sh b/xbps-src/shutils/metadata.sh index 8102ae0a4a0..34ddb0dd0d0 100644 --- a/xbps-src/shutils/metadata.sh +++ b/xbps-src/shutils/metadata.sh @@ -364,16 +364,18 @@ _EOF mv -f $TMPFPLIST ${DESTDIR}/files.plist mv -f $TMPFPROPS ${DESTDIR}/props.plist - $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/files.plist || return 1 - $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/props.plist || return 1 - chmod 644 ${DESTDIR}/files.plist ${DESTDIR}/props.plist - [ -f $metadir/flist ] && chmod 644 $metadir/flist - + { \ + $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/files.plist; \ + $XBPS_PKGDB_CMD sanitize-plist ${DESTDIR}/props.plist; \ + chmod 644 ${DESTDIR}/files.plist ${DESTDIR}/props.plist; \ + [ -f $metadir/flist ] && chmod 644 $metadir/flist; \ + \ # # Create the INSTALL/REMOVE scripts if package uses them # or uses any available trigger. # - . ${XBPS_SHUTILSDIR}/metadata_scripts.sh - xbps_write_metadata_scripts_pkg install || return $? - xbps_write_metadata_scripts_pkg remove || return $? + . ${XBPS_SHUTILSDIR}/metadata_scripts.sh; \ + xbps_write_metadata_scripts_pkg install; \ + xbps_write_metadata_scripts_pkg remove; \ + } || return $? } diff --git a/xbps-src/shutils/pkgtarget_funcs.sh.in b/xbps-src/shutils/pkgtarget_funcs.sh.in index a6f3114984d..b2b4e782836 100644 --- a/xbps-src/shutils/pkgtarget_funcs.sh.in +++ b/xbps-src/shutils/pkgtarget_funcs.sh.in @@ -96,22 +96,21 @@ install_pkg() fi # Install pkg into destdir. - env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \ + { env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \ + dontrm_builddir=${dontrm_builddir} \ ${fakeroot_cmd} ${fakeroot_cmd_args} \ @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper \ - ${curpkgn} || exit $? + ${curpkgn}; } || exit $? # Always write metadata to package's destdir. . $XBPS_SHUTILSDIR/metadata.sh - xbps_write_metadata_pkg + xbps_write_metadata_pkg || return $? - # - # Do not stow package if it wasn't requested. - # - if [ -z "$install_destdir_target" ]; then - . $XBPS_SHUTILSDIR/stow_funcs.sh - stow_pkg_handler stow - fi + [ "$install_destdir_target" = "yes" ] && return 0 + + # Stow package into masterdir. + . $XBPS_SHUTILSDIR/stow_funcs.sh + stow_pkg_handler stow } # diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index d746bd305e5..2b13365fea3 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -277,11 +277,13 @@ install|install-destdir) [ ! -r ./template ] && msg_error "missing build template file." . ./template + install_destdir_target=no [ "$target" = "install-destdir" ] && install_destdir_target=yes + [ -z "$dontrm_builddir" ] && dontrm_builddir=no + if [ -z "$in_chroot" -a -z "$base_chroot" ]; then . $XBPS_SHUTILSDIR/chroot.sh - xbps_chroot_handler install $(basename_cwd) \ - $install_destdir_target $dontrm_builddir + xbps_chroot_handler $target $(basename_cwd) $dontrm_builddir else . $XBPS_SHUTILSDIR/pkgtarget_funcs.sh setup_tmpl $(basename_cwd)