Gentoo Archives: gentoo-embedded

From: Joakim Tjernlund <joakim.tjernlund@×××××××××.se>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] crossdev improvements
Date: Sat, 25 Sep 2010 18:05:53
Message-Id: OF85935B08.21D9E6A7-ONC12577A9.005E326E-C12577A9.005E6E85@transmode.se
In Reply to: Re: [gentoo-embedded] crossdev improvements by Mike Frysinger
1 Mike Frysinger <vapier@g.o> wrote on 2010/09/25 07:37:49:
2 >
3 > On Friday, September 24, 2010 13:42:04 Joakim Tjernlund wrote:
4 > > Mike Frysinger <vapier@g.o> wrote on 2010/09/24 19:01:26:
5 > > > On Friday, September 24, 2010 12:01:21 Joakim Tjernlund wrote:
6 > > > > - make crossdev respect PORTAGE_CONFIGROOT. We use our own portage
7 > > > >
8 > > > > tree for our pkgs, including the compiler, as we want to be able
9 > > > > to recreate/rebuild the same sw versions in the future.
10 > > >
11 > > > i dont know what this means. crossdev doesnt touch PORTAGE_CONFIGROOT at
12 > > > all.
13 > >
14 > > Exactly, it uses hardcoded paths to /etc et. all instead of
15 > > PORTAGE_CONFIGROOT/etc
16 >
17 > so you're talking about the /etc/portage/ file setup. you should be explicit
18 > in your examples :P.
19 >
20 > i'd file a bug about this.
21 > -mike
22
23 Until then, here is an initial hack(untested), against 20100814:
24
25 From 50337e535b7dff4fb473db097483ba5ffe7b355e Mon Sep 17 00:00:00 2001
26 From: Joakim Tjernlund <Joakim.Tjernlund@×××××××××.se>
27 Date: Sat, 25 Sep 2010 19:07:28 +0200
28 Subject: [PATCH] Initial support for PORTAGE_CONFIGROOT
29
30 ---
31 crossdev-20100814/crossdev | 32 +++++++++++++++++---------------
32 1 files changed, 17 insertions(+), 15 deletions(-)
33
34 diff --git a/crossdev-20100814/crossdev b/crossdev-20100814/crossdev
35 index 54a6ed7..fc9b89e 100755
36 --- a/crossdev-20100814/crossdev
37 +++ b/crossdev-20100814/crossdev
38 @@ -12,7 +12,8 @@ if [[ ${ROOT:-/} != "/" ]] ; then
39 exit 2
40 fi
41
42 -source /etc/init.d/functions.sh || exit 1
43 +setup_portage_vars
44 +source ${PORTAGE_CONFIGROOT}/etc/init.d/functions.sh || exit 1
45 esyslog() { :; }
46 die() {
47 echo
48 @@ -235,6 +236,7 @@ parse_target() {
49 }
50
51 setup_portage_vars() {
52 + PORTAGE_CONFIGROOT=$(portageq envvar PORTAGE_CONFIGROOT)
53 PORTDIR_OVERLAYS=$(portageq envvar PORTDIR_OVERLAY)
54 PORTDIR_OVERLAY=${PORTDIR_OVERLAYS%% *}
55 PORTDIR=$(portageq envvar PORTDIR)
56 @@ -253,9 +255,9 @@ uninstall() {
57
58 [[ -d ${PORTDIR_OVERLAY}/cross-${CTARGET} ]] \
59 && rm -r ${PORTDIR_OVERLAY}/cross-${CTARGET}
60 - sed -i -e "/^cross-${CTARGET}$/d" /etc/portage/categories
61 + sed -i -e "/^cross-${CTARGET}$/d" ${PORTAGE_CONFIGROOT}/etc/portage/categories
62 for f in package.{mask,keywords,use} ; do
63 - f="/etc/portage/${f}"
64 + f="${PORTAGE_CONFIGROOT}/etc/portage/${f}"
65 if [[ -d ${f} ]] ; then
66 rm -f "${f}"/cross-${CTARGET}
67 rmdir "${f}" 2>/dev/null
68 @@ -263,8 +265,8 @@ uninstall() {
69 sed -i -e "/cross-${CTARGET}\//d" "${f}"
70 fi
71 done
72 - rm -rf /etc/portage/env/cross-${CTARGET}
73 - rmdir /etc/portage/env 2>/dev/null
74 + rm -rf ${PORTAGE_CONFIGROOT}/etc/portage/env/cross-${CTARGET}
75 + rmdir ${PORTAGE_CONFIGROOT}/etc/portage/env 2>/dev/null
76
77 rmdir /var/db/pkg/cross-${CTARGET} 2>/dev/null
78 if [[ -d /var/db/pkg/cross-${CTARGET} ]] ; then
79 @@ -298,7 +300,7 @@ uninstall() {
80 [[ ${ans} == [Yy]* ]] && rm -rf "${d}"
81 fi
82 done
83 - rm -f /etc/env.d/{binutils,gcc}/config-${CTARGET}
84 + rm -f ${PORTAGE_CONFIGROOT}/etc/env.d/{binutils,gcc}/config-${CTARGET}
85 [[ -e /var/db/pkg/cross-${CTARGET} ]] && rmdir /var/db/pkg/cross-${CTARGET}
86
87 exit 0
88 @@ -445,14 +447,14 @@ fi
89
90 # grab user settings
91 for v in ABI UCLIBC_CPU USE BVER GVER KVER LVER STAGE CFLAGS LDFLAGS ASFLAGS ; do
92 - if [[ -e /etc/portage/crossdev/${CTARGET}/${v} ]] ; then
93 + if [[ -e ${PORTAGE_CONFIGROOT}/etc/portage/crossdev/${CTARGET}/${v} ]] ; then
94 # yes, quotes are needed in this instance (export $var="...")
95 - export ${v}="$(</etc/portage/crossdev/${CTARGET}/${v})"
96 + export ${v}="$(<${PORTAGE_CONFIGROOT}/etc/portage/crossdev/${CTARGET}/${v})"
97 einfo "Restoring user setting '${v}' to '${!v}'"
98 fi
99 - if [[ -e /etc/portage/crossdev/${CTARGET}/env ]] ; then
100 + if [[ -e ${PORTAGE_CONFIGROOT}/etc/portage/crossdev/${CTARGET}/env ]] ; then
101 einfo "Restoring generic user env settings"
102 - source /etc/portage/crossdev/${CTARGET}/env
103 + source ${PORTAGE_CONFIGROOT}/etc/portage/crossdev/${CTARGET}/env
104 fi
105 done
106
107 @@ -600,12 +602,12 @@ set_portage() {
108 set_env ${pkg}
109 }
110
111 -mkdir -p /etc/portage
112 -check_trailing_newline /etc/portage/categories
113 -grep -qs "^cross-${CTARGET}$" /etc/portage/categories \
114 - || echo cross-${CTARGET} >> /etc/portage/categories
115 +mkdir -p ${PORTAGE_CONFIGROOT}/etc/portage
116 +check_trailing_newline ${PORTAGE_CONFIGROOT}/etc/portage/categories
117 +grep -qs "^cross-${CTARGET}$" ${PORTAGE_CONFIGROOT}/etc/portage/categories \
118 + || echo cross-${CTARGET} >> ${PORTAGE_CONFIGROOT}/etc/portage/categories
119 mkdir -p "${PORTDIR_OVERLAY}"/cross-${CTARGET}
120 -cd /etc/portage
121 +cd ${PORTAGE_CONFIGROOT}/etc/portage
122 for f in package.{keywords,mask,use} ; do
123 [[ -f ${f} ]] && continue
124 mkdir -p ${f}
125 --
126 1.7.2.2

Replies

Subject Author
Re: [gentoo-embedded] crossdev improvements Mike Frysinger <vapier@g.o>