/[gentoo-x86]/app-portage/prefix-chain-setup/files/prefix-chain-setup.in
Gentoo

Contents of /app-portage/prefix-chain-setup/files/prefix-chain-setup.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Oct 29 09:59:31 2010 UTC (7 years, 10 months ago) by mduft
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +3 -2 lines
File MIME type: text/plain
updated from private overlay; revbump
(Portage version: 2.1.8.3/cvs/Linux i686)

1 #!/bin/env bash
2
3 PARENT_EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
4 PARENT_CHOST="@GENTOO_PORTAGE_CHOST@"
5 CHILD_EPREFIX=
6 CHILD_PROFILE=
7 DO_MINIMAL=no
8 DO_SOURCES=no
9 PORT_TMPDIR=
10
11 #
12 # get ourselfs the functions.sh script for ebegin/eend/etc.
13 #
14 . "${PARENT_EPREFIX}"/sbin/functions.sh
15
16 for arg in "$@"; do
17 case "${arg}" in
18 --eprefix=*) CHILD_EPREFIX="${arg#--eprefix=}" ;;
19 --profile=*) CHILD_PROFILE="${arg#--profile=}" ;;
20 --sources) DO_SOURCES=yes ;;
21 --portage-tmpdir=*) PORT_TMPDIR="${arg#--portage-tmpdir=}" ;;
22
23 --help)
24 einfo "$0 usage:"
25 einfo " --eprefix=[PATH] Path to new EPREFIX to create chained to the prefix"
26 einfo " where this script is installed (${PARENT_EPREFIX})"
27 einfo " --profile=[PATH] The absolute path to the profile to use. This path"
28 einfo " must point to a directory within ${PARENT_EPREFIX}"
29 einfo " --sources inherit 'source' statements from the parent make.conf"
30 einfo " --portage-tmpdir=DIR use DIR as portage temporary directory."
31 exit 0
32 ;;
33 esac
34 done
35
36 #
37 # sanity check of given values
38 #
39
40 test -n "${CHILD_EPREFIX}" || { eerror "no eprefix argument given"; exit 1; }
41 test -d "${CHILD_EPREFIX}" && { eerror "${CHILD_EPREFIX} already exists"; exit 1; }
42 test -n "${CHILD_PROFILE}" || { eerror "no profile argument given"; exit 1; }
43 test -d "${CHILD_PROFILE}" || { eerror "${CHILD_PROFILE} does not exist"; exit 1; }
44 if test -n "${PORT_TMPDIR}"; then
45 if ! test -d "${PORT_TMPDIR}"; then
46 einfo "creating temporary directory ${PORT_TMPDIR}"
47 mkdir -p "${PORT_TMPDIR}"
48 fi
49 fi
50
51 einfo "creating chained prefix ${CHILD_EPREFIX}"
52
53 #
54 # functions needed below.
55 #
56 eend_exit() {
57 eend $1
58 [[ $1 != 0 ]] && exit 1
59 }
60
61 #
62 # create the directories required to bootstrap the least.
63 #
64 ebegin "creating directory structure"
65 (
66 set -e
67 mkdir -p "${CHILD_EPREFIX}"/etc
68 mkdir -p "${CHILD_EPREFIX}"/var/log
69 )
70 eend_exit $?
71
72 #
73 # create a make.conf and set PORTDIR and PORTAGE_TMPDIR
74 #
75 ebegin "creating make.conf"
76 (
77 set -e
78 echo "#"
79 echo "# The following values where taken from the parent prefix's"
80 echo "# environment. Feel free to adopt them as you like."
81 echo "#"
82 echo "CFLAGS=\"$(portageq envvar CFLAGS)\""
83 echo "CXXFLAGS=\"$(portageq envvar CXXFLAGS)\""
84 echo "MAKEOPTS=\"$(portageq envvar MAKEOPTS)\""
85 niceness=$(portageq envvar PORTAGE_NICENESS)
86 [[ -n ${niceness} ]] &&
87 echo "PORTAGE_NICENESS=\"${niceness}\""
88 echo "USE=\"prefix-chaining\""
89 echo
90 echo "# Mirrors from parent prefix."
91 echo "GENTOO_MIRRORS=\"$(portageq envvar GENTOO_MIRRORS)\""
92 echo
93 echo "#"
94 echo "# Below comes the chained-prefix setup. Only change things"
95 echo "# if you know exactly what you are doing!"
96 echo "# by default, only DEPEND is inherited from the parent in"
97 echo "# the chain. if you want more, make it a comma seperated"
98 echo "# list - like this: DEPEND,RDEPEND,PDEPEN - which would the"
99 echo "# all that is possible"
100 echo "#"
101 echo "PORTDIR=\"$(portageq envvar PORTDIR)\""
102 echo "SYNC=\"$(portageq envvar SYNC)\""
103 if test -z "${PORT_TMPDIR}"; then
104 case "${CHILD_PROFILE}" in
105 *winnt*) echo "PORTAGE_TMPDIR=/var/tmp" ;;
106 *) echo "PORTAGE_TMPDIR=\"${CHILD_EPREFIX}/var/tmp\"" ;;
107 esac
108 else
109 echo "PORTAGE_TMPDIR=\"${PORT_TMPDIR}\""
110 fi
111 echo "READONLY_EPREFIX=\"${PARENT_EPREFIX}:DEPEND\""
112
113 if test "${DO_SOURCES}" == "yes"; then
114 # don't fail if nothing found
115 egrep "^source .*" "${PARENT_EPREFIX}/etc/make.conf" 2>/dev/null || true
116 fi
117 ) > "${CHILD_EPREFIX}"/etc/make.conf
118 eend_exit $?
119
120 #
121 # create the make.profile symlinks.
122 #
123 ebegin "creating make.profile"
124 (
125 ln -s "${CHILD_PROFILE}" "${CHILD_EPREFIX}/etc/make.profile"
126 )
127 eend_exit $?
128
129 #
130 # adjust permissions of generated files.
131 #
132 ebegin "adjusting permissions"
133 (
134 chmod 644 "${CHILD_EPREFIX}"/etc/make.conf
135 )
136 eend_exit $?
137
138 #
139 # now merge some basics.
140 #
141 ebegin "installing required basic packages"
142 (
143 # this -pv is there to avoid the global update output, which is
144 # there on the first emerge run. (thus, just cosmetics).
145 EPREFIX="${CHILD_EPREFIX}" emerge -p1qO baselayout > /dev/null 2>&1
146
147 EPREFIX="${CHILD_EPREFIX}" emerge -1qO baselayout prefix-chain-utils
148
149 # merge with the parent's chost. this forces the use of the parent
150 # compiler, which generally would be illegal - this is an exception.
151 # This is required for example on winnt, because the wrapper has to
152 # be able to use/resolve symlinks, etc. native winnt binaries miss that
153 # ability, but interix binaries don't.
154 EPREFIX="${CHILD_EPREFIX}" CHOST="${PARENT_CHOST}" emerge -1qO gcc-config
155
156 # select the chain wrapper profile from gcc-config
157 env -i "$(type -P bash)" "${CHILD_EPREFIX}"/usr/bin/gcc-config 1
158
159 # do this _AFTER_ selecting the correct compiler!
160 EPREFIX="${CHILD_EPREFIX}" emerge -1qO libtool
161 )
162 eend_exit $?
163
164 #
165 # wow, all ok :)
166 #
167 ewarn
168 ewarn "all done. don't forget to tune ${CHILD_EPREFIX}/etc/make.conf."
169 ewarn "to enter the new prefix, run \"${CHILD_EPREFIX}/startprefix\"."
170 ewarn

  ViewVC Help
Powered by ViewVC 1.1.20