blob: 2afa6f67c3bc9fb8a4999ee4d872196b4c84ada5 (
plain)
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
|
#/bin/bash
set -eu
REMOVEPERL=${REMOVEPERL:-0}
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PORTAGE_TMPDIR="/var/tmp"
if [[ $# -ne 2 ]] ; then
echo "Two arguments are required."
echo ""
echo "arg 1: TARGETVER"
echo "arg 2: TARGETMODE, Please set kernel, freebsd_userland, world."
exit 1
else
TARGETVER=$1
TARGETMODE=$2
fi
set_profile(){
echo "Setting the ${TARGETVER} profile..."
emerge --info | head -n 1 | grep clang &>/dev/null && :
if [[ $? -eq 0 ]] ; then
eselect profile set $(eselect profile list | grep "${TARGETVER}" | grep clang | awk '{print $1}' | sed 's:\[::g' | sed 's:\]::g' | tail -n 1)
export CXX="clang++ -stdlib=libc++"
else
eselect profile set $(eselect profile list | grep "${TARGETVER}" | grep -v clang | awk '{print $1}' | sed 's:\[::g' | sed 's:\]::g' | tail -n 1)
fi
}
move_makeconf(){
[[ ! -e /etc/portage ]] && mkdir -p /etc/portage
if [[ -e /etc/make.conf ]] && [[ ! -e /etc/portage/make.conf ]] ; then
echo "Moving the /etc/make.conf to /etc/portage..."
mv /etc/make.conf /etc/portage
fi
gsed -i '/LDFLAGS=/d' /etc/portage/make.conf
if [[ -e /etc/make.profile ]] && [[ ! -e /etc/portage/make.profile ]] ; then
echo "Creating the make.profile..."
ln -s ../..${PORTDIR}profiles/$(eselect profile list | grep '*' | awk '{print $2}') /etc/portage/make.profile
fi
}
update_portage(){
local dl_portage_ver="2.3.8"
echo "Updating the sys-apps/portage with a manual method..."
cd /tmp
if [[ -e "${DISTDIR}"/portage-${dl_portage_ver}.tar.bz2 ]] ; then
cp -a "${DISTDIR}/portage-${dl_portage_ver}.tar.bz2" .
else
wget -q "http://dev.gentoo.org/~dolsen/releases/portage/portage-${dl_portage_ver}.tar.bz2"
fi
tar xjf "portage-${dl_portage_ver}.tar.bz2"
cd "/tmp/portage-${dl_portage_ver}"
PYTHON_TARGETS="python2_7" bin/emerge --nodeps dev-lang/python-exec
eselect python set 1
PYTHON_TARGETS="python2_7" bin/emerge --nodeps sys-apps/portage --exclude sys-freebsd/*
eselect python set 1
}
update_bmake(){
echo "Updating the bmake..."
[[ -e /usr/local/bin/make ]] && exit 1
cd "${PORTDIR}/sys-freebsd/freebsd-ubin" && ebuild $(ls -1 freebsd-ubin-${TARGETVER}*.ebuild | tail -n 1) prepare
cd "${PORTAGE_TMPDIR}"/portage/sys-freebsd/freebsd-ubin-${TARGETVER}*/work/usr.bin/bmake
make
cp -a make /usr/local/bin/
cd "${PORTDIR}/sys-freebsd/freebsd-ubin" && ebuild $(ls -1 freebsd-ubin-${TARGETVER}*.ebuild | tail -n 1) clean
}
update_minimal(){
echo "Updating the minimal packages to upgrade the Gentoo/FreeBSD..."
emerge -u sys-devel/gcc-config --exclude sys-freebsd/*
update_bmake
emerge --nodeps sys-freebsd/freebsd-mk-defs
emerge -u '<sys-apps/findutils-4.6' --exclude sys-freebsd/*
emerge sys-devel/libtool --exclude sys-freebsd/*
# https://bugs.gentoo.org/564168
USE="-*" emerge --nodeps sys-devel/gettext --exclude sys-freebsd/*
emerge sys-devel/gettext --exclude sys-freebsd/*
USE="-acl" emerge -u app-arch/libarchive --exclude sys-freebsd/*
emerge -u sys-devel/flex sys-devel/patch sys-devel/m4 net-libs/libpcap sys-devel/gettext sys-libs/zlib dev-util/dialog --exclude sys-freebsd/*
emerge sys-devel/libtool --exclude sys-freebsd/*
if [[ -e /usr/lib/libc++.so ]] ; then
if [[ $(uname -p) == amd64 ]] && [[ ! -e /usr/lib32/librt.so ]] ; then
[[ ! -e /etc/portage/profile ]] && mkdir -p /etc/portage/profile
echo "sys-libs/libcxx abi_x86_32" >> /etc/portage/profile/package.use.mask
echo "sys-libs/libcxxrt abi_x86_32" >> /etc/portage/profile/package.use.mask
USE="internal-glib" emerge -u dev-util/pkgconfig --exclude sys-freebsd/*
USE="-nls" emerge -u cmake --exclude sys-freebsd/*
emerge --nodeps '<sys-libs/libcxx-3.9' '<sys-libs/libcxxrt-3.9' --exclude sys-freebsd/*
[[ -e /etc/portage/profile/package.use.mask ]] && gsed -i '/sys-libs\/libcxx abi_x86_32/d' /etc/portage/profile/package.use.mask
[[ -e /etc/portage/profile/package.use.mask ]] && gsed -i '/sys-libs\/libcxxrt abi_x86_32/d' /etc/portage/profile/package.use.mask
fi
fi
}
update_toolchain(){
echo "Updating the toolchains..."
if [[ $(uname -p) == amd64 ]] ; then
gsed -i "s:CHOST=.*:CHOST=\"x86_64-gentoo-freebsd${TARGETVER}\":g" /etc/portage/make.conf
else
gsed -i "s:CHOST=.*:CHOST=\"i686-gentoo-freebsd${TARGETVER}\":g" /etc/portage/make.conf
fi
# https://bugs.gentoo.org/629128
[[ ! -e /etc/portage/package.unmask ]] && mkdir -p /etc/portage/package.unmask
echo "sys-devel/binutils" > /etc/portage/package.unmask/binutils-oldversion
emerge -u '<sys-devel/binutils-2.28' --exclude sys-freebsd/*
emerge -u sys-devel/gcc-config --exclude sys-freebsd/*
emerge -u '<sys-devel/gcc-5.0' --exclude sys-freebsd/* --exclude sys-devel/binutils
gcc-config $(gcc-config -l | grep "${TARGETVER}" | awk '{print $1}' | sed 's:\[::g' | sed 's:\]::g' | tail -n 1)
env-update
source /etc/profile
emerge sys-devel/libtool --exclude sys-freebsd/*
}
update_kernel(){
echo "Updating the kernel..."
emerge -C freebsd-sources sys-freebsd/virtio-kmod sys-fs/fuse4bsd && :
emerge freebsd-sources
}
fix_dependence_issue(){
echo "" > /var/db/pkg/sys-freebsd/freebsd-lib-*/RDEPEND
rm /var/db/pkg/sys-freebsd/freebsd-lib-*/*.ebuild
echo "" > /var/db/pkg/dev-libs/glib-*/RDEPEND
echo "" > /var/db/pkg/dev-libs/glib-*/DEPEND
rm /var/db/pkg/dev-libs/glib-*/*.ebuild
rm /var/db/pkg/sys-freebsd/freebsd-libexec-*/*.ebuild
}
update_freebsd_userland(){
echo "Updating the FreeBSD userland..."
# Fixing the dependence issue:
ls -1 /var/db/pkg/sys-freebsd/freebsd-lib-9.* &>/dev/null && :
[[ $? -eq 0 ]] && fix_dependence_issue
[[ -e /usr/share/misc/windrv_stub.c ]] && rm -rf /usr/share/misc/windrv_stub.c
CC=gcc CXX=g++ CXXFLAGS="-O2 -pipe" USE=build emerge -u freebsd-bin freebsd-lib freebsd-mk-defs freebsd-pam-modules freebsd-sbin freebsd-share freebsd-sources freebsd-ubin freebsd-usbin
emerge freebsd-share
if type -P clang &> /dev/null ; then
emerge dev-util/re2c
emerge --nodeps '<sys-libs/libcxxrt-3.9' --exclude sys-freebsd/*
emerge --nodeps '<sys-libs/libcxx-3.9' --exclude sys-freebsd/*
CMAKE_MAKEFILE_GENERATOR=emake CC=gcc CXX=g++ CXXFLAGS="-O2 -pipe" emerge -u '<sys-devel/llvm-4.0' '<sys-devel/clang-4.0' --exclude sys-freebsd/*
CMAKE_MAKEFILE_GENERATOR=emake emerge sys-devel/llvm sys-devel/clang sys-libs/libcxxrt sys-libs/libcxx --exclude sys-freebsd/*
fi
emerge freebsd-bin freebsd-lib freebsd-mk-defs freebsd-pam-modules freebsd-sbin freebsd-share freebsd-sources freebsd-ubin freebsd-usbin
[[ -e /usr/local/bin/make ]] && rm /usr/local/bin/make
env-update
source /etc/profile
}
post_freebsd_userland(){
echo "Updating the minimal tools..."
emerge sys-devel/libtool app-admin/eselect
emerge sys-apps/portage
}
remove_perl(){
echo "Removing and re-installing the dev-lang/perl..."
emerge -C dev-lang/perl
emerge -C dev-perl/* perl-core/* virtual/perl*
emerge dev-lang/perl
emerge dev-perl/Text-Unidecode dev-perl/Unicode-EastAsianWidth dev-perl/XML-Parser
rm -rf "${PORTAGE_TMPDIR}"/portage/dev-perl/libintl-perl*
cd "${PORTDIR}/dev-perl/libintl-perl" && ebuild $(ls -1 libintl-perl-*.ebuild | tail -n 1) clean prepare
gsed -i 's:-liconv::g' "${PORTAGE_TMPDIR}"/portage/dev-perl/libintl-perl-*/work/libintl-perl-*/gettext_xs/Makefile.PL
ebuild $(ls -1 libintl-perl-*.ebuild | tail -n 1) merge clean
}
emerge_world(){
echo "Updating all packages... It takes a lot of time."
emerge sys-devel/libtool
emerge -C dev-lang/python:3.3 && :
gsed -i '/python3.3/d' /etc/python-exec/python-exec.conf
USE="internal-glib" emerge -u dev-util/pkgconfig
emerge dev-libs/libxml2
emerge dev-libs/libxslt app-arch/libarchive dev-libs/glib
emerge -u sys-devel/gcc
emerge -C \<$(emerge -pq --nodeps sys-devel/gcc --exclude sys-freebsd/* | grep ebuild | awk '{print $4}') && :
gcc-config $(gcc-config -l | grep "${TARGETVER}" | awk '{print $1}' | sed 's:\[::g' | sed 's:\]::g' | tail -n 1)
source /etc/profile
emerge -e @world --exclude dev-perl/libintl-perl
emerge -C dev-lang/python:3.2 && :
emerge -C '<sys-devel/binutils-2.28.1' && :
emerge @preserved-rebuild
emerge dev-perl/libintl-perl
emerge sys-apps/portage
}
cleanup(){
emerge sys-devel/libtool app-admin/eselect
echo "done!"
}
case "${TARGETMODE}" in
"kernel" )
set_profile
move_makeconf
update_portage
update_minimal
update_toolchain
update_kernel
;;
"kernelonly" ) update_kernel ;;
"freebsd_userland" )
update_freebsd_userland
post_freebsd_userland
;;
"world" )
[[ ${REMOVEPERL} -ne 0 ]] && remove_perl
emerge_world
cleanup
;;
* )
echo "Please set the argument:"
echo "kernel, freebsd_userland, world."
exit 1
;;
esac
|