commit:     f3d246e24b5b1da80b4444204a989957f155c1a2
Author:     Yuta SATOH <nigoro.dev <AT> gmail <DOT> com>
AuthorDate: Fri Dec 29 01:35:36 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 02:04:21 2017 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f3d246e2

detect and use a configured sed command for Gentoo/FreeBSD # 363577

Relocated the main.py code changes location: Brian Dolbec <dolsen <AT> 
gentoo.org
Bug url: https://bugs.gentoo.org/363577

 catalyst/defaults.py                |  1 +
 catalyst/main.py                    |  6 ++++++
 targets/stage1/stage1-chroot.sh     | 11 +++++------
 targets/support/bootloader-setup.sh |  2 +-
 targets/support/chroot-functions.sh | 10 +++++-----
 targets/support/create-iso.sh       |  6 +++---
 targets/support/kmerge.sh           |  8 ++++----
 targets/support/livecdfs-update.sh  | 36 ++++++++++++++++++------------------
 8 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index ed5766d6..f2fe29df 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -62,6 +62,7 @@ confdefaults={
        "PythonDir": "./catalyst",
        "repo_basedir": REPODIR[:],
        "repo_name": MAINREPO[:],
+       "sed": "sed",
        "sharedir": "/usr/share/catalyst",
        "shdir": "/usr/share/catalyst/targets/",
        "snapshot_cache": "/var/tmp/catalyst/snapshot_cache",

diff --git a/catalyst/main.py b/catalyst/main.py
index 2d2faada..01c456ea 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -408,6 +408,12 @@ def _main(parser, opts):
                                
hash_map.hash_map[conf_values['hash_function']].cmd,
                                conf_values['hash_function'])
 
+       # detect GNU sed
+       for sed in ('/usr/bin/gsed', '/bin/sed', '/usr/bin/sed'):
+               if os.path.exists(sed):
+                       conf_values["sed"] = sed
+                       break
+
        addlargs={}
 
        if myspecfile:

diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh
index 1b0aa08b..0caf49ee 100755
--- a/targets/stage1/stage1-chroot.sh
+++ b/targets/stage1/stage1-chroot.sh
@@ -48,15 +48,14 @@ else
 fi
 
 # Clear USE
