From 4ef0fbcada7e9da5014ade7ad86e6d327b551e7d Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 17 Oct 2009 02:58:36 +0200 Subject: [PATCH] Multiple changes to xbps-src and shutils: * Added XBPS_FETCH_CMD to xbps-src.conf, this will be used to fetch distfiles. Please note that it will be copied to the chroot, so it should be statically linked or with only libc required. * Removed libtool_func.sh and associated vars, it's unneeded currently. * Added keep_empty_dirs, keep_libtool_archives and nostrip. By default all empty dirs and libtool archives are removed, and executables and libraries stripped, respectively. One can use set the var in a build template to change the behaviour. * Explain in README what are the requirements to build XBPS. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091017005836-uifiof32ndy0wmd8 --- bin/xbps-src/main.sh | 4 +-- doc/README | 16 +++++---- etc/xbps-src.conf | 5 +++ shutils/build_funcs.sh | 14 +------- shutils/chroot.sh | 22 +++++++++---- shutils/fetch_funcs.sh | 2 +- shutils/install_funcs.sh | 39 ++++++++++++++++------ shutils/libtool_funcs.sh | 71 ---------------------------------------- shutils/metadata.sh | 14 ++++---- shutils/tmpl_funcs.sh | 15 +++++---- 10 files changed, 77 insertions(+), 125 deletions(-) delete mode 100644 shutils/libtool_funcs.sh diff --git a/bin/xbps-src/main.sh b/bin/xbps-src/main.sh index bae4d28e..91e66c2a 100755 --- a/bin/xbps-src/main.sh +++ b/bin/xbps-src/main.sh @@ -29,7 +29,6 @@ trap "echo && exit 1" INT QUIT : ${progname:=$(basename $0)} : ${fakeroot_cmd:=fakeroot} -: ${fetch_cmd:=wget} : ${xbps_machine:=$(uname -m)} usage() @@ -118,8 +117,7 @@ set_defvars() # check_config_vars() { - local cffound= - local f= + local cffound f if [ -z "$config_file_specified" ]; then config_file_paths="$XBPS_CONFIG_FILE ./etc/xbps-src.conf" diff --git a/doc/README b/doc/README index c7f6a508..7e1eb1ed 100644 --- a/doc/README +++ b/doc/README @@ -26,6 +26,15 @@ http://code.google.com/p/portableproplib/ I'm also the human maintaining the portable proplib package. I'd suggest you to install it into /usr/local to avoid issues with your distribution packages. +To build the xbps utils, you'll need: + + * acl (devel pkg with static lib) + * zlib (devel pkg with static lib) + * bzip2 (devel pkg with static lib) + * xz (devel pkg with static lib) + * libarchive (devel pkg with static lib, all features built in) + * proplib (deve pkg with static lib, see above) + Additionally the following software is required in the host system to build and install xbps binary packages: @@ -33,12 +42,7 @@ and install xbps binary packages: * GNU Make * GNU Bison * fakeroot - * wget OR curl OR fetch - * libarchive (devel package with static library. - acl, lzma, bzip2 support) - * libacl (devel package with static library) - * lzma/xz (devel package with static library) - * bzip2 (devel package with static library) + * wget OR curl OR fetch (statically linked or no additional deps) * perl * sudo diff --git a/etc/xbps-src.conf b/etc/xbps-src.conf index 4ce94e9a..94bc0b51 100644 --- a/etc/xbps-src.conf +++ b/etc/xbps-src.conf @@ -52,6 +52,11 @@ XBPS_CXXFLAGS="$XBPS_CFLAGS" # #XBPS_MAKEJOBS=4 +# +# Fetch command to download files. +# +XBPS_FETCH_CMD=wget + # # Cross compilation stuff. # diff --git a/shutils/build_funcs.sh b/shutils/build_funcs.sh index a59c735c..4d971bd4 100644 --- a/shutils/build_funcs.sh +++ b/shutils/build_funcs.sh @@ -1,5 +1,5 @@ #- -# Copyright (c) 2008 Juan Romero Pardines. +# Copyright (c) 2008-2009 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -63,11 +63,6 @@ build_src_phase() [ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ] && \ makejobs="-j$XBPS_MAKEJOBS" - if [ -z "$in_chroot" ]; then - . $XBPS_SHUTILSDIR/libtool_funcs.sh - libtool_fixup_file - fi - . $XBPS_SHUTILSDIR/buildvars_funcs.sh set_build_vars @@ -84,13 +79,6 @@ build_src_phase() unset makejobs - if [ -z "$in_chroot" ]; then - if [ -z "$libtool_fixup_la_stage" \ - -o "$libtool_fixup_la_stage" = "postbuild" ]; then - libtool_fixup_la_files - fi - fi - # unset cross compiler vars. [ -n "$cross_compiler" ] && cross_compile_unsetvars unset_build_vars diff --git a/shutils/chroot.sh b/shutils/chroot.sh index 113b0b4a..b4226bad 100644 --- a/shutils/chroot.sh +++ b/shutils/chroot.sh @@ -1,5 +1,5 @@ #- -# Copyright (c) 2008 Juan Romero Pardines. +# Copyright (c) 2008-2009 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -106,7 +106,7 @@ rebuild_ldso_cache() install_xbps_utils() { - local needed= + local needed fetch_cmd local xbps_prefix=$XBPS_MASTERDIR/usr/local for f in bin cmpver digest pkgdb; do @@ -117,13 +117,20 @@ install_xbps_utils() if [ -n "$needed" ]; then cd ${XBPS_MASTERDIR}/bin && ln -s dash sh - echo "=> Building and installing xbps utils." + echo "=> Installing the required XBPS utils." chroot $XBPS_MASTERDIR sh -c \ "echo /usr/local/lib > /etc/ld.so.conf" - for f in bin src cmpver digest pkgdb repo; do - cp -f $XBPS_INSTALLDIR/sbin/xbps-$f $xbps_prefix/sbin + fetch_cmd="$(which $XBPS_FETCH_CMD 2>/dev/null)" + if [ -z "$fetch_cmd" ]; then + echo "Unexistent XBPS_FETCH_CMD specified!" + exit 1 + fi + cp -f $fetch_cmd $xbps_prefix/sbin + for f in bin cmpver digest pkgdb repo; do + cp -f $XBPS_INSTALLDIR/sbin/xbps-$f.static \ + $xbps_prefix/sbin/xbps-$f done - cp -a $XBPS_INSTALLDIR/lib/libxbps.so* $xbps_prefix/lib + cp -f $XBPS_INSTALLDIR/sbin/xbps-src $xbps_prefix/sbin if [ -z $XBPS_INSTALLDIR ]; then installdir=/usr/share/xbps else @@ -192,7 +199,7 @@ mount_chroot_fs() ;; *) blah=/$f;; esac - [ ! -d $blah ] && continue + [ ! -d $blah ] && echo "failed." && continue mount --bind $blah $XBPS_MASTERDIR/$f if [ $? -eq 0 ]; then echo 1 > $XBPS_MASTERDIR/.${f}_mount_bind_done @@ -281,6 +288,7 @@ echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPSSRC_CF echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPSSRC_CF echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPSSRC_CF echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPSSRC_CF +echo "XBPS_FETCH_CMD=$XBPS_FETCH_CMD" >> $XBPSSRC_CF if [ -n "$XBPS_MAKEJOBS" ]; then echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPSSRC_CF fi diff --git a/shutils/fetch_funcs.sh b/shutils/fetch_funcs.sh index f7c9b355..b810bcb6 100644 --- a/shutils/fetch_funcs.sh +++ b/shutils/fetch_funcs.sh @@ -120,7 +120,7 @@ fetch_distfiles() localurl="$url/$curfile" fi - $fetch_cmd $localurl + $XBPS_FETCH_CMD $localurl if [ $? -ne 0 ]; then unset localurl if [ ! -f $XBPS_SRCDISTDIR/$curfile ]; then diff --git a/shutils/install_funcs.sh b/shutils/install_funcs.sh index 8be8cd5a..e6319096 100644 --- a/shutils/install_funcs.sh +++ b/shutils/install_funcs.sh @@ -27,6 +27,27 @@ # Runs the "install" phase for a pkg. This consists in installing package # into the destination directory. # + +strip_files() +{ + if [ ! -x /usr/bin/strip ]; then + return 0 + fi + [ -n "$nostrip" ] && return 0 + + msg_normal "Finding binaries/libraries to strip..." + for f in $(find ${DESTDIR} -type f); do + case "$(file -biz $f)" in + application/x-executable*) + /usr/bin/strip $f && \ + echo "===> Stripped executable: $(basename $f)";; + application/x-sharedlib*|application/x-archive*) + /usr/bin/strip -S $f && \ + echo "===> Stripped library: $(basename $f)";; + esac + done +} + install_src_phase() { local pkg="$1" @@ -71,8 +92,8 @@ install_src_phase() # Run post_install func. run_func post_install || msg_error "post_install stage failed!" - # Remove libtool archives. - if [ -z "$libtool_no_delete_archives" ]; then + # Remove libtool archives by default. + if [ -z "$keep_libtool_archives" ]; then find ${DESTDIR} -type f -name \*.la -delete fi # Always remove perllocal.pod and .packlist files. @@ -80,6 +101,12 @@ install_src_phase() find ${DESTDIR} -type f -name perllocal.pod -delete find ${DESTDIR} -type f -name .packlist -delete fi + # Remove empty directories by default. + if [ -z "$keep_empty_dirs" ]; then + find ${DESTDIR} -depth -type d -empty -delete + fi + # Strip bins/libs. + strip_files # unset cross compiler vars. [ -n "$cross_compiler" ] && cross_compile_unsetvars @@ -152,14 +179,6 @@ make_install() run_rootcmd no ${make_cmd} ${make_install_target} ${make_install_args} [ $? -ne 0 ] && msg_error "installing $pkgname-$lver." - # Replace libtool archives if requested. - if [ -z "$in_chroot" ]; then - if [ "$libtool_fixup_la_stage" = "postinstall" ]; then - . $XBPS_SHUTILSDIR/libtool_funcs.sh - libtool_fixup_la_files postinstall - fi - fi - # Unset build vars. unset_build_vars } diff --git a/shutils/libtool_funcs.sh b/shutils/libtool_funcs.sh deleted file mode 100644 index 2be43134..00000000 --- a/shutils/libtool_funcs.sh +++ /dev/null @@ -1,71 +0,0 @@ -#- -# Copyright (c) 2008 Juan Romero Pardines. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# -# Functions to fixup libtool archives while building packages -# required by xbps-base-chroot, not within the chroot. -# -libtool_fixup_file() -{ - local hldirf="hardcode_libdir_flag_spec" - - [ "$pkgname" = "libtool" -o ! -f $wrksrc/libtool ] && return 0 - [ -n "$no_libtool_fixup" ] && return 0 - - sed -i -e "s|^$hldirf=.*|$hldirf=\"-Wl,-rpath /usr/lib\"|g" \ - $wrksrc/libtool -} - -libtool_fixup_la_files() -{ - local f= - local postinstall="$1" - local where= - - # Ignore libtool itself - [ "$pkgname" = "libtool" ] && return 0 - - [ ! -f "$wrksrc/libtool" -o ! -f "$wrksrc/ltmain.sh" ] && return 0 - - # - # Replace hardcoded or incorrect paths with correct ones. - # - if [ -z "$postinstall" ]; then - where="$wrksrc" - else - where="$XBPS_DESTDIR/$pkgname-$version" - fi - - for f in $(find $where -type f -name \*.la*); do - if [ -f $f ]; then - msg_normal "Fixing up libtool archive: ${f##$where/}." - sed -i -e "s|\/..\/lib||g;s|\/\/lib|/usr/lib|g" \ - -e "s|$XBPS_MASTERDIR||g;s|$wrksrc||g" \ - -e "s|$where||g" $f - awk '{ if (/^ dependency_libs/) {gsub("/usr[^]*lib","lib");}print}' \ - $f > $f.in && mv $f.in $f - fi - done -} diff --git a/shutils/metadata.sh b/shutils/metadata.sh index 178397ce..aa7ffbdb 100644 --- a/shutils/metadata.sh +++ b/shutils/metadata.sh @@ -54,11 +54,11 @@ xbps_write_metadata_pkg() check_installed_pkg ${spkgrev} [ $? -eq 0 ] && continue - if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then + if [ ! -f $XBPS_TEMPLATESDIR/$sourcepkg/$subpkg.template ]; then msg_error "Cannot find subpackage template!" fi unset run_depends conf_files noarch triggers \ - revision openrc_services essential + revision openrc_services essential keep_empty_dirs . $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template pkgname=${sourcepkg}-${subpkg} set_tmpl_common_vars @@ -70,11 +70,11 @@ xbps_write_metadata_pkg() [ -n "${subpackages}" ] && [ "$pkg" != "${sourcepkg}" ] && return $? if [ "$build_style" = "meta-template" -a -z "${run_depends}" ]; then - for subpkg in ${subpackages}; do + for spkg in ${subpackages}; do if [ -n "${revision}" ]; then - spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}" + spkgrev="$sourcepkg-$spkg-${version}_$revision" else - spkgrev="${sourcepkg}-${subpkg}-${version}" + spkgrev="${sourcepkg}-${spkg}-${version}" fi run_depends="${run_depends} ${spkgrev}" done @@ -148,7 +148,7 @@ xbps_write_metadata_pkg_real() ln -s ${lnkat}.gz ${newlnk}.gz continue fi - echo "=> Compressing info file: $j..." + echo "===> Compressing info file: $j..." gzip -q9 ${DESTDIR}/$j done fi @@ -173,7 +173,7 @@ xbps_write_metadata_pkg_real() ln -s ${lnkat}.gz ${newlnk}.gz continue fi - echo "=> Compressing manpage: $j..." + echo "===> Compressing manpage: $j..." gzip -q9 ${DESTDIR}/$j done fi diff --git a/shutils/tmpl_funcs.sh b/shutils/tmpl_funcs.sh index 5112aebc..5a22559d 100644 --- a/shutils/tmpl_funcs.sh +++ b/shutils/tmpl_funcs.sh @@ -66,18 +66,16 @@ reset_tmpl_vars() local TMPL_VARS="pkgname distfiles configure_args configure_env \ make_build_args make_install_args build_style \ short_desc maintainer long_desc checksum wrksrc \ - make_cmd base_chroot register_shell \ + make_cmd base_chroot register_shell keep_empty_dirs \ make_build_target configure_script noextract nofetch \ - pre_configure pre_build pre_install \ - post_configure post_build post_install \ + pre_configure pre_build pre_install build_depends \ + post_configure post_build post_install nostrip \ make_install_target version revision essential \ sgml_catalogs xml_catalogs xml_entries sgml_entries \ - build_depends libtool_fixup_la_stage no_fixup_libtool \ disable_parallel_build run_depends cross_compiler \ - only_for_archs conf_files \ + only_for_archs conf_files keep_libtool_archives \ noarch subpackages sourcepkg gtk_iconcache_dirs \ abi_depends api_depends triggers openrc_services \ - libtool_no_delete_archives \ XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \ XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \ SRCPKGDESTDIR PATCHESDIR" @@ -165,7 +163,10 @@ prepare_tmpl() # # There's nothing of interest if we are a meta template. # - [ "$build_style" = "meta-template" ] && return 0 + if [ "$build_style" = "meta-template" ]; then + set_tmpl_common_vars + return 0 + fi REQ_VARS="pkgname version build_style short_desc long_desc"