commit: d370474e3f85a3bbcbb2026ca5ec55257b7a0f39 Author: XU Benda <heroxbd <AT> gmail <DOT> com> AuthorDate: Thu Dec 22 04:37:11 2011 +0000 Commit: Steve Arnold <nerdboy <AT> gentoo <DOT> org> CommitDate: Sat Jun 25 13:45:04 2016 +0000 URL: https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=d370474e
prefixify build system and scripts. Makefile | 2 ++ crossdev | 52 +++++++++++++++++++++++------------------- settings.mk | 3 ++- wrappers/Makefile | 3 +++ wrappers/cross-emerge | 7 +++++- wrappers/emerge-wrapper | 2 +- wrappers/etc/portage/make.conf | 2 +- 7 files changed, 44 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index a36fa1f..26c5b37 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ include settings.mk all: + sed -i -e "s,@GENTOO_PORTAGE_EPREFIX@,$(EPREFIX),g" crossdev + $(MAKE) -C wrappers install: $(INSTALL_DIR) $(DESTDIR)/$(PREFIX)/bin/ diff --git a/crossdev b/crossdev index 877c68f..00ddea7 100755 --- a/crossdev +++ b/crossdev @@ -13,9 +13,15 @@ if [[ ${ROOT} != "/" ]] ; then exit 2 fi +EPREFIX="@GENTOO_PORTAGE_EPREFIX@" +if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then + EPREFIX="" +fi +EROOT=${ROOT%/}"${EPREFIX}"/ +: ${PORTAGE_CONFIGROOT:=${EROOT}} CONFIGROOT="${PORTAGE_CONFIGROOT}/etc/portage" -source /etc/init.d/functions.sh || exit 1 +source "${EPREFIX}"/etc/init.d/functions.sh || exit 1 esyslog() { :; } die_logs() { echo @@ -318,7 +324,7 @@ parse_repo_config() { # location = /usr/local/portage # masters = gentoo # priority = 0 - local repo_config=$(portageq repositories_configuration "${ROOT}") + local repo_config=$(portageq repositories_configuration "${EROOT}") local flat_config=$(echo "${repo_config}" | gawk ' function push(arr, idx, ele) { if (idx in arr) @@ -400,7 +406,7 @@ setup_portage_vars() { fi # make sure we have a valid logdir - : ${PORT_LOGDIR:=/var/log/portage} + : ${PORT_LOGDIR:=${EPREFIX}/var/log/portage} xmkdir -p "${PORT_LOGDIR}" } @@ -421,8 +427,8 @@ uninstall() { done rm -rf "${CONFIGROOT}"/env/cross-${CTARGET} rmdir "${CONFIGROOT}"/env 2>/dev/null - rm -f /etc/revdep-rebuild/05cross-${CTARGET} - rmdir /etc/revdep-rebuild 2>/dev/null + rm -f "${EPREFIX}"/etc/revdep-rebuild/05cross-${CTARGET} + rmdir "${EPREFIX}"/etc/revdep-rebuild 2>/dev/null # Unmerge all toolchain packages for this target. qmerge -Uqy $(qlist -IC "cross-${CTARGET}/") @@ -433,29 +439,29 @@ uninstall() { gcc-{ar,nm,ranlib} gccbug gprof ld nm objcopy objdump \ ranlib readelf size strings strip windmc windres do - rm -f /usr/bin/${CTARGET}-${f} /usr/${CTARGET}/bin/${f} + rm -f "${EPREFIX}"/usr/bin/${CTARGET}-${f} "${EPREFIX}"/usr/${CTARGET}/bin/${f} done - rm -f /usr/${CTARGET}/{sys-include,usr} - rmdir /usr/${CTARGET}/{include/asm,include} 2>/dev/null - rm -f /usr/bin/${CTARGET}-{gcc,{c,g}++,cpp,gfortran,gcov} - rm -f /etc/env.d/{binutils,gcc}/config-${CTARGET} + rm -f "${EPREFIX}"/usr/${CTARGET}/{sys-include,usr} + rmdir "${EPREFIX}"/usr/${CTARGET}/{include/asm,include} 2>/dev/null + rm -f "${EPREFIX}"/usr/bin/${CTARGET}-{gcc,{c,g}++,cpp,gfortran,gcov} + rm -f "${EPREFIX}"/etc/env.d/{binutils,gcc}/config-${CTARGET} # clean out files from crossdev itself - [[ -e /var/db/pkg/cross-${CTARGET} ]] && rmdir /var/db/pkg/cross-${CTARGET} - rm -f /usr/bin/${CTARGET}-{emerge,fix-root,pkg-config} /usr/bin/emerge-${CTARGET} + [[ -e ${EPREFIX}/var/db/pkg/cross-${CTARGET} ]] && rmdir "${EPREFIX}"/var/db/pkg/cross-${CTARGET} + rm -f "${EPREFIX}"/usr/bin/${CTARGET}-{emerge,fix-root,pkg-config} "${EPREFIX}"/usr/bin/emerge-${CTARGET} for f in make.{conf,globals,profile} ; do - f="/usr/${CTARGET}/etc/${f}" + f="${EPREFIX}/usr/${CTARGET}/etc/${f}" [[ -L ${f} ]] && rm -f ${f} - f="/usr/${CTARGET}/etc/portage/${f##*/}" + f="${EPREFIX}/usr/${CTARGET}/etc/portage/${f##*/}" [[ -L ${f} ]] && rm -f ${f} done - find /usr/share/crossdev/etc/ -type f | \ + find "${EPREFIX}"/usr/share/crossdev/etc/ -type f | \ while read f ; do f1=${f} [[ ! -e ${f1} ]] && continue m1=$(set -- `md5sum ${f1}`; echo $1) - f2=/usr/${CTARGET}${f#/usr/share/crossdev} + f2=${EPREFIX}/usr/${CTARGET}${f#/usr/share/crossdev} [[ ! -e ${f2} ]] && continue m2=$(set -- `md5sum ${f2}`; echo $1) if [[ ${m1} == ${m2} ]] ; then @@ -464,7 +470,7 @@ uninstall() { done # clean out the sysroot, prompting the user if need be - for d in /usr/lib/gcc{,-lib}/${CTARGET} /usr/${CTARGET} ; do + for d in "${EPREFIX}"/usr/lib/gcc{,-lib}/${CTARGET} "${EPREFIX}"/usr/${CTARGET} ; do if [[ ! -d ${d} ]] ; then rm -f "${d}" else @@ -540,9 +546,9 @@ hr() { || c=${c##* } fi local ext=${1:- _ - ~ -} - local sext=${ext//?/ } + local sext=${ext/?/ } local br=$(printf "%$((c + ${#ext}))s") - local banner=${br//${sext}/${ext}} + local banner=${br/${sext}/${ext}} echo "${banner:0:${c}}" } ver_get_op() { @@ -1124,21 +1130,21 @@ for_each_extra_pkg set_portage X set_metadata # filter out revdep rebuild stuff #182601 -xmkdir -p /etc/revdep-rebuild -echo "SEARCH_DIRS_MASK=/usr/${CTARGET}" > /etc/revdep-rebuild/05cross-${CTARGET} +xmkdir -p "${EPREFIX}"/etc/revdep-rebuild +echo "SEARCH_DIRS_MASK=${EPREFIX}/usr/${CTARGET}" > "${EPREFIX}"/etc/revdep-rebuild/05cross-${CTARGET} hr ####################################### ### Create links for helper scripts ### -xmkdir -p /usr/${CTARGET} +xmkdir -p "${EPREFIX}"/usr/${CTARGET} emerge-wrapper --target ${CTARGET} --init || exit 1 ################# emerged_with_use() { local pkg=$1 use=$2 - grep -qs ${use} /var/db/pkg/cross-${CTARGET}/${pkg}-*/USE + grep -qs ${use} "${EPREFIX}"/var/db/pkg/cross-${CTARGET}/${pkg}-*/USE } set_eopts_on_pkg_status() { emerged_with_use "$@" \ diff --git a/settings.mk b/settings.mk index 30434d6..01f8e9d 100644 --- a/settings.mk +++ b/settings.mk @@ -1,8 +1,9 @@ # Copyright 2008-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +PORTAGE_CONFIGROOT ?= $(shell portageq envvar PORTAGE_CONFIGROOT) DESTDIR ?= -EPREFIX ?= +EPREFIX ?= $(shell portageq envvar EPREFIX) PREFIX ?= $(EPREFIX)/usr INSTALL_DIR = install -m 755 -d diff --git a/wrappers/Makefile b/wrappers/Makefile index 144ecc1..df5eb2b 100644 --- a/wrappers/Makefile +++ b/wrappers/Makefile @@ -9,6 +9,9 @@ SITE = $(PREFIX)/share/crossdev/include/site TOPDIR = all: + sed -i -e "s,@GENTOO_PORTAGE_EPREFIX@,$(EPREFIX),g" cross-emerge + sed -i -e "s,@GENTOO_PORTAGE_EPREFIX@,$(EPREFIX),g" emerge-wrapper + sed -i -e "s,@GENTOO_PORTAGE_EPREFIX@,$(EPREFIX),g" etc/portage/make.conf install: $(INSTALL_DIR) $(DESTDIR)/$(PREFIX)/bin/ $(DESTDIR)/$(SITE) diff --git a/wrappers/cross-emerge b/wrappers/cross-emerge index fc6117e..fb98951 100755 --- a/wrappers/cross-emerge +++ b/wrappers/cross-emerge @@ -9,7 +9,12 @@ if [ -z "${CHOST}" ] ; then fi export CHOST -: ${SYSROOT=/usr/${CHOST}} +EPREFIX="@GENTOO_PORTAGE_EPREFIX@" +if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then + EPREFIX="" +fi + +: ${SYSROOT=${EPREFIX}/usr/${CHOST}} : ${PORTAGE_CONFIGROOT=${SYSROOT}} export SYSROOT PORTAGE_CONFIGROOT diff --git a/wrappers/emerge-wrapper b/wrappers/emerge-wrapper index e375025..c123259 100755 --- a/wrappers/emerge-wrapper +++ b/wrappers/emerge-wrapper @@ -91,7 +91,7 @@ cross_wrap_bin() cross_wrap() { - SYSROOT=/usr/${CHOST} + SYSROOT=@GENTOO_PORTAGE_EPREFIX@/usr/${CHOST} cross_wrap_bin "$@" || return $? if [[ -d ${SYSROOT} ]] && [[ ! -d ${SYSROOT}/etc ]] ; then cross_wrap_etc "$@" diff --git a/wrappers/etc/portage/make.conf b/wrappers/etc/portage/make.conf index 65214dc..573ead0 100644 --- a/wrappers/etc/portage/make.conf +++ b/wrappers/etc/portage/make.conf @@ -4,7 +4,7 @@ ARCH=__ARCH__ HOSTCC=__CBUILD__-gcc -ROOT=/usr/${CHOST}/ +ROOT=@GENTOO_PORTAGE_EPREFIX@/usr/${CHOST}/ ACCEPT_KEYWORDS="__ARCH__ ~__ARCH__"