This repository was archived by the owner on Jan 15, 2020. It is now read-only.
forked from stormos-next/build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-portage
246 lines (217 loc) · 6.21 KB
/
bootstrap-portage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/bin/sh
PORTDIR=/usr/portage
DISTDIR=${PORTDIR}/distfiles
PORTAGE_TMPDIR=/var/tmp
PORTAGE_VER=2.1.11.52
PYTHON_VER=2.7.2
echo "Going to try to boostrap python / portage if needed."
echo "Python ${PYTHON_VER}"
echo "Portage ${PORTAGE_VER}"
echo
for n in PORTDIR DISTDIR PORTAGE_TMPDIR ; do
eval v=\$$n
echo "${n} = ${v}"
done
echo
echo "Press return to continue or CTRL+C to abort ..."
read
mkdir -p "${DISTDIR}"
die() {
[ $# -gt 0 ] && cat "$1"
exit 1
}
eerror() {
echo "Error: $@" >&2
}
econf() {
set -- \
${ECONF_SOURCE:-.}/configure \
CC='/opt/gcc/4.4.4/bin/gcc' \
CXX='/opt/gcc/4.4.4/bin/g++' \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--datadir=/usr/share \
--sysconfdir=/etc \
--localstatedir=/var/lib "$@"
echo "$@"
"$@" >& .config.log || die .config.log
}
emake() {
set -- make "$@"
echo "$@"
"$@" >& .build.log || die .build.log
}
src_fetch() {
PN=$1
PV=$2
P="${PN}-${PV}"
eval A=$3
echo "bootstrapping ${P}"
if [ ! -e "${DISTDIR}/${A}" ] ; then
eval wget -P "${DISTDIR}" $4/${A}
fi
}
src_unpack() {
export S="${PORTAGE_TMPDIR}/${P}"
rm -rf "${S}"
mkdir -p "${S}"
cd "${S}"
case ${A} in
*bz2) tar -jxf "${DISTDIR}"/${A} || die ;;
*gz) tar -zxf "${DISTDIR}"/${A} || die ;;
*) die ;;
esac
cd "${S}"/*/
S=${PWD}
}
######################
# bootstrap python
######################
if [ ! -x /usr/bin/python ] ; then
src_fetch python ${PYTHON_VER} 'Python-${PV}.tar.bz2' 'http://www.python.org/ftp/python/${PV%_*}'
src_unpack
export PYTHON_DISABLE_MODULES="readline pyexpat dbm gdbm bsddb _curses _curses_panel _tkinter"
export PYTHON_DISABLE_SSL=1
econf \
--enable-unicode=ucs4 \
--with-fpectl \
--enable-shared \
--disable-ipv6 \
--with-threads \
--with-cxx=no
emake
emake altinstall
ln -s python`expr substr ${PV} 1 3` /usr/bin/python
else
echo "python seems to be up-to-date; skipping"
echo "rm /usr/bin/python to force"
fi
######################
# bootstrap portage
######################
if [ ! -x /usr/bin/emerge ] ; then
src_fetch portage ${PORTAGE_VER} '${P}.tar.bz2' http://distfiles.gentoo.org/distfiles
src_unpack
dodir() { mkdir -p "$@" ; }
keepdir() { dodir "$@" ; }
insinto() { INSDESTTREE=$1 ; }
doins() { cp -p "$@" "$INSDESTTREE/" || die ; }
newins() { cp -p "$1" "$INSDESTTREE/$2" || die ; }
exeinto() { EXEDESTTREE=$1 ; }
doexe() {
for exe in $@; do
cp "$exe" "$EXEDESTTREE/" || die ;
chmod 755 "$EXEDESTTREE/"`basename $exe` || die ;
done
}
get_libdir() { echo lib ; }
dosym() { ln -sf "$@" || die ; }
dodoc() { :; }
src_install() {
local libdir=$(get_libdir)
local portage_base="/usr/${libdir}/portage"
local portage_share_config=/usr/share/portage/config
cd "${S}"/cnf
insinto /etc
doins etc-update.conf dispatch-conf.conf || die
dodir "$portage_share_config" || die
insinto "$portage_share_config"
doins "$S/cnf/make.globals" || die
newins make.conf make.conf.example || die
dosym ..${portage_share_config}/make.globals /etc/make.globals
#insinto /etc/logrotate.d
#doins "${S}"/cnf/logrotate.d/elog-save-summary || die
# BSD and OSX need a sed wrapper so that find/xargs work properly
if use userland_GNU; then
rm "${S}"/bin/ebuild-helpers/sed || die "Failed to remove sed wrapper"
fi
local x symlinks files
cd "$S" || die "cd failed"
for x in $(find bin -type d) ; do
dodir $portage_base/$x || die "dodir failed"
exeinto $portage_base/$x || die "exeinto failed"
cd "$S"/$x || die "cd failed"
files=$(find . -mindepth 1 -maxdepth 1 -type f ! -type l)
if [ -n "$files" ] ; then
doexe $files || die "doexe failed"
fi
symlinks=$(find . -mindepth 1 -maxdepth 1 -type l)
if [ -n "$symlinks" ] ; then
cp -p $symlinks "$D$portage_base/$x" || die "cp failed"
fi
done
cd "$S" || die "cd failed"
for x in $(find pym/* -type d | grep -v "pym/portage/tests") ; do
dodir $portage_base/$x || die "dodir failed"
insinto $portage_base/$x || die "insinto failed"
cd "$S"/$x || die "cd failed"
# __pycache__ directories contain no py files
[[ "*.py" != $(echo *.py) ]] || continue
doins *.py || die "doins failed"
symlinks=$(find . -mindepth 1 -maxdepth 1 -type l)
if [ -n "$symlinks" ] ; then
cp -p $symlinks "$D$portage_base/$x" || die "cp failed"
fi
done
# We install some minimal tests for use as a preinst sanity check.
# These tests must be able to run without a full source tree and
# without relying on a previous portage instance being installed.
cd "$S" || die "cd failed"
dodir $portage_base/pym/portage/tests || die
exeinto $portage_base/pym/portage/tests || die
doexe pym/portage/tests/runTests || die
insinto $portage_base/pym/portage/tests || die
doins pym/portage/tests/*.py || die
dodir $portage_base/pym/portage/tests/lint || die
insinto $portage_base/pym/portage/tests/lint || die
doins pym/portage/tests/lint/*.py || die
doins pym/portage/tests/lint/__test__ || die
# Symlinks to directories cause up/downgrade issues and the use of these
# modules outside of portage is probably negligible.
for x in "${D}${portage_base}/pym/"{cache,elog_modules} ; do
[ ! -L "${x}" ] && continue
die "symlink to directory will cause upgrade/downgrade issues: '${x}'"
done
doman "${S}"/man/*.[0-9]
if use linguas_pl; then
doman -i18n=pl "${S_PL}"/man/pl/*.[0-9]
doman -i18n=pl_PL.UTF-8 "${S_PL}"/man/pl_PL.UTF-8/*.[0-9]
fi
dodoc "${S}"/{ChangeLog,NEWS,RELEASE-NOTES}
use doc && dohtml -r "${S}"/doc/*
use epydoc && dohtml -r "${WORKDIR}"/api
dodir /usr/bin
for x in ebuild egencache emerge portageq quickpkg repoman ; do
dosym ../${libdir}/portage/bin/${x} /usr/bin/${x}
done
dodir /usr/sbin
local my_syms="archive-conf
dispatch-conf
emaint
emerge-webrsync
env-update
etc-update
fixpackages
regenworld"
local x
for x in ${my_syms}; do
dosym ../${libdir}/portage/bin/${x} /usr/sbin/${x}
done
dosym env-update /usr/sbin/update-env
dosym etc-update /usr/sbin/update-etc
dodir /etc/portage
keepdir /etc/portage
}
set -x
src_install
set +x
else
echo "python seems to be up-to-date; skipping"
echo "rm /usr/bin/emerge to force"
fi
######################
# setup misc configs
######################
grep -qs ^portage: /etc/group || groupadd -g 250 portage
grep -qs ^portage: /etc/passwd || echo portage:x:250:250:portage:/var/tmp/portage:/bin/false >> /etc/passwd