File openSUSE-images.spec of Package openSUSE-images

#
# spec file for package openSUSE-images (Version 11.1)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# needsrootforbuild
# needsbinariesforbuild


Name:           openSUSE-images
BuildRequires:  createrepo lzma package-lists-openSUSE-images
BuildRequires:  ghostscript-fonts-std ghostscript-library
BuildRequires:  bundle-lang-common-en bundle-lang-gnome-en bundle-lang-kde-en
BuildRequires:  dummy-release openSUSE-build-key
#!BuildIgnore:  openSUSE-release
#!BuildIgnore:  suspend
Summary:        Creates preinstalled images of patterns
Version:        11.1
Release:        10
Group:          Metapackages
License:        BSD 3-Clause
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         common_tree 
Source1:        images.xml.in
ExcludeArch:    ia64 ppc ppc64 s390x s390
# do not compress the ISO - takes ages 
%define _binary_payload w.ufdio

%description
This will install most default packages and create tar images for
faster installation



Authors:
--------
    Stephan Kulow <coolo@suse.de>

%prep
%setup -T -c

%build
createrepo /.build.binaries
install_repo()
{
  set +e
  root=$1
  file=$2
  export YAST_IS_RUNNING=1
  export ZYPP_MODALIAS_SYSFS=/tmp
  mkdir -p $root/home/rpmdir $root/proc $root/sys
  mkdir -p $root/dev
  mkdir -m 755 -p $root/dev/pts
  mknod -m 666 $root/dev/null c 1 3
  mknod -m 666 $root/dev/zero c 1 5
  mknod -m 622 $root/dev/full c 1 7
  mknod -m 666 $root/dev/random c 1 8
  mknod -m 644 $root/dev/urandom c 1 9
  mknod -m 666 $root/dev/tty c 5 0
  mknod -m 666 $root/dev/ptmx c 5 2
  ln -s /proc/self/fd $root/dev/fd
  ln -s fd/2 $root/dev/stderr
  ln -s fd/0 $root/dev/stdin
  ln -s fd/1 $root/dev/stdout
  mknod -m 640 $root/dev/loop0 b 7 0
  mknod -m 640 $root/dev/loop1 b 7 1
  mknod -m 640 $root/dev/loop2 b 7 2
  mknod -m 640 $root/dev/loop3 b 7 3
  mkdir -p $root/etc
  touch $root/etc/mtab
  cp /var/adm/fillup-templates/passwd.aaa_base $root/etc/passwd
  cp /var/adm/fillup-templates/group.aaa_base $root/etc/group
  ret=0
  ZYPPER="zypper --root $root --non-interactive --no-gpg-checks"
  mount -o bind,ro /.build.binaries $root/home/rpmdir
  mount -o bind /dev $root/dev
  mount -o bind /proc $root/proc
  mount -o bind /sys $root/sys
  for key in sigs/gpg-pubke*; do
    rpm -r $root --import $key
  done
#  mount -t sysfs none $root/sys
  $ZYPPER addrepo file:$root/home/rpmdir repo || ret=1
  $ZYPPER ref
  $ZYPPER in --auto-agree-with-licenses `cat /usr/share/suse/packages/$file` || ret=1
  rpm -r $root -qa --qf "[%{NAME}\n]" | LC_ALL=C sort -u > $file
  diff -U 0 /usr/share/suse/packages/$file $file
  list=`diff -u /usr/share/suse/packages/$file $file | grep -v +++ | grep ^+ | grep -v gpg-pubkey | cut -b2-`
  if test -n "$list"; then
    rpm -v --nodeps -r $root -e $list || ret=1
  fi
  # update System.solv
  $ZYPPER ref
  umount -f $root/home/rpmdir
  rmdir $root/home/rpmdir
  umount -f $root/proc
  umount $root/sys
  umount -f $root/dev
  set -e
  if test "$ret" = 1; then
    exit 1
  fi
}
mkdir sigs
cd sigs
/usr/lib/rpm/gnupg/dumpsigs /usr/lib/rpm/gnupg/pubring.gpg
cd ..
for i in kde_cd-base gnome_cd-x11 gnome_cd kde_cd; do 
  file=$i-default.%{_target_cpu}.list
  install_repo $PWD/$i $file
  mkdir -p $i-meta/var/lib/rpm $i-meta/var/cache/zypp
  rm -rf $i/var/cache/zypp/raw/
  rm -rf $i/var/cache/zypp/repo.* $i/etc/zypp/repos.d/repo.repo $i/var/cache/zypp/solv/repo
  rm -f $i/var/lib/zypp/AnonymousUniqueId
  mv $i/var/lib/rpm/* $i-meta/var/lib/rpm
  mv $i/var/cache/zypp/* $i-meta/var/cache/zypp
  mv $file $i.rpms
done
rm -rf sigs
perl %SOURCE0 --dst common-desktop --prim kde_cd --sec gnome_cd
perl %SOURCE0 --dst common-xorg --prim gnome_cd-x11 --sec common-desktop
perl %SOURCE0 --dst common-base --prim kde_cd-base --sec common-xorg
# non-confusing names
mv gnome_cd-meta gnome-meta
mv gnome_cd gnome
mv gnome_cd-x11-meta x11-meta
mv gnome_cd-x11 x11
mv gnome_cd-x11.rpms x11.rpms
mv kde_cd-base-meta base-meta
mv kde_cd-base base
mv kde_cd-base.rpms base.rpms
mv kde_cd-meta kde-meta
mv kde_cd kde
mv kde_cd.rpms kde.rpms

%install
mkdir -p $RPM_BUILD_ROOT/CD1/images
COMP="lzma -7 -c -v"
EXT=lzma
cpu=%_target_cpu
case $cpu in
   i*86)
      cpu=i386
      ;;
esac
cat > $RPM_BUILD_ROOT/CD1/images/details-$cpu.xml <<EOF
<?xml version="1.0"?>
<!DOCTYPE details>
<image_installation_details xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
<details config:type="list" >
EOF
for i in *; do 
  test -d $i || continue
  cd $i
  tar cf ../$i.tar *
  cd ..
  $COMP $i.tar > $RPM_BUILD_ROOT/CD1/images/$i-$cpu.tar.$EXT
  usize=$(stat --terse --format=%s $i.tar)
  rm $i.tar
  (
    echo "<image>"
    echo "  <file>$i-$cpu.tar.$EXT</file>"
    case $i in
      *-meta)
        echo "  <rpms config:type=\"list\">"
        for r in `cat ${i/-meta/}.rpms`; do
          echo "    <rpm>$r</rpm>"
        done
        echo "  </rpms>"
        ;;
    esac
    echo "  <size>$usize</size>"
    echo "</image>"
   ) >> $RPM_BUILD_ROOT/CD1/images/details-$cpu.xml
done
cat >> $RPM_BUILD_ROOT/CD1/images/details-$cpu.xml <<EOF
</details>
</image_installation_details>
EOF
cat > $RPM_BUILD_ROOT/CD1/images/images.xml <<EOF
<?xml version="1.0"?>
<!DOCTYPE images>
<image_installation xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
<image_sets config:type="list" >
EOF
for arch in i386 x86_64 ppc; do
  sed -e "s,@ARCH@,$arch,g" %SOURCE1 >> $RPM_BUILD_ROOT/CD1/images/images.xml
done
cat >> $RPM_BUILD_ROOT/CD1/images/images.xml <<EOF
</image_sets>
</image_installation>
EOF
size=`du -s $RPM_BUILD_ROOT/CD1/images/ | cut -f1`
if test $size -gt 460000; then
  echo "this looks unreasonable"
  exit 1
fi

%files
%defattr(-, root, root)
/CD1

%changelog
* Tue Dec 09 2008 coolo@suse.de
- better cleanup of zypp activity during image installation
* Tue Nov 25 2008 coolo@suse.de
- remove the signatures after their use
* Mon Nov 24 2008 coolo@suse.de
- could finally test last change
* Thu Nov 20 2008 coolo@suse.de
- import the build keys
* Wed Nov 05 2008 coolo@suse.de
- revert last change (misunderstood myself)
* Tue Nov 04 2008 coolo@suse.de
- pick the right filename (kde4)
* Tue Nov 04 2008 coolo@suse.de
- exclude ppc as well to save build power
* Thu Oct 30 2008 coolo@suse.de
- don't trigger rebuild on changes of openSUSE-release
* Mon Oct 27 2008 coolo@suse.de
- bump version to 11.1
* Mon Oct 27 2008 coolo@suse.de
- pick one flavor for zypper
* Tue Oct 21 2008 aj@suse.de
- Revert: Make /.build.binaries writeable.  This is handled
  via building as root in the project config.
* Tue Oct 21 2008 coolo@suse.de
- enable size check again, should work fine by now
* Fri Oct 17 2008 aj@suse.de
- Make /.build.binaries writeable.
* Thu Oct 02 2008 cthiel@suse.de
- temp. disable size check
* Wed Oct 01 2008 cthiel@suse.de
- workaround zypper ref segfault (bugreport pending)
* Wed Oct 01 2008 cthiel@suse.de
- use /.build.binaries to get the packages (fix for buildservice)
- workaround bug (bnc#431221)
* Fri Aug 15 2008 coolo@suse.de
- work around zypper sa bug
* Mon Aug 04 2008 coolo@suse.de
- check against too big images directory
* Tue Jun 03 2008 coolo@suse.de
- compare gids too (obvious typo - bnc#396689)
* Fri May 16 2008 coolo@suse.de
- preinit passwd and group to fix e.g. udev installation
* Thu May 15 2008 coolo@suse.de
- remove mountpoint from images (bnc#390635)
* Sat Apr 19 2008 coolo@suse.de
- prepare chroot to avoid broken %%posts
* Thu Apr 17 2008 coolo@suse.de
- apparmor pattern is small enough to be removed after installation
* Tue Apr 15 2008 coolo@suse.de
- fixing DOCTYPE for details
* Mon Apr 14 2008 coolo@suse.de
- write out the details yast needs and nothing more
* Thu Apr 10 2008 coolo@suse.de
- working on gathering informations
* Thu Apr 10 2008 coolo@suse.de
- fixing file names
* Tue Apr 08 2008 coolo@suse.de
- take multiple arch repos into account
* Tue Apr 08 2008 coolo@suse.de
- now that the package lists are trimmed, the intersections
  are smaller, so reduce them and give them speaking names
* Mon Apr 07 2008 coolo@suse.de
- adapt to new file names
* Mon Apr 07 2008 coolo@suse.de
- use the base and x11 patterns of the CD repos
* Thu Apr 03 2008 coolo@suse.de
- use list of patterns
* Tue Apr 01 2008 coolo@suse.de
- put more image sets in the images.xml
* Mon Mar 31 2008 coolo@suse.de
- adding more installation types
* Fri Mar 28 2008 coolo@suse.de
- now that yast2-installation supports lzma, we can go there
* Fri Mar 28 2008 coolo@suse.de
- fix shell syntax
* Thu Mar 27 2008 coolo@suse.de
- package images.xml and ignore the gnome part for now
  (prototyping)
* Sun Mar 23 2008 coolo@suse.de
- initial package
openSUSE Build Service is sponsored by