1 |
commit: f3d246e24b5b1da80b4444204a989957f155c1a2 |
2 |
Author: Yuta SATOH <nigoro.dev <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Dec 29 01:35:36 2017 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Dec 29 02:04:21 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f3d246e2 |
7 |
|
8 |
detect and use a configured sed command for Gentoo/FreeBSD # 363577 |
9 |
|
10 |
Relocated the main.py code changes location: Brian Dolbec <dolsen <AT> gentoo.org |
11 |
Bug url: https://bugs.gentoo.org/363577 |
12 |
|
13 |
catalyst/defaults.py | 1 + |
14 |
catalyst/main.py | 6 ++++++ |
15 |
targets/stage1/stage1-chroot.sh | 11 +++++------ |
16 |
targets/support/bootloader-setup.sh | 2 +- |
17 |
targets/support/chroot-functions.sh | 10 +++++----- |
18 |
targets/support/create-iso.sh | 6 +++--- |
19 |
targets/support/kmerge.sh | 8 ++++---- |
20 |
targets/support/livecdfs-update.sh | 36 ++++++++++++++++++------------------ |
21 |
8 files changed, 43 insertions(+), 37 deletions(-) |
22 |
|
23 |
diff --git a/catalyst/defaults.py b/catalyst/defaults.py |
24 |
index ed5766d6..f2fe29df 100644 |
25 |
--- a/catalyst/defaults.py |
26 |
+++ b/catalyst/defaults.py |
27 |
@@ -62,6 +62,7 @@ confdefaults={ |
28 |
"PythonDir": "./catalyst", |
29 |
"repo_basedir": REPODIR[:], |
30 |
"repo_name": MAINREPO[:], |
31 |
+ "sed": "sed", |
32 |
"sharedir": "/usr/share/catalyst", |
33 |
"shdir": "/usr/share/catalyst/targets/", |
34 |
"snapshot_cache": "/var/tmp/catalyst/snapshot_cache", |
35 |
|
36 |
diff --git a/catalyst/main.py b/catalyst/main.py |
37 |
index 2d2faada..01c456ea 100644 |
38 |
--- a/catalyst/main.py |
39 |
+++ b/catalyst/main.py |
40 |
@@ -408,6 +408,12 @@ def _main(parser, opts): |
41 |
hash_map.hash_map[conf_values['hash_function']].cmd, |
42 |
conf_values['hash_function']) |
43 |
|
44 |
+ # detect GNU sed |
45 |
+ for sed in ('/usr/bin/gsed', '/bin/sed', '/usr/bin/sed'): |
46 |
+ if os.path.exists(sed): |
47 |
+ conf_values["sed"] = sed |
48 |
+ break |
49 |
+ |
50 |
addlargs={} |
51 |
|
52 |
if myspecfile: |
53 |
|
54 |
diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh |
55 |
index 1b0aa08b..0caf49ee 100755 |
56 |
--- a/targets/stage1/stage1-chroot.sh |
57 |
+++ b/targets/stage1/stage1-chroot.sh |
58 |
@@ -48,15 +48,14 @@ else |
59 |
fi |
60 |
|
61 |
# Clear USE |
62 |
-[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"${BINDIST} ${USE}\"/d" ${clst_make_conf} |
63 |
- |
64 |
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^USE=\"${BINDIST} ${USE}\"/d" ${clst_make_conf} |
65 |
make_destpath /tmp/stage1root |
66 |
|
67 |
## START BUILD |
68 |
# First, we drop in a known-good baselayout |
69 |
[ -e ${clst_make_conf} ] && echo "USE=\"${USE} -build\"" >> ${clst_make_conf} |
70 |
run_merge "--oneshot --nodeps sys-apps/baselayout" |
71 |
-sed -i "/USE=\"${USE} -build\"/d" ${clst_make_conf} |
72 |
+${clst_sed} -i "/USE=\"${USE} -build\"/d" ${clst_make_conf} |
73 |
|
74 |
# Now, we install our packages |
75 |
if [ -e ${clst_make_conf} ]; then |
76 |
@@ -75,10 +74,10 @@ run_merge "--oneshot ${clst_buildpkgs}" |
77 |
# Why are we removing these? Don't we need them for final make.conf? |
78 |
for useexpand in ${clst_HOSTUSEEXPAND}; do |
79 |
x="clst_${useexpand}" |
80 |
- sed -i "/${useexpand}=\"${!x}\"/d" \ |
81 |
+ ${clst_sed} -i "/${useexpand}=\"${!x}\"/d" \ |
82 |
${clst_make_conf} |
83 |
done |
84 |
|
85 |
# Clear USE |
86 |
-[ -e ${clst_make_conf} ] && sed -i -e "/^CATALYST_USE/d" ${clst_make_conf} |
87 |
-[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"/s/\${CATALYST_USE} ${USE} ${BOOTSTRAP_USE}//" ${clst_make_conf} |
88 |
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^CATALYST_USE/d" ${clst_make_conf} |
89 |
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^USE=\"/s/\${CATALYST_USE} ${USE} ${BOOTSTRAP_USE}//" ${clst_make_conf} |
90 |
|
91 |
diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh |
92 |
index d9e2620e..ffe7be2f 100755 |
93 |
--- a/targets/support/bootloader-setup.sh |
94 |
+++ b/targets/support/bootloader-setup.sh |
95 |
@@ -79,7 +79,7 @@ case ${clst_hostarch} in |
96 |
echo "message=/boot/boot.msg" >> ${icfg} |
97 |
|
98 |
# Here is where I fix up the boot.msg file. |
99 |
- sed -e 's/ARCH/PowerPC/' \ |
100 |
+ ${clst_sed} -e 's/ARCH/PowerPC/' \ |
101 |
-e 's/HARDWARE/Apple and IBM hardware/' \ |
102 |
-i $kmsg |
103 |
|
104 |
|
105 |
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh |
106 |
index e44de61b..84d90fe9 100755 |
107 |
--- a/targets/support/chroot-functions.sh |
108 |
+++ b/targets/support/chroot-functions.sh |
109 |
@@ -101,7 +101,7 @@ setup_myfeatures(){ |
110 |
else |
111 |
clst_root_path=/ run_merge --oneshot --noreplace sys-devel/distcc || exit 1 |
112 |
fi |
113 |
- sed -i '/USE="${USE} -avahi -gtk -gnome"/d' ${clst_make_conf} |
114 |
+ ${clst_sed} -i '/USE="${USE} -avahi -gtk -gnome"/d' ${clst_make_conf} |
115 |
mkdir -p /etc/distcc |
116 |
echo "${clst_distcc_hosts}" > /etc/distcc/hosts |
117 |
|
118 |
@@ -201,7 +201,7 @@ setup_pkgmgr(){ |
119 |
echo "Adding USE=\"\${USE} $1\" to make.conf for portage build" |
120 |
[ -e "${clst_make_conf}" ] && echo "USE=\"\${USE} $1\"" >> "${clst_make_conf}" |
121 |
run_merge --oneshot --update --newuse sys-apps/portage |
122 |
- sed -i "/USE=\"\${USE} $1\"/d" "${clst_make_conf}" |
123 |
+ ${clst_sed} -i "/USE=\"\${USE} $1\"/d" "${clst_make_conf}" |
124 |
else |
125 |
run_merge --oneshot --update --newuse sys-apps/portage |
126 |
fi |
127 |
@@ -256,8 +256,8 @@ cleanup_stages() { |
128 |
|
129 |
# Remove bindist from use |
130 |
# this is handled independantly in stage2, changes here should be mirrored there |
131 |
- sed -i "/USE=\"\${USE} bindist\"/d" "${clst_make_conf}" |
132 |
- sed -i "/USE=\"bindist\"/d" "${clst_make_conf}" |
133 |
+ ${clst_sed} -i "/USE=\"\${USE} bindist\"/d" "${clst_make_conf}" |
134 |
+ ${clst_sed} -i "/USE=\"bindist\"/d" "${clst_make_conf}" |
135 |
|
136 |
[ "${clst_target}" != "tinderbox" ] && rm -f /var/log/emerge.log /var/log/portage/elog/* |
137 |
} |
138 |
@@ -275,7 +275,7 @@ die() { |
139 |
|
140 |
make_destpath() { |
141 |
# ROOT is / by default, so remove any ROOT= settings from make.conf |
142 |
- sed -i '/ROOT=/d' ${clst_make_conf} |
143 |
+ ${clst_sed} -i '/ROOT=/d' ${clst_make_conf} |
144 |
export ROOT=/ |
145 |
if [ "${1}" != "/" -a -n "${1}" ] |
146 |
then |
147 |
|
148 |
diff --git a/targets/support/create-iso.sh b/targets/support/create-iso.sh |
149 |
index 723f8998..b7c4a7aa 100755 |
150 |
--- a/targets/support/create-iso.sh |
151 |
+++ b/targets/support/create-iso.sh |
152 |
@@ -95,7 +95,7 @@ fi |
153 |
isoroot_checksum() { |
154 |
echo "Creating checksums for all files included in the iso, please wait..." |
155 |
find "${clst_target_path}" -type f ! -name 'isoroot_checksums' ! -name 'isolinux.bin' -exec sha512sum {} + > "${clst_target_path}"/isoroot_checksums |
156 |
- sed -i "s#${clst_target_path}/\?##" "${clst_target_path}"/isoroot_checksums |
157 |
+ ${clst_sed} -i "s#${clst_target_path}/\?##" "${clst_target_path}"/isoroot_checksums |
158 |
} |
159 |
|
160 |
run_mkisofs() { |
161 |
@@ -211,10 +211,10 @@ case ${clst_hostarch} in |
162 |
if [ -f "${clst_target_path}/ppc/bootinfo.txt" ] |
163 |
then |
164 |
echo "bootinfo.txt found .. updating it" |
165 |
- sed -i -e \ |
166 |
+ ${clst_sed} -i -e \ |
167 |
's#^<description>.*</description>$#<description>'"${clst_iso_volume_id}"'</description>#' \ |
168 |
"${clst_target_path}/ppc/bootinfo.txt" |
169 |
- sed -i -e \ |
170 |
+ ${clst_sed} -i -e \ |
171 |
's#^<os-name>.*</os-name>$#<os-name>'"${clst_iso_volume_id}"'</os-name>#' \ |
172 |
"${clst_target_path}/ppc/bootinfo.txt" |
173 |
fi |
174 |
|
175 |
diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh |
176 |
index f29cd385..b8593ada 100755 |
177 |
--- a/targets/support/kmerge.sh |
178 |
+++ b/targets/support/kmerge.sh |
179 |
@@ -249,7 +249,7 @@ then |
180 |
if [ ! "${clst_kextraversion}" = "" ] |
181 |
then |
182 |
echo "Setting extraversion to ${clst_kextraversion}" |
183 |
- sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile |
184 |
+ ${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile |
185 |
echo ${clst_kextraversion} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION |
186 |
else |
187 |
touch /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION |
188 |
@@ -266,7 +266,7 @@ $(portageq contents / $(portageq best_visible / "${clst_ksource}" 2>/dev/null) 2 |
189 |
if [ ! "${clst_kextraversion}" = "" ] |
190 |
then |
191 |
echo "Setting extraversion to ${clst_kextraversion}" |
192 |
- sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile |
193 |
+ ${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile |
194 |
fi |
195 |
fi |
196 |
|
197 |
@@ -279,12 +279,12 @@ make_destpath |
198 |
|
199 |
|
200 |
build_kernel |
201 |
-sed -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf} |
202 |
+${clst_sed} -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf} |
203 |
# grep out the kernel version so that we can do our modules magic |
204 |
VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'` |
205 |
PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'` |
206 |
SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'` |
207 |
-EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"` |
208 |
+EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | ${clst_sed} -e "s/EXTRAVERSION =//" -e "s/ //g"` |
209 |
clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV} |
210 |
|
211 |
unset USE |
212 |
|
213 |
diff --git a/targets/support/livecdfs-update.sh b/targets/support/livecdfs-update.sh |
214 |
index 31cdf04e..2c551b42 100755 |
215 |
--- a/targets/support/livecdfs-update.sh |
216 |
+++ b/targets/support/livecdfs-update.sh |
217 |
@@ -7,7 +7,7 @@ source /tmp/chroot-functions.sh |
218 |
# Allow root logins to our CD by default |
219 |
if [ -e /etc/ssh/sshd_config ] |
220 |
then |
221 |
- sed -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' \ |
222 |
+ ${clst_sed} -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' \ |
223 |
/etc/ssh/sshd_config |
224 |
fi |
225 |
|
226 |
@@ -73,7 +73,7 @@ fi |
227 |
# Setup sudoers |
228 |
if [ -f /etc/sudoers ] |
229 |
then |
230 |
- sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers |
231 |
+ ${clst_sed} -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers |
232 |
fi |
233 |
|
234 |
# Setup links for ethernet devices |
235 |
@@ -113,7 +113,7 @@ echo "####################################################" >> ${clst_make_conf} |
236 |
cat ${clst_make_conf}.old >> ${clst_make_conf} |
237 |
|
238 |
# devfs tweaks |
239 |
-[ -e /etc/devfsd.conf ] && sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf |
240 |
+[ -e /etc/devfsd.conf ] && ${clst_sed} -i '/dev-state/ s:^:#:' /etc/devfsd.conf |
241 |
|
242 |
# Add some helpful aliases |
243 |
echo "alias cp='cp -i'" >> /etc/profile |
244 |
@@ -153,10 +153,10 @@ fi |
245 |
# Setup configured display manager |
246 |
if [ -n "${clst_livecd_xdm}" ] |
247 |
then |
248 |
- sed -i \ |
249 |
+ ${clst_sed} -i \ |
250 |
-e "s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \ |
251 |
/etc/rc.conf |
252 |
- sed -i \ |
253 |
+ ${clst_sed} -i \ |
254 |
-e "s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \ |
255 |
/etc/conf.d/xdm |
256 |
fi |
257 |
@@ -175,21 +175,21 @@ case ${clst_livecd_type} in |
258 |
gentoo-release-universal) |
259 |
cat /etc/generic.motd.txt /etc/universal.motd.txt \ |
260 |
/etc/minimal.motd.txt > /etc/motd |
261 |
- sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd |
262 |
+ ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd |
263 |
;; |
264 |
gentoo-release-minimal) |
265 |
cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd |
266 |
- sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd |
267 |
+ ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd |
268 |
;; |
269 |
gentoo-release-live*) |
270 |
cat /etc/generic.motd.txt \ |
271 |
/etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd |
272 |
- sed -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' \ |
273 |
+ ${clst_sed} -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' \ |
274 |
-e "s:##DISPLAY_MANAGER:${clst_livecd_xdm}:" /etc/motd |
275 |
;; |
276 |
gentoo-gamecd) |
277 |
cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd |
278 |
- sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd |
279 |
+ ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd |
280 |
;; |
281 |
esac |
282 |
|
283 |
@@ -200,7 +200,7 @@ if [ -n "${clst_livecd_splash_theme}" ] |
284 |
then |
285 |
if [ -d /etc/splash/${clst_livecd_splash_theme} ] |
286 |
then |
287 |
- sed -i \ |
288 |
+ ${clst_sed} -i \ |
289 |
-e "s:# SPLASH_THEME=\"gentoo\":SPLASH_THEME=\"${clst_livecd_splash_theme}\":" \ |
290 |
-e "/^# SPLASH_TTYS=/ s/^#//" \ |
291 |
/etc/conf.d/splash |
292 |
@@ -229,7 +229,7 @@ case ${clst_livecd_type} in |
293 |
rm /tmp/gamecd.conf |
294 |
|
295 |
# Here we replace out game information into several files |
296 |
- sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd |
297 |
+ ${clst_sed} -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd |
298 |
|
299 |
# Here we setup our xinitrc |
300 |
echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc |
301 |
@@ -276,7 +276,7 @@ case ${clst_livecd_type} in |
302 |
/etc/X11/gdm/custom.conf |
303 |
else |
304 |
cp -f /etc/X11/gdm/gdm.conf /etc/X11/gdm/gdm.conf.old |
305 |
- sed -i \ |
306 |
+ ${clst_sed} -i \ |
307 |
-e 's:TimedLoginEnable=false:TimedLoginEnable=true:' \ |
308 |
-e 's:TimedLoginDelay=30:TimedLoginDelay=10:' \ |
309 |
-e 's:AllowRemoteRoot=true:AllowRemoteRoot=false:' \ |
310 |
@@ -286,7 +286,7 @@ case ${clst_livecd_type} in |
311 |
|
312 |
if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ] |
313 |
then |
314 |
- sed -i \ |
315 |
+ ${clst_sed} -i \ |
316 |
-e "s:TimedLogin=:TimedLogin=${first_user}:" \ |
317 |
/etc/X11/gdm/gdm.conf |
318 |
fi |
319 |
@@ -296,7 +296,7 @@ case ${clst_livecd_type} in |
320 |
# This gives us our list of system packages for the installer |
321 |
mkdir -p /usr/livecd |
322 |
### XXX: Andrew says we don't need this anymore |
323 |
- USE="-* $(cat /var/db/pkg/sys-libs/glibc*/USE)" emerge -eqp @system | grep -e '^\[ebuild' | sed -e 's:^\[ebuild .\+\] ::' -e 's: .\+$::' > /usr/livecd/systempkgs.txt |
324 |
+ USE="-* $(cat /var/db/pkg/sys-libs/glibc*/USE)" emerge -eqp @system | grep -e '^\[ebuild' | ${clst_sed} -e 's:^\[ebuild .\+\] ::' -e 's: .\+$::' > /usr/livecd/systempkgs.txt |
325 |
|
326 |
# This is my hack to reduce tmpfs usage |
327 |
cp -r ${clst_repo_basedir}/${clst_repo_name}/profiles /usr/livecd |
328 |
@@ -331,10 +331,10 @@ case ${clst_livecd_type} in |
329 |
/home/${username}/Desktop |
330 |
cp -f /usr/share/applications/installer-dialog.desktop \ |
331 |
/home/${username}/Desktop |
332 |
- sed -i -e \ |
333 |
+ ${clst_sed} -i -e \ |
334 |
's:Exec=installer-dialog:Exec=sudo installer-dialog:' \ |
335 |
/home/${username}/Desktop/installer-dialog.desktop |
336 |
- sed -i -e 's:Exec=installer-gtk:Exec=installer:' \ |
337 |
+ ${clst_sed} -i -e 's:Exec=installer-gtk:Exec=installer:' \ |
338 |
/home/${username}/Desktop/installer-gtk.desktop |
339 |
fi |
340 |
chown -R ${username}:100 /home/${username} |
341 |
@@ -369,12 +369,12 @@ esac |
342 |
# We want the first user to be used when auto-starting X |
343 |
if [ -e /etc/startx ] |
344 |
then |
345 |
- sed -i "s:##STARTX:echo startx | su - '${first_user}':" /root/.bashrc |
346 |
+ ${clst_sed} -i "s:##STARTX:echo startx | su - '${first_user}':" /root/.bashrc |
347 |
fi |
348 |
|
349 |
if [ -e /lib/rcscripts/addons/udev-start.sh ] |
350 |
then |
351 |
- sed -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh |
352 |
+ ${clst_sed} -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh |
353 |
fi |
354 |
|
355 |
env-update |