[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [firstboot] Fix firstboot for s390 architecture



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This looks good.  I have some comments below.

On Thu, 11 Feb 2010, Martin Gracik wrote:

Run firstboot the first time root user logs in
with a capable terminal
---
firstboot.spec       |   11 ++++++++++-
scripts/firstboot.sh |   18 ++++++++++++++++++
setup.py             |    3 ++-
3 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 scripts/firstboot.sh

diff --git a/firstboot.spec b/firstboot.spec
index e1e672f..8e84e45 100644
--- a/firstboot.spec
+++ b/firstboot.spec
@@ -3,7 +3,7 @@
Summary: Initial system configuration utility
Name: firstboot
URL: http://fedoraproject.org/wiki/FirstBoot
-Version: 1.110
+Version: 1.111
Release: 1%{?dist}
# This is a Red Hat maintained package which is specific to
# our distribution.  Thus the source is only available from
@@ -40,15 +40,20 @@ a series of steps that allows for easier configuration of the machine.
rm -rf %{buildroot}
make DESTDIR=%{buildroot} SITELIB=%{python_sitelib} install
rm %{buildroot}/%{_datadir}/firstboot/modules/additional_cds.py*
+%ifnarch s390 s390x
+rm -rf %{buildroot}/%{_sysconfdir}/profile.d
+%endif

You can probably avoid this removal here with a change to the setup.py script
(see below).

%find_lang %{name}

%clean
rm -rf %{buildroot}

%post
+%ifnarch s390 s390x
if ! [ -f /etc/sysconfig/firstboot ]; then
  chkconfig --add firstboot
fi
+%endif

Is this valid shell syntax?  I think it should be:

    if [ ! -f /etc/sysconfig/firstboot ]; then

I could be wrong here, but I don't care.  It's shell and I don't claim to be a
shell expert.

%preun
if [ $1 = 0 ]; then
@@ -71,6 +76,10 @@ fi
%{_datadir}/firstboot/modules/eula.py*
%{_datadir}/firstboot/modules/welcome.py*
%{_datadir}/firstboot/themes/default/*
+%ifarch s390 s390x
+%dir %{_sysconfdir}/profile.d
+%{_sysconfdir}/profile.d/firstboot.sh
+%endif

%changelog
* Wed Oct 14 2009 Chris Lumens <clumens redhat com> 1.110-1
diff --git a/scripts/firstboot.sh b/scripts/firstboot.sh
new file mode 100644
index 0000000..474622b
--- /dev/null
+++ b/scripts/firstboot.sh
@@ -0,0 +1,18 @@
+# firstboot.sh
+
+FIRSTBOOT_EXEC=/usr/sbin/firstboot
+FIRSTBOOT_CONF=/etc/sysconfig/firstboot
+
+# check if firstboot is installed and should be run
+if [ -f $FIRSTBOOT_EXEC ] && [ ! -f $FIRSTBOOT_CONF ] || [ -z "$(grep 'RUN_FIRSTBOOT=NO' $FIRSTBOOT_CONF)" ]; then

Rather than grep $FIRSTBOOT_CONF here, you can just source the file and check
the variable.  The files in /etc/sysconfig are required to be
shell-sourceable, so that's why they all set variables.  Something like this
instead:

    [ -f $FIRSTBOOT_CONF ] && . $FIRSTBOOT_CONF
    if [ -f $FIRSTBOOT_EXEC ] && [ "${RUN_FIRSTBOOT,,}" = "yes" ]; then

The ,, after RUN_FIRSTBOOT converts the string to lowercase so we only need to
check against 'yes' and not all case variants of 'yes'.  ^^ can be used to do
uppercase conversion.

+    # check if we're on 3270 terminal and root
+    if [ $(/sbin/consoletype) == "pty" ] && [ $(/usr/bin/id -u) -eq 0 ]; then

The == may or may not be valid (again, not shell expert).  For testing
equality, I always use = inside [ ] in shell.

For the user ID check, you can use $EUID instead of running '/usr/bin/id -u'.
The firstboot init script could also use this change.

+        args=""
+        if grep -i "reconfig" /proc/cmdline >/dev/null || [ -f /etc/reconfigSys ]; then
+            args="--reconfig"
+        fi
+
+        . /etc/sysconfig/i18n
+        $FIRSTBOOT_EXEC $args
+    fi
+fi
diff --git a/setup.py b/setup.py
index 6249be6..38db780 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from distutils.core import setup
from glob import *

-setup(name='firstboot', version='1.110',
+setup(name='firstboot', version='1.111',
      description='Post-installation configuration utility',
      author='Chris Lumens', author_email='clumens redhat com',
      url='http://fedoraproject.org/wiki/FirstBoot',
@@ -11,5 +11,6 @@ setup(name='firstboot', version='1.110',
                  ('/etc/rc.d/init.d', ['init/firstboot']),
                  ('/usr/share/firstboot/themes/default', glob('themes/default/*.png')),
                  ('/usr/share/firstboot/modules', glob('modules/*.py')),
+                  ('/etc/profile.d', ['scripts/firstboot.sh'])
                 ],
      packages=['firstboot'])


Instead of the rm -rf /etc/profile.d in the RPM spec file on non-s390
platforms, you can prevent installation of the profile.d script on non-s390
platforms with this setup.py:

    #!/usr/bin/python2

    import os
    from distutils.core import setup
    from glob import *

    data_files=[('/usr/sbin', ['progs/firstboot']),
                ('/etc/rc.d/init.d', ['init/firstboot']),
                ('/usr/share/firstboot/themes/default', glob('themes/default/*.png')),
                ('/usr/share/firstboot/modules', glob('modules/*.py'))
               ]

    if os.uname()[4].startswith('s390'):
        data_files.append(('/etc/profile.d', ['scripts/firstboot.sh']))

    setup(name='firstboot', version='1.110',
          description='Post-installation configuration utility',
          author='Chris Lumens', author_email='clumens redhat com',
          url='http://fedoraproject.org/wiki/FirstBoot',
          data_files=data_files,
          packages=['firstboot'])

Since it's just Python code, I broke out data_files to the common section for
all platforms.  Then I check uname() and if I see I'm on s390, I add the
profile.d script to data_files.

- -- David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkt0Vz0ACgkQ5hsjjIy1VknXOACfVP+ysKod8KpMYmQ3H4jslCd7
6d4AoJwNOFn0mC07nOeMCDm8TPYF+phC
=0+t+
-----END PGP SIGNATURE-----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]