-[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"${BINDIST} ${USE}\"/d" 
${clst_make_conf}
-
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^USE=\"${BINDIST} ${USE}\"/d" 
${clst_make_conf}
 make_destpath /tmp/stage1root
 
 ## START BUILD
 # First, we drop in a known-good baselayout
 [ -e ${clst_make_conf} ] && echo "USE=\"${USE} -build\"" >> ${clst_make_conf}
 run_merge "--oneshot --nodeps sys-apps/baselayout"
-sed -i "/USE=\"${USE} -build\"/d" ${clst_make_conf}
+${clst_sed} -i "/USE=\"${USE} -build\"/d" ${clst_make_conf}
 
 # Now, we install our packages
 if [ -e ${clst_make_conf} ]; then
@@ -75,10 +74,10 @@ run_merge "--oneshot ${clst_buildpkgs}"
 # Why are we removing these? Don't we need them for final make.conf?
 for useexpand in ${clst_HOSTUSEEXPAND}; do
        x="clst_${useexpand}"
-       sed -i "/${useexpand}=\"${!x}\"/d" \
+       ${clst_sed} -i "/${useexpand}=\"${!x}\"/d" \
        ${clst_make_conf}
 done
 
 # Clear USE
-[ -e ${clst_make_conf} ] && sed -i -e "/^CATALYST_USE/d" ${clst_make_conf}
-[ -e ${clst_make_conf} ] && sed -i -e "/^USE=\"/s/\${CATALYST_USE} ${USE} 
${BOOTSTRAP_USE}//" ${clst_make_conf}
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^CATALYST_USE/d" 
${clst_make_conf}
+[ -e ${clst_make_conf} ] && ${clst_sed} -i -e "/^USE=\"/s/\${CATALYST_USE} 
${USE} ${BOOTSTRAP_USE}//" ${clst_make_conf}

diff --git a/targets/support/bootloader-setup.sh 
b/targets/support/bootloader-setup.sh
index d9e2620e..ffe7be2f 100755
--- a/targets/support/bootloader-setup.sh
+++ b/targets/support/bootloader-setup.sh
@@ -79,7 +79,7 @@ case ${clst_hostarch} in
                echo "message=/boot/boot.msg" >> ${icfg}
 
                # Here is where I fix up the boot.msg file.
-               sed -e 's/ARCH/PowerPC/' \
+               ${clst_sed} -e 's/ARCH/PowerPC/' \
                        -e 's/HARDWARE/Apple and IBM hardware/' \
                        -i $kmsg
 

diff --git a/targets/support/chroot-functions.sh 
b/targets/support/chroot-functions.sh
index e44de61b..84d90fe9 100755
--- a/targets/support/chroot-functions.sh
+++ b/targets/support/chroot-functions.sh
@@ -101,7 +101,7 @@ setup_myfeatures(){
                else
                        clst_root_path=/ run_merge --oneshot --noreplace 
sys-devel/distcc || exit 1
                fi
-               sed -i '/USE="${USE} -avahi -gtk -gnome"/d' ${clst_make_conf}
+               ${clst_sed} -i '/USE="${USE} -avahi -gtk -gnome"/d' 
${clst_make_conf}
                mkdir -p /etc/distcc
                echo "${clst_distcc_hosts}" > /etc/distcc/hosts
 
@@ -201,7 +201,7 @@ setup_pkgmgr(){
                echo "Adding USE=\"\${USE} $1\" to make.conf for portage build"
                [ -e "${clst_make_conf}" ] && echo "USE=\"\${USE} $1\"" >> 
"${clst_make_conf}"
                run_merge --oneshot --update --newuse sys-apps/portage
-               sed -i "/USE=\"\${USE} $1\"/d" "${clst_make_conf}"
+               ${clst_sed} -i "/USE=\"\${USE} $1\"/d" "${clst_make_conf}"
        else
                run_merge --oneshot --update --newuse sys-apps/portage
        fi
@@ -256,8 +256,8 @@ cleanup_stages() {
 
        # Remove bindist from use
        # this is handled independantly in stage2, changes here should be 
mirrored there
-       sed -i "/USE=\"\${USE} bindist\"/d" "${clst_make_conf}"
-       sed -i "/USE=\"bindist\"/d" "${clst_make_conf}"
+       ${clst_sed} -i "/USE=\"\${USE} bindist\"/d" "${clst_make_conf}"
+       ${clst_sed} -i "/USE=\"bindist\"/d" "${clst_make_conf}"
 
        [ "${clst_target}" != "tinderbox" ] && rm -f /var/log/emerge.log 
/var/log/portage/elog/*
 }
@@ -275,7 +275,7 @@ die() {
 
 make_destpath() {
        # ROOT is / by default, so remove any ROOT= settings from make.conf
-       sed -i '/ROOT=/d' ${clst_make_conf}
+       ${clst_sed} -i '/ROOT=/d' ${clst_make_conf}
        export ROOT=/
        if [ "${1}" != "/" -a -n "${1}" ]
        then

diff --git a/targets/support/create-iso.sh b/targets/support/create-iso.sh
index 723f8998..b7c4a7aa 100755
--- a/targets/support/create-iso.sh
+++ b/targets/support/create-iso.sh
@@ -95,7 +95,7 @@ fi
 isoroot_checksum() {
        echo "Creating checksums for all files included in the iso, please 
wait..."
        find "${clst_target_path}" -type f ! -name 'isoroot_checksums' ! -name 
'isolinux.bin' -exec sha512sum {} + > "${clst_target_path}"/isoroot_checksums
-       sed -i "s#${clst_target_path}/\?##" 
"${clst_target_path}"/isoroot_checksums
+       ${clst_sed} -i "s#${clst_target_path}/\?##" 
"${clst_target_path}"/isoroot_checksums
 }
 
 run_mkisofs() {
@@ -211,10 +211,10 @@ case ${clst_hostarch} in
                if [ -f "${clst_target_path}/ppc/bootinfo.txt" ]
                then
                        echo "bootinfo.txt found .. updating it"
-                       sed -i -e \
+                       ${clst_sed} -i -e \
                        
's#^<description>.*</description>$#<description>'"${clst_iso_volume_id}"'</description>#'
 \
                        "${clst_target_path}/ppc/bootinfo.txt"
-                       sed -i -e \
+                       ${clst_sed} -i -e \
                        
's#^<os-name>.*</os-name>$#<os-name>'"${clst_iso_volume_id}"'</os-name>#' \
                        "${clst_target_path}/ppc/bootinfo.txt"
                fi

diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
index f29cd385..b8593ada 100755
--- a/targets/support/kmerge.sh
+++ b/targets/support/kmerge.sh
@@ -249,7 +249,7 @@ then
                if [ ! "${clst_kextraversion}" = "" ]
                then
                        echo "Setting extraversion to ${clst_kextraversion}"
-                       sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION 
\1-${clst_kextraversion}:" /usr/src/linux/Makefile
+                       ${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION 
\1-${clst_kextraversion}:" /usr/src/linux/Makefile
                        echo ${clst_kextraversion} > 
/tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
                else
                        touch 
/tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
@@ -266,7 +266,7 @@ $(portageq contents / $(portageq best_visible / 
"${clst_ksource}" 2>/dev/null) 2
        if [ ! "${clst_kextraversion}" = "" ]
        then
                echo "Setting extraversion to ${clst_kextraversion}"
-               sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION 
\1-${clst_kextraversion}:" /usr/src/linux/Makefile
+               ${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION 
\1-${clst_kextraversion}:" /usr/src/linux/Makefile
        fi
 fi
 
@@ -279,12 +279,12 @@ make_destpath
 
 
 build_kernel
-sed -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf}
+${clst_sed} -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf}
 # grep out the kernel version so that we can do our modules magic
 VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
 PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
 SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
-EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION 
=//" -e "s/ //g"`
+EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | ${clst_sed} -e 
"s/EXTRAVERSION =//" -e "s/ //g"`
 clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
 
 unset USE

diff --git a/targets/support/livecdfs-update.sh 
b/targets/support/livecdfs-update.sh
index 31cdf04e..2c551b42 100755
--- a/targets/support/livecdfs-update.sh
+++ b/targets/support/livecdfs-update.sh
@@ -7,7 +7,7 @@ source /tmp/chroot-functions.sh
 # Allow root logins to our CD by default
 if [ -e /etc/ssh/sshd_config ]
 then
-       sed -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' \
+       ${clst_sed} -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' \
                /etc/ssh/sshd_config
 fi
 
@@ -73,7 +73,7 @@ fi
 # Setup sudoers
 if [ -f /etc/sudoers ]
 then
-       sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
+       ${clst_sed} -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
 fi
 
 # Setup links for ethernet devices
@@ -113,7 +113,7 @@ echo "####################################################" 
>> ${clst_make_conf}
 cat ${clst_make_conf}.old >> ${clst_make_conf}
 
 # devfs tweaks
-[ -e /etc/devfsd.conf ] && sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf
+[ -e /etc/devfsd.conf ] && ${clst_sed} -i '/dev-state/ s:^:#:' /etc/devfsd.conf
 
 # Add some helpful aliases
 echo "alias cp='cp -i'" >> /etc/profile
@@ -153,10 +153,10 @@ fi
 # Setup configured display manager
 if [ -n "${clst_livecd_xdm}" ]
 then
-       sed -i \
+       ${clst_sed} -i \
                -e 
"s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
                /etc/rc.conf
-       sed -i \
+       ${clst_sed} -i \
                -e 
"s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
                /etc/conf.d/xdm
 fi
@@ -175,21 +175,21 @@ case ${clst_livecd_type} in
        gentoo-release-universal)
                cat /etc/generic.motd.txt /etc/universal.motd.txt \
                        /etc/minimal.motd.txt > /etc/motd
-               sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal 
Installation CD!:' /etc/motd
+               ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux 
Universal Installation CD!:' /etc/motd
        ;;
        gentoo-release-minimal)
                cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
-               sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal 
Installation CD!:' /etc/motd
+               ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux 
Minimal Installation CD!:' /etc/motd
        ;;
        gentoo-release-live*)
                cat /etc/generic.motd.txt \
                        /etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
-               sed -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' \
+               ${clst_sed} -i -e 's:^##GREETING:Welcome to the Gentoo Linux 
LiveCD!:' \
                        -e "s:##DISPLAY_MANAGER:${clst_livecd_xdm}:" /etc/motd
        ;;
        gentoo-gamecd)
                cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
-               sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME 
GameCD!:' /etc/motd
+               ${clst_sed} -i 's:^##GREETING:Welcome to the Gentoo Linux 
##GAME_NAME GameCD!:' /etc/motd
        ;;
 esac
 
@@ -200,7 +200,7 @@ if [ -n "${clst_livecd_splash_theme}" ]
 then
        if [ -d /etc/splash/${clst_livecd_splash_theme} ]
        then
-               sed -i \
+               ${clst_sed} -i \
                        -e "s:# 
SPLASH_THEME=\"gentoo\":SPLASH_THEME=\"${clst_livecd_splash_theme}\":" \
                        -e "/^# SPLASH_TTYS=/ s/^#//" \
                        /etc/conf.d/splash
@@ -229,7 +229,7 @@ case ${clst_livecd_type} in
                        rm /tmp/gamecd.conf
 
                        # Here we replace out game information into several 
files
-                       sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
+                       ${clst_sed} -i -e "s:##GAME_NAME:${GAME_NAME}:" 
/etc/motd
 
                        # Here we setup our xinitrc
                        echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
@@ -276,7 +276,7 @@ case ${clst_livecd_type} in
                                        /etc/X11/gdm/custom.conf
                        else
                                cp -f /etc/X11/gdm/gdm.conf 
/etc/X11/gdm/gdm.conf.old
-                               sed -i \
+                               ${clst_sed} -i \
                                        -e 
's:TimedLoginEnable=false:TimedLoginEnable=true:' \
                                        -e 
's:TimedLoginDelay=30:TimedLoginDelay=10:' \
                                        -e 
's:AllowRemoteRoot=true:AllowRemoteRoot=false:' \
@@ -286,7 +286,7 @@ case ${clst_livecd_type} in
 
                                if [ -n "${clst_livecd_users}" ] && [ -n 
"${first_user}" ]
                                then
-                                       sed -i \
+                                       ${clst_sed} -i \
                                                -e 
"s:TimedLogin=:TimedLogin=${first_user}:" \
                                                /etc/X11/gdm/gdm.conf
                                fi
@@ -296,7 +296,7 @@ case ${clst_livecd_type} in
                # This gives us our list of system packages for the installer
                mkdir -p /usr/livecd
                ### XXX: Andrew says we don't need this anymore
-               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
+               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
 
                # This is my hack to reduce tmpfs usage
                cp -r ${clst_repo_basedir}/${clst_repo_name}/profiles 
/usr/livecd
@@ -331,10 +331,10 @@ case ${clst_livecd_type} in
                                                /home/${username}/Desktop
                                        cp -f 
/usr/share/applications/installer-dialog.desktop \
                                                /home/${username}/Desktop
-                                       sed -i -e \
+                                       ${clst_sed} -i -e \
                                                
's:Exec=installer-dialog:Exec=sudo installer-dialog:' \
                                                
/home/${username}/Desktop/installer-dialog.desktop
-                                       sed -i -e 
's:Exec=installer-gtk:Exec=installer:' \
+                                       ${clst_sed} -i -e 
's:Exec=installer-gtk:Exec=installer:' \
                                                
/home/${username}/Desktop/installer-gtk.desktop
                                fi
                                chown -R ${username}:100 /home/${username}
@@ -369,12 +369,12 @@ esac
 # We want the first user to be used when auto-starting X
 if [ -e /etc/startx ]
 then
-       sed -i "s:##STARTX:echo startx | su - '${first_user}':" /root/.bashrc
+       ${clst_sed} -i "s:##STARTX:echo startx | su - '${first_user}':" 
/root/.bashrc
 fi
 
 if [ -e /lib/rcscripts/addons/udev-start.sh ]
 then
-       sed -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& 
\[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh
+       ${clst_sed} -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} 
\]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh
 fi
 
 env-update

Reply via email to