%{!?build_user: %define build_user mockbuild}

%{!?image_name: %define image_name min}
Summary: Image building setup for "%{image_name}" image
Name: %{image_name}-builder
Version: 0.0.3
Release: 1%{?dist}%{?extra_release}
License: GPLv2+
Group: Applications/System
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
URL: http://ovirt.org/
Requires: selinux-policy-targeted
Requires: sudo

## %packages from %{image_name}.ks
# @core
# kernel
# hwdata
# dhclient
# openssh-clients
# openssh-server
# /usr/sbin/lokkit

Requires: kernel
Requires: hwdata
Requires: dhclient
Requires: openssh-clients
Requires: openssh-server
Requires: /usr/sbin/lokkit

# @core resolved:
#Group: Core
# Description: Smallest possible installation
# Mandatory Packages:
Requires: SysVinit
Requires: authconfig
Requires: basesystem
Requires: bash
Requires: coreutils
Requires: cpio
Requires: e2fsprogs
Requires: ed
Requires: file
Requires: filesystem
Requires: glibc
Requires: hdparm
Requires: initscripts
Requires: iproute
#Requires: iprutils
Requires: iputils
Requires: kbd
Requires: kudzu
Requires: libgcc
Requires: libhugetlbfs
Requires: libtermcap
Requires: mkinitrd
Requires: passwd
Requires: policycoreutils
Requires: prelink
Requires: procps
Requires: readline
Requires: redhat-logos
Requires: redhat-release
Requires: redhat-release-notes
Requires: rootfiles
Requires: rpm
Requires: selinux-policy-targeted
Requires: setools
Requires: setserial
Requires: setup
Requires: shadow-utils
Requires: sysklogd
Requires: termcap
Requires: util-linux
Requires: vim-minimal
# Default Packages:
#Requires: Deployment_Guide-en-US
## if arch ia64 ?
#Requires: elilo
#Requires: gnu-efi
#Requires: salinfo
## if arch ppc ?
#Requires: ppc64-utils
#Requires: yaboot
## if arch s390 ?
#Requires: s390utils
Requires: grub
Requires: sysfsutils
Requires: udftools
# Optional Packages:
#   ecryptfs-utils
#   rsyslog

#

#  disable debuginfo, makes no sense for boot image and it is created empty anyway
%define debug_package %{nil}

%description
Prepare chroot for building the "%{image_name}" image.
Adds %{build_user} to sudoers and pulls in all packages listed in image kickstart.

%prep

%build

%post
echo "%{build_user}	ALL=(ALL)	NOPASSWD: ALL" >> /etc/sudoers
# mock has minimal /dev, add loop device nodes
for i in $(seq 0 7); do
  mknod /dev/loop$i b 7 $i
done

if test ! -f /selinux/enforce ; then
  # FROM imgcreate.creator.ImageCreator.__create_selinuxfs()
  # enforce=0 tells the chroot selinux is not enforcing
  # policyvers=999 tell the chroot to make the highest version of policy it can
  mkdir -p /selinux
  printf 0 > /selinux/enforce
  printf 999 > /selinux/policyvers
  printf 1 > /selinux/mls
  # make /load -> /dev/null so chroot policy loads don't hurt anything
  mknod --mode=0666 /selinux/load c 1 3
fi

%install
%{__rm} -rf %{buildroot}
mkdir %{buildroot}

%clean
%{__rm} -rf %{buildroot}

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

%changelog
* Wed Oct 29 2008 Alan Pevec <apevec@redhat.com> 0.0.3-0
- prepare for livecd-creator --global-config --cacheonly

* Tue Oct 07 2008 Alan Pevec <apevec@redhat.com> 0.0.2-0
- fake selinuxfs from imgcreate.creator.ImageCreator.__create_selinuxfs()

* Mon Oct 06 2008 Alan Pevec <apevec@redhat.com> 0.0.1-0
- Initial build.
