From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id A35E6138435 for ; Sat, 12 Jan 2013 20:45:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8B5F121C032; Sat, 12 Jan 2013 20:45:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BF87121C032 for ; Sat, 12 Jan 2013 20:45:09 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 496A633DB78 for ; Sat, 12 Jan 2013 17:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id D5331E4073 for ; Sat, 12 Jan 2013 17:05:58 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1358010456.deaecbb404c8a60f9aec3bc85a4fc1621a561687.vapier@gentoo> Subject: [gentoo-commits] proj/gcc-config:master commit in: / X-VCS-Repository: proj/gcc-config X-VCS-Files: Makefile gcc-config wrapper.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: deaecbb404c8a60f9aec3bc85a4fc1621a561687 X-VCS-Branch: master Date: Sat, 12 Jan 2013 17:05:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a0dba5bc-67c5-4b26-95f0-574c80f37d56 X-Archives-Hash: 3eea75b23e27766f664577caf8dab519 commit: deaecbb404c8a60f9aec3bc85a4fc1621a561687 Author: Fabian Groffen gentoo org> AuthorDate: Sat Jan 5 16:12:34 2013 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Jan 12 17:07:36 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gcc-config.git;a=commit;h=deaecbb4 make aware of EPREFIX offset prefix - changed Makefile to expand @GENTOO_EPREFIX@ for gcc-config - defined EPREFIX and EROOT in gcc-config, and used them - made wrapper look in the offset for files Signed-off-by: Fabian Groffen gentoo.org> Signed-off-by: Mike Frysinger gentoo.org> --- Makefile | 7 ++++++- gcc-config | 59 +++++++++++++++++++++++++++++++++-------------------------- wrapper.c | 14 +++++++++----- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 409d7b0..db14af9 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ +EPREFIX ?= + CFLAGS ?= -O2 -g CFLAGS += -Wall -Wextra +CPPFLAGS += '-DEPREFIX="$(EPREFIX)"' PN = gcc-config PV = git P = $(PN)-$(PV) -PREFIX = /usr +PREFIX = $(EPREFIX)/usr BINDIR = $(PREFIX)/bin SUBLIBDIR = lib LIBDIR = $(PREFIX)/$(SUBLIBDIR) @@ -21,6 +24,8 @@ clean: .gcc-config: gcc-config sed \ + -e '1s:/:$(EPREFIX)/:' \ + -e 's:@GENTOO_EPREFIX@:$(EPREFIX):g' \ -e 's:@GENTOO_LIBDIR@:$(SUBLIBDIR):g' \ -e 's:@PV@:$(PV):g' \ $< > $@ diff --git a/gcc-config b/gcc-config index 6fb9904..b4ed712 100755 --- a/gcc-config +++ b/gcc-config @@ -9,14 +9,17 @@ : ${ROOT:=/} [[ ${ROOT} != */ ]] && ROOT="${ROOT}/" [[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}" +EPREFIX="@GENTOO_EPREFIX@" +[[ ${EPREFIX} == @*@ ]] && EPREFIX="" +EROOT="${ROOT%/}${EPREFIX}/" cd / trap ":" INT QUIT TSTP argv0=${0##*/} -source /etc/init.d/functions.sh || { - echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 +source "${EPREFIX}"/etc/init.d/functions.sh || { + echo "${argv0}: Could not source ${EPREFIX}/etc/init.d/functions.sh!" 1>&2 exit 1 } esyslog() { :; } @@ -84,9 +87,9 @@ try_real_hard_to_find_CHOST() { # local varname=${1:-CHOST} - local conf=${ROOT}/etc/portage/make.conf - if [[ ! -e ${conf} && -e ${ROOT}/etc/make.conf ]] ; then - conf=${ROOT}/etc/make.conf + local conf=${EROOT}/etc/portage/make.conf + if [[ ! -e ${conf} && -e ${EROOT}/etc/make.conf ]] ; then + conf=${EROOT}/etc/make.conf fi local ret=$(source "${conf}" 2>/dev/null ; echo ${!varname}) if [[ -z ${ret} ]] ; then @@ -109,8 +112,8 @@ try_real_hard_to_find_CHOST() { # # Then we try /etc/env.d/gcc/config-${CTARGET} # - if [[ -s ${ROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then - ret=$(split_gcc_ver $(show_var CURRENT "${ROOT}"/etc/env.d/gcc/config-${CTARGET})) + if [[ -s ${EROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then + ret=$(split_gcc_ver $(show_var CURRENT "${EROOT}"/etc/env.d/gcc/config-${CTARGET})) echo ${ret% *} fi } @@ -133,7 +136,7 @@ get_chost() { if [[ -z ${CHOST} ]] ; then eerror "${argv0}: Could not get portage CHOST!" eerror "${argv0}: You should verify that CHOST is set in one of these places:" - eerror "${argv0}: - ${ROOT}/etc/portage/make.conf" + eerror "${argv0}: - ${EROOT}/etc/portage/make.conf" eerror "${argv0}: - active environment" exit 1 fi @@ -196,7 +199,7 @@ update_wrappers() { # Find the bin wrapper local wrapper for wrapper in ${GENTOO_LIBDIR} lib lib64 lib32 lib ; do - wrapper="${ROOT}usr/${wrapper}/misc/gcc-config" + wrapper="${EROOT}usr/${wrapper}/misc/gcc-config" [[ -e ${wrapper} ]] && break done @@ -222,7 +225,7 @@ update_wrappers() { # new one does not. for x in "${old_wrappers[@]}" ; do has "${x}" "${new_wrappers[@]}" && continue - rm -f "${ROOT}usr/bin/${x}" "${ROOT}usr/bin/${CTARGET}-${x}" + rm -f "${EROOT}usr/bin/${x}" "${EROOT}usr/bin/${CTARGET}-${x}" done # For all toolchains, we want to create the fully qualified @@ -259,19 +262,19 @@ update_wrappers() { # Now do the actual wrapper copy with paths to the reference binary if [[ -x ${ref} ]] ; then - atomic_cp "${wrapper}" "${ROOT}usr/bin" "${x}" "${ref}" + atomic_cp "${wrapper}" "${EROOT}usr/bin" "${x}" "${ref}" else ewarn "double insanity with ${x} and ${ref}" # Make sure we have no stale wrappers - rm -f "${ROOT}usr/bin/${x}" + rm -f "${EROOT}usr/bin/${x}" fi done # legacy cruft, make sure we dont leave it laying around #143205 - rm -f "${ROOT}usr/bin/${CTARGET}-cc" "${ROOT}usr/bin"/{${CTARGET}-,}g{cc,++}{32,64} + rm -f "${EROOT}usr/bin/${CTARGET}-cc" "${EROOT}usr/bin"/{${CTARGET}-,}g{cc,++}{32,64} # install the canonical cpp wrapper if ! is_cross_compiler ; then - atomic_cp "${wrapper}" "${ROOT}lib" "cpp" "${ROOT}usr/bin/cpp" + atomic_cp "${wrapper}" "${EROOT}lib" "cpp" "${EROOT}usr/bin/cpp" fi } @@ -301,11 +304,11 @@ handle_split_usr() { LDPATH=${LDPATH%%:*} # If /usr isn't a sep mount, then don't bother with linking stuff. - if ln "${ROOT}/${LDPATH}/libgcc.a" "${ROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then - rm -f "${ROOT}"/lib/.gcc.config.$$ - if [[ -n $(find "${ROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]] ; then + if ln "${ROOT}/${LDPATH}/libgcc.a" "${EROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then + rm -f "${EROOT}"/lib/.gcc.config.$$ + if [[ -n $(find "${EROOT}"/lib*/lib{gcc_s,unwind}.so* 2>/dev/null) ]] ; then # If we previously had stuff in /, make sure ldconfig gets re-run. - rm -f "${ROOT}"/lib*/lib{gcc_s,unwind}.so* + rm -f "${EROOT}"/lib*/lib{gcc_s,unwind}.so* return 1 fi return 0 @@ -317,7 +320,7 @@ handle_split_usr() { # Only bother with this stuff for the native ABI. We assume the user # doesn't have critical binaries for non-native ABIs which is fair. local gcclib - local libdir="${ROOT}${GENTOO_LIBDIR}" + local libdir="${EROOT}${GENTOO_LIBDIR}" mkdir -p "${libdir}"/.gcc.config.new || return 0 # !?!?! for gcclib in gcc_s unwind ; do # This assumes that we always have the .so symlink, @@ -343,7 +346,7 @@ switch_profile() { # Make sure we have write access to the dirs. Do not require `root` # so that we work with prefix/cross/etc... setups that run as user. - [[ ! -w ${ROOT} ]] && die "need write access to ${ROOT}" + [[ ! -w ${EROOT} ]] && die "need write access to ${EROOT}" if is_cross_compiler ; then ebegin "Switching cross-compiler to ${CC_COMP}" @@ -429,7 +432,7 @@ switch_profile() { local x libdir pkgconfdir local mver=${CC_COMP_VERSION:0:3} for libdir in ${MULTIOSDIRS//:/ } ; do - pkgconfdir="${ROOT}/usr/lib/${libdir}/pkgconfig" + pkgconfdir="${EROOT}/usr/lib/${libdir}/pkgconfig" for x in "" "-${mver}" ; do x="${pkgconfdir}/libgcj${x}.pc" if [[ -e ${pkgconfdir}/libgcj-${CC_COMP_VERSION}.pc ]] ; then @@ -477,7 +480,7 @@ switch_profile() { ewarn "If you intend to use the gcc from the new profile in an already" ewarn "running shell, please remember to do:" echo - ewarn " . /etc/profile" + ewarn " . ${EPREFIX}/etc/profile" echo fi @@ -655,7 +658,7 @@ DOIT="" FORCE="no" CC_COMP= -ENV_D="${ROOT}etc/env.d" +ENV_D="${EROOT}etc/env.d" GCC_ENV_D="${ENV_D}/gcc" for x in "$@" ; do @@ -786,7 +789,11 @@ if [[ -z ${CC_COMP} ]] ; then fi if [[ ${DOIT} != "get_current_profile" ]] ; then - GCC_LIB=$(get_lib_path | awk -F/ '{ print "/"$2"/"$3"/"$4"/" }') + GCC_LIB=$( + get_lib_path | \ + ${SED} -e "s|${EPREFIX:-/}/*|/|g" | \ + awk -F/ '{ print "/"$2"/"$3"/"$4"/" }' + ) # For people who insist on using funky version strings ("4.6.x" # rather than "4.6.2"), allow them to manually specify it. @@ -799,11 +806,11 @@ if [[ ${DOIT} != "get_current_profile" ]] ; then CC_COMP_TARGET=${CC_COMP%-${CC_COMP_VERSION}*} fi - if [[ ! -d ${ROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]]; then + if [[ ! -d ${EROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]]; then CC_COMP_VERSION=${CC_COMP_VERSION%-*} fi - if [[ ! -d ${ROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]] || \ + if [[ ! -d ${EROOT}/${GCC_LIB}/${CC_COMP_TARGET}/${CC_COMP_VERSION} ]] || \ [[ ! -f ${GCC_ENV_D}/${CC_COMP} ]] then eerror "${argv0}: Profile does not exist or invalid setting for ${GCC_ENV_D}/${CC_COMP}" 1>&2 diff --git a/wrapper.c b/wrapper.c index 65e5317..50c35a4 100644 --- a/wrapper.c +++ b/wrapper.c @@ -21,8 +21,12 @@ #include #include -#define GCC_CONFIG "/usr/bin/gcc-config" -#define ENVD_BASE "/etc/env.d/05gcc" +#ifndef EPREFIX +# define EPREFIX "" +#endif + +#define GCC_CONFIG EPREFIX "/usr/bin/gcc-config" +#define ENVD_BASE EPREFIX "/etc/env.d/05gcc" #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) @@ -146,7 +150,7 @@ static int find_target_in_envd(struct wrapper_data *data, int cross_compile) /* for the sake of speed, we'll keep a symlink around for * the native compiler. #190260 */ - snprintf(envd_file, sizeof(envd_file)-1, "/etc/env.d/gcc/.NATIVE"); + snprintf(envd_file, sizeof(envd_file)-1, EPREFIX "/etc/env.d/gcc/.NATIVE"); } else { char *ctarget, *end = strrchr(data->name, '-'); if (end == NULL) @@ -289,8 +293,8 @@ int main(int argc, char *argv[]) data.name = wrapper_aliases[i].target; /* What is the full name of our wrapper? */ - data.fullname = xmalloc(strlen(data.name) + sizeof("/usr/bin/") + 1); - sprintf(data.fullname, "/usr/bin/%s", data.name); + data.fullname = xmalloc(strlen(data.name) + sizeof(EPREFIX "/usr/bin/") + 1); + sprintf(data.fullname, EPREFIX "/usr/bin/%s", data.name); find_wrapper_target(&data);