[Ovirt-devel] [PATCH] A few specfile tweaks
Jim Meyering
meyering at redhat.com
Mon May 5 19:27:21 UTC 2008
Jim Meyering <meyering at redhat.com> wrote:
> Jim Meyering <jim at meyering.net> wrote:
>> Ian Main <imain at redhat.com> wrote:
>>> D'oh, need this too.. Consider it an addendum :)
>>>
>>> diff --git a/wui-appliance/common-post.ks b/wui-appliance/common-post.ks
>>> index 3bd6b4d..d50436a 100644
>>> --- a/wui-appliance/common-post.ks
>>> +++ b/wui-appliance/common-post.ks
>>> @@ -34,7 +34,7 @@ cat > /etc/init.d/ovirt-wui-first-run << \EOF
>>> start() {
>>> echo -n "Starting ovirt-wui-first-run: "
>>>
>>> - /usr/bin/ovirt-wui-install > /var/log/ovirt-wui-first-run.log 2>&1
>>> + /usr/sbin/ovirt-wui-install > /var/log/ovirt-wui-first-run.log 2>&1
>>
>> Hi Ian,
>>
>> You could also just drop the leading "/usr/sbin/", since the PATH
>> is set via the preceding ". /etc/init.d/functions" line.
>>
>> This is another good reason to avoid those absolute prefixes when possible.
>>
>> Speaking of that, I still have a patch that removes a whole bunch of them.
>> I'll rebase it and post on Monday.
>
> I've been doing this little by little over the last month or two...
> If you're interested only in some parts, tell me which and I'll extract them:
>
> - factor out some duplication
> - split long lines
> - remove /usr/sbin, /usr/bin, etc. prefixes
> - a couple misc things like use printf rather than echo -e
>
> Until today, the middle change-set accidentally removed some
> trailing blanks (not good to mix that sort of change with a "real" one),
> so today after the main rebase (git rebase master) I ran
> "git rebase -i master" from my topic branch, selected the middle
> change-set and actually re-added those trailing blanks.
>
> Avoiding this sort of extra work is one of the reasons I'd like
> to remove all trailing blanks.
>
> What sort of testing would you like?
FYI, I really did send the three change sets, but our
old version of mailman ate them.
Here they are again, but with the "From " lines '>'-escaped.
>From 1d2927b089219e90e6e073d5a2c299f25d94955d Mon Sep 17 00:00:00 2001
Date: Thu, 13 Mar 2008 13:41:32 +0100
Subject: [PATCH] Don't specify absolute names for programs.
/etc/init.d/functions ensures that PATH is reasonable:
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
Signed-off-by: Jim Meyering <meyering at redhat.com>
---
ovirt-host-creator/common-post.ks | 20 ++++++++++----------
ovirt-host-creator/ovirt-common.sh | 7 +++++--
ovirt-host-creator/ovirt-flash-static.sh | 4 ++--
ovirt-host-creator/ovirt-flash.sh | 6 +++---
ovirt-host-creator/ovirt-pxe.sh | 3 +--
5 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/ovirt-host-creator/common-post.ks b/ovirt-host-creator/common-post.ks
index 18ab8d8..64fe0ee 100644
--- a/ovirt-host-creator/common-post.ks
+++ b/ovirt-host-creator/common-post.ks
@@ -63,11 +63,11 @@ start() {
BLOCKDEVS=`ls /dev/sd? /dev/hd? 2>/dev/null`
# now LVM partitions
- LVMDEVS="$DEVICES `/usr/sbin/lvscan | awk '{print $2}' | tr -d \"'\"`"
+ LVMDEVS="$DEVICES `lvscan | awk '{print $2}' | tr -d \"'\"`"
SWAPDEVS="$LVMDEVS"
for dev in $BLOCKDEVS; do
- SWAPDEVS="$SWAPDEVS `/sbin/fdisk -l $dev 2>/dev/null | tr '*' ' ' \
+ SWAPDEVS="$SWAPDEVS `fdisk -l $dev 2>/dev/null | tr '*' ' ' \
| awk '$5 ~ /82/ {print $1}'`"
done
@@ -76,7 +76,7 @@ start() {
sig=`dd if=$device bs=1 count=10 skip=$(( $PAGESIZE - 10 )) \
2>/dev/null`
if [ "$sig" = "SWAPSPACE2" ]; then
- /sbin/swapon $device
+ swapon $device
fi
done
}
@@ -92,7 +92,7 @@ esac
EOF
chmod +x /etc/init.d/ovirt-early
-/sbin/chkconfig ovirt-early on
+chkconfig ovirt-early on
# just to get a boot warning to shut up
touch /etc/resolv.conf
@@ -131,7 +131,7 @@ start() {
# then give up
tries=0
while [ "$VAL" != "SUCCESS" -a $tries -lt 5 ]; do
- VAL=`echo "KERB" | /usr/bin/nc $SRV_HOST 6666`
+ VAL=`echo "KERB" | nc $SRV_HOST 6666`
if [ "$VAL" == "SUCCESS" ]; then
break
fi
@@ -193,9 +193,9 @@ echo "Setting up bridged networking"
cat > /etc/kvm-ifup << \EOF
#!/bin/sh
-switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
-/sbin/ifconfig $1 0.0.0.0 up
-/usr/sbin/brctl addif ${switch} $1
+switch=$(ip route list | awk '/^default / { print $NF }')
+ifconfig $1 0.0.0.0 up
+brctl addif ${switch} $1
EOF
chmod +x /etc/kvm-ifup
@@ -270,8 +270,8 @@ rm -f /etc/krb5.conf
echo "Creating shadow files"
# because we aren't installing authconfig, we aren't setting up shadow
# and gshadow properly. Do it by hand here
-/usr/sbin/pwconv
-/usr/sbin/grpconv
+pwconv
+grpconv
echo "Re-creating cracklib dicts"
# cracklib-dicts is 8MB. We probably don't need to have strict password
diff --git a/ovirt-host-creator/ovirt-common.sh b/ovirt-host-creator/ovirt-common.sh
index 2ada16e..1680a2c 100644
--- a/ovirt-host-creator/ovirt-common.sh
+++ b/ovirt-host-creator/ovirt-common.sh
@@ -1,11 +1,14 @@
+PATH=/sbin:/bin:/usr/bin
+export PATH
+
create_iso() {
KICKSTART=ovirt-`uname -i`.ks
if [ $# -eq 0 ]; then
LABEL=ovirt-`date +%Y%m%d%H%M`
- /usr/bin/livecd-creator --skip-minimize -c $KICKSTART -f $LABEL 1>&2 &&
+ livecd-creator --skip-minimize -c $KICKSTART -f $LABEL 1>&2 &&
echo $LABEL.iso
elif [ $# -eq 1 ]; then
- /usr/bin/livecd-creator --skip-minimize -c $KICKSTART -b $1 1>&2 &&
+ livecd-creator --skip-minimize -c $KICKSTART -b $1 1>&2 &&
echo $1
else
return 1
diff --git a/ovirt-host-creator/ovirt-flash-static.sh b/ovirt-host-creator/ovirt-flash-static.sh
index f31fc02..12e3d14 100755
--- a/ovirt-host-creator/ovirt-flash-static.sh
+++ b/ovirt-host-creator/ovirt-flash-static.sh
@@ -47,7 +47,7 @@ mount -o loop $IMGTMP/LiveOS/squashfs.img $SQUASHTMP
# clear out the old partition table
dd if=/dev/zero of=$USBDEVICE bs=4096 count=1
-echo -e 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | /sbin/fdisk $USBDEVICE
+printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | fdisk $USBDEVICE
cat /usr/lib/syslinux/mbr.bin > $USBDEVICE
dd if=$SQUASHTMP/LiveOS/ext3fs.img of=${USBDEVICE}1
@@ -62,7 +62,7 @@ mv $USBTMP/isolinux.cfg $USBTMP/extlinux.conf
LABEL=`echo $ISO | cut -d'.' -f1 | cut -c-16`
sed -i -e "s/ *append.*/ append initrd=initrd.img root=LABEL=$LABEL ro/" $USBTMP/extlinux.conf
-/sbin/extlinux -i $USBTMP
+extlinux -i $USBTMP
umount $USBTMP
umount $SQUASHTMP
diff --git a/ovirt-host-creator/ovirt-flash.sh b/ovirt-host-creator/ovirt-flash.sh
index bb0ca45..621972c 100755
--- a/ovirt-host-creator/ovirt-flash.sh
+++ b/ovirt-host-creator/ovirt-flash.sh
@@ -39,7 +39,7 @@ ISO=`create_iso $ISO` || exit 1
# clear out the old partition table
dd if=/dev/zero of=$USBDEVICE bs=4096 count=1
-echo -e 'n\np\n1\n\n\nt\n6\na\n1\nw\n' | /sbin/fdisk $USBDEVICE
-/sbin/mkdosfs -n ovirt ${USBDEVICE}1
+printf 'n\np\n1\n\n\nt\n6\na\n1\nw\n' | fdisk $USBDEVICE
+mkdosfs -n ovirt ${USBDEVICE}1
cat /usr/lib/syslinux/mbr.bin > $USBDEVICE
-/usr/bin/livecd-iso-to-disk $ISO ${USBDEVICE}1
+livecd-iso-to-disk $ISO ${USBDEVICE}1
diff --git a/ovirt-host-creator/ovirt-pxe.sh b/ovirt-host-creator/ovirt-pxe.sh
index 1581e15..632ec5d 100755
--- a/ovirt-host-creator/ovirt-pxe.sh
+++ b/ovirt-host-creator/ovirt-pxe.sh
@@ -30,5 +30,4 @@ fi
ISO=`create_iso $ISO` || exit 1
-/usr/bin/livecd-iso-to-pxeboot $ISO
-
+livecd-iso-to-pxeboot $ISO
--
1.5.5.1.126.g02179
>From 20404b532b69c851910773ae67c794e3e1e39034 Mon Sep 17 00:00:00 2001
Date: Thu, 20 Mar 2008 08:59:41 +0100
Subject: [PATCH] remove abs names, split long lines, factor out some duplication
Signed-off-by: Jim Meyering <meyering at redhat.com>
---
wui-appliance/wui-devel-x86_64.ks | 71 ++++++++++++++++++++++---------------
1 files changed, 42 insertions(+), 29 deletions(-)
diff --git a/wui-appliance/wui-devel-x86_64.ks b/wui-appliance/wui-devel-x86_64.ks
index c7ccdd7..f28ed27 100644
--- a/wui-appliance/wui-devel-x86_64.ks
+++ b/wui-appliance/wui-devel-x86_64.ks
@@ -23,7 +23,8 @@ repo --name=ovirt-management --baseurl=http://ovirt.et.redhat.com/repos/ovirt-ma
%include common-post.ks
# make sure our "hostname" resolves to management.priv.ovirt.org
-sed -i -e 's/^HOSTNAME.*/HOSTNAME=management.priv.ovirt.org/' /etc/sysconfig/network
+sed -i -e 's/^HOSTNAME.*/HOSTNAME=management.priv.ovirt.org/' \
+ /etc/sysconfig/network
# make sure to update the /etc/hosts with the list of all possible DHCP
# addresses we can hand out; dnsmasq uses this
@@ -32,31 +33,38 @@ for i in `seq 3 252` ; do
echo "192.168.50.$i node$i.priv.ovirt.org" >> /etc/hosts
done
+principal=ovirtadmin at PRIV.OVIRT.ORG
+cron_file=/etc/cron.hourly/ovirtadmin.cron
+ktab_file=/usr/share/ovirt-wui/ovirtadmin.tab
+
# automatically refresh the kerberos ticket every hour (we'll create the
# principal on first-boot)
-cat > /etc/cron.hourly/ovirtadmin.cron << \EOF
+cat > $cron_file << EOF
#!/bin/bash
-/usr/kerberos/bin/kdestroy
-/usr/kerberos/bin/kinit -k -t /usr/share/ovirt-wui/ovirtadmin.tab ovirtadmin at PRIV.OVIRT.ORG
+export PATH=/usr/kerberos/bin:$PATH
+kdestroy
+kinit -k -t $ktab_file $principal
EOF
-chmod 755 /etc/cron.hourly/ovirtadmin.cron
+chmod 755 $cron_file
+
+ff_profile_dir=uxssq4qb.ovirtadmin
# for firefox, we need to make some subdirs and add some preferences
-mkdir -p /root/.mozilla/firefox/uxssq4qb.ovirtadmin
-cat >> /root/.mozilla/firefox/uxssq4qb.ovirtadmin/prefs.js << \EOF
+mkdir -p /root/.mozilla/firefox/$ff_profile_dir
+cat >> /root/.mozilla/firefox/$ff_profile_dir/prefs.js << \EOF
user_pref("network.negotiate-auth.delegation-uris", "priv.ovirt.org");
user_pref("network.negotiate-auth.trusted-uris", "priv.ovirt.org");
user_pref("browser.startup.homepage", "http://management.priv.ovirt.org/ovirt");
EOF
-cat >> /root/.mozilla/firefox/profiles.ini << \EOF
+cat >> /root/.mozilla/firefox/profiles.ini << EOF
[General]
StartWithLastProfile=1
[Profile0]
Name=ovirtadmin
IsRelative=1
-Path=uxssq4qb.ovirtadmin
+Path=$ff_profile_dir
EOF
# make sure we don't mount the "fake" iSCSI LUNs, since they are meant to
@@ -79,7 +87,7 @@ EOF
chmod +x /etc/dhclient-exit-hooks
# make sure that we get a kerberos principal on every boot
-echo "/etc/cron.hourly/ovirtadmin.cron" >> /etc/rc.d/rc.local
+echo "$cron_file" >> /etc/rc.d/rc.local
# make collectd.conf.
cat > /etc/collectd.conf << \EOF
@@ -105,7 +113,11 @@ LoadPlugin rrdtool
EOF
-cat > /etc/init.d/ovirt-wui-dev-first-run << \EOF
+first_run_file=/etc/init.d/ovirt-wui-dev-first-run
+sed -e "s, at cron_file@,$cron_file," \
+ -e "s, at principal@,$principal," \
+ -e "s, at ktab_file@,$ktab_file," \
+ > $first_run_file << \EOF
#!/bin/bash
#
# ovirt-wui-dev-first-run First run configuration for Ovirt WUI Dev appliance
@@ -123,12 +135,13 @@ start() {
echo -n "Starting ovirt-dev-wui-first-run: "
(
# set up freeipa
- /usr/sbin/ipa-server-install -r PRIV.OVIRT.ORG -p ovirt -P ovirt -a ovirtwui --hostname management.priv.ovirt.org -u dirsrv -U
+ ipa-server-install -r PRIV.OVIRT.ORG -p ovirt -P ovirt -a ovirtwui \
+ --hostname management.priv.ovirt.org -u dirsrv -U
# now create the ovirtadmin user
- $KADMIN -q 'addprinc -randkey ovirtadmin at PRIV.OVIRT.ORG'
- $KADMIN -q 'ktadd -k /usr/share/ovirt-wui/ovirtadmin.tab ovirtadmin at PRIV.OVIRT.ORG'
- /etc/cron.hourly/ovirtadmin.cron
+ $KADMIN -q 'addprinc -randkey @principal@'
+ $KADMIN -q 'ktadd -k @ktab_file@ @principal@'
+ @cron_file@
) > /var/log/ovirt-wui-dev-first-run.log 2>&1
RETVAL=$?
@@ -149,9 +162,9 @@ case "$1" in
exit 2
esac
-/sbin/chkconfig ovirt-wui-dev-first-run off
+chkconfig ovirt-wui-dev-first-run off
EOF
-chmod +x /etc/init.d/ovirt-wui-dev-first-run
+chmod +x $first_run_file
/sbin/chkconfig ovirt-wui-dev-first-run on
cat > /etc/init.d/ovirt-wui-dev << \EOF
@@ -168,7 +181,7 @@ cat > /etc/init.d/ovirt-wui-dev << \EOF
start() {
echo -n "Starting ovirt-wui-dev: "
- /usr/sbin/dnsmasq -i eth1 -F 192.168.50.6,192.168.50.252 \
+ dnsmasq -i eth1 -F 192.168.50.6,192.168.50.252 \
-G 00:16:3e:12:34:57,192.168.50.3 -G 00:16:3e:12:34:58,192.168.50.4 \
-G 00:16:3e:12:34:59,192.168.50.5 \
-s priv.ovirt.org \
@@ -181,23 +194,23 @@ start() {
-R -S 192.168.122.1
# Set up the fake iscsi target
- /usr/sbin/tgtadm --lld iscsi --op new --mode target --tid 1 \
+ tgtadm --lld iscsi --op new --mode target --tid 1 \
-T ovirtpriv:storage
#
# Now associate them to the LVs
#
- /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
+ tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
--lun 1 -b /dev/VolGroup00/iSCSI3
- /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
+ tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
--lun 2 -b /dev/VolGroup00/iSCSI4
- /usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
+ tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
--lun 3 -b /dev/VolGroup00/iSCSI5
-
+
#
# Now make them available
#
- /usr/sbin/tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
+ tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
echo_success
echo
@@ -207,15 +220,15 @@ stop() {
echo -n "Stopping ovirt-wui-dev: "
# stop access to the iscsi target
- /usr/sbin/tgtadm --lld iscsi --op unbind --mode target --tid 1 -I ALL
+ tgtadm --lld iscsi --op unbind --mode target --tid 1 -I ALL
# unbind the LUNs
- /usr/sbin/tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 3
- /usr/sbin/tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 2
- /usr/sbin/tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
+ tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 3
+ tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 2
+ tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
# shutdown the target
- /usr/sbin/tgtadm --lld iscsi --op delete --mode target --tid 1
+ tgtadm --lld iscsi --op delete --mode target --tid 1
kill $(cat /var/run/dnsmasq.pid)
--
1.5.5.1.126.g02179
>From 7d6e35a711f104482dc9939fa0ba2936153947f3 Mon Sep 17 00:00:00 2001
Date: Fri, 11 Apr 2008 19:14:20 +0200
Subject: [PATCH] * ovirt-host-creator/common-post.ks: Add explicit PATH= setting, ...
so it's obviously ok to remove all absolute path prefixes.
* wui-appliance/common-post.ks: Likewise.
Signed-off-by: Jim Meyering <meyering at redhat.com>
---
ovirt-host-creator/common-post.ks | 6 ++++--
wui-appliance/common-post.ks | 9 ++++++---
wui-appliance/wui-devel-x86_64.ks | 4 ++--
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/ovirt-host-creator/common-post.ks b/ovirt-host-creator/common-post.ks
index 64fe0ee..17291b4 100644
--- a/ovirt-host-creator/common-post.ks
+++ b/ovirt-host-creator/common-post.ks
@@ -1,4 +1,6 @@
echo "Starting Kickstart Post"
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+export PATH
echo "Setting up Networking"
cat > /etc/sysconfig/iptables << \EOF
@@ -183,7 +185,7 @@ esac
EOF
chmod +x /etc/init.d/ovirt
-/sbin/chkconfig ovirt on
+chkconfig ovirt on
echo "Setting up libvirt interfaces"
# make libvirtd listen on the external interfaces
@@ -278,7 +280,7 @@ echo "Re-creating cracklib dicts"
# checking on the ovirt host
# unfortunately we can't create an empty cracklib dict, so we create it
# with a single entry "1"
-echo 1 | /usr/sbin/packer >& /dev/null
+echo 1 | packer >& /dev/null
echo "Forcing C locale"
# force logins (via ssh, etc) to use C locale, since we remove locales
diff --git a/wui-appliance/common-post.ks b/wui-appliance/common-post.ks
index 3bd6b4d..3dee5bb 100644
--- a/wui-appliance/common-post.ks
+++ b/wui-appliance/common-post.ks
@@ -1,3 +1,6 @@
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+export PATH
+
# pretty login screen..
g=$(printf '\33[1m\33[32m') # similar to g=$(tput bold; tput setaf 2)
n=$(printf '\33[m') # similar to n=$(tput sgr0)
@@ -34,7 +37,7 @@ cat > /etc/init.d/ovirt-wui-first-run << \EOF
start() {
echo -n "Starting ovirt-wui-first-run: "
- /usr/bin/ovirt-wui-install > /var/log/ovirt-wui-first-run.log 2>&1
+ ovirt-wui-install > /var/log/ovirt-wui-first-run.log 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
@@ -54,10 +57,10 @@ case "$1" in
exit 2
esac
-/sbin/chkconfig ovirt-wui-first-run off
+chkconfig ovirt-wui-first-run off
EOF
chmod +x /etc/init.d/ovirt-wui-first-run
-/sbin/chkconfig ovirt-wui-first-run on
+chkconfig ovirt-wui-first-run on
cat > /etc/yum.repos.d/ovirt-management.repo << \EOF
[ovirt-management]
diff --git a/wui-appliance/wui-devel-x86_64.ks b/wui-appliance/wui-devel-x86_64.ks
index f28ed27..67172ba 100644
--- a/wui-appliance/wui-devel-x86_64.ks
+++ b/wui-appliance/wui-devel-x86_64.ks
@@ -165,7 +165,7 @@ esac
chkconfig ovirt-wui-dev-first-run off
EOF
chmod +x $first_run_file
-/sbin/chkconfig ovirt-wui-dev-first-run on
+chkconfig ovirt-wui-dev-first-run on
cat > /etc/init.d/ovirt-wui-dev << \EOF
#!/bin/bash
@@ -253,7 +253,7 @@ case "$1" in
esac
EOF
chmod +x /etc/init.d/ovirt-wui-dev
-/sbin/chkconfig ovirt-wui-dev on
+chkconfig ovirt-wui-dev on
# get the PXE boot image; this can take a while
PXE_URL=http://ovirt.org/download
--
1.5.5.1.126.g02179
More information about the ovirt-devel
mailing list