File openSUSE-release.spec of Package _product

Name:           ___PACKAGE_NAME___
%define product ___PRODUCT_NAME___
License:        BSD 3-Clause
Group:          System/Fhs
Version:        ___VERSION___
# ___RELEASE___ is the product release, not the build release of this package 
Release:        0
Provides:       aaa_version distribution-release
Provides:       suse-release-oss = %{version}-%{release}
Provides:       suse-release = %{version}-%{release}
Obsoletes:      aaa_version
Obsoletes:      openSUSE-release-live <= 11.0
Obsoletes:      openSUSE-Promo-release <= 11.1
Obsoletes:      product_flavor(%{product}) < ___VERSION___
Conflicts:      sles-release <= 10 sled-release <= 10 core-release <= 10
Suggests:       java-1_6_0-openjdk
Suggests:       mysql-community-server
Suggests:       mysql-community-server-client
Recommends:     branding-openSUSE
___PRODUCT_PROVIDES___
___OBSOLETE_PACKAGES___

BuildRequires:  skelcd-control-openSUSE skelcd-openSUSE
AutoReqProv:    on
Summary:        ___SUMMARY___
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
#PreReq:         coreutils
%define betaversion ___BETA_VERSION___
%define codename Mantis

%description
___DESCRIPTION___

___FLAVOR_PACKAGES___

%prep

%build

%install
mkdir -p $RPM_BUILD_ROOT/etc
echo -e 'Welcome to %{product} %{version} "%{codename}" - Kernel \\r (\\l).\n\n' > $RPM_BUILD_ROOT/etc/issue
echo 'Welcome to %{product} %{version} "%{codename}" - Kernel %%r (%%t).' > $RPM_BUILD_ROOT/etc/issue.net
echo "%{product} %{version} (%{_target_cpu})" > $RPM_BUILD_ROOT/etc/SuSE-release

%if 0%{?betaversion:1}
echo -e 'Welcome to %{product} %{version} "%{codename}" %{?betaversion:%{betaversion}}  - Kernel \\r (\\l).\n\n' > $RPM_BUILD_ROOT/etc/issue
echo 'Welcome to %{product} %{version} "%{codename}" %{?betaversion:%{betaversion}}  - Kernel %%r (%%t).' > $RPM_BUILD_ROOT/etc/issue.net
echo "%{product} %{version} %{?betaversion:%{betaversion}} (%{_target_cpu})" > $RPM_BUILD_ROOT/etc/SuSE-release
%endif

echo VERSION = %{version} >> $RPM_BUILD_ROOT/etc/SuSE-release
echo CODENAME = %{codename} >> $RPM_BUILD_ROOT/etc/SuSE-release

# Fill /etc/os-release:
echo NAME=openSUSE > $RPM_BUILD_ROOT/etc/os-release
%if 0%{?betaversion:1}
echo VERSION=\"%{version} %{betaversion} "(%{codename})"\" >> $RPM_BUILD_ROOT/etc/os-release
# VERSION_ID is lower case without spaces
echo VERSION_ID=\"`echo %{version}%{betaversion}|tr '[:upper:]' '[:lower:]'`\"|sed -e 's/ //g;' >> $RPM_BUILD_ROOT/etc/os-release
echo PRETTY_NAME=\"openSUSE %{version} %{betaversion} "(%{codename}) (%{_target_cpu})"\"  >> $RPM_BUILD_ROOT/etc/os-release
%else
echo VERSION=\""%{version} (%{codename})"\" >> $RPM_BUILD_ROOT/etc/os-release
echo VERSION_ID=\"`echo %{version}|tr '[:upper:]' '[:lower:]'`\"|sed -e 's/ //g;' >> $RPM_BUILD_ROOT/etc/os-release
echo PRETTY_NAME=\"openSUSE %{version} "(%{codename}) (%{_target_cpu})\""  >> $RPM_BUILD_ROOT/etc/os-release
%endif
echo ID=opensuse >> $RPM_BUILD_ROOT/etc/os-release
echo ANSI_COLOR=\"0\;32\" >> $RPM_BUILD_ROOT/etc/os-release
echo CPE_NAME=\"cpe:/o:opensuse:opensuse:%{version}\" >> $RPM_BUILD_ROOT/etc/os-release

echo "Have a lot of fun..." > $RPM_BUILD_ROOT/etc/motd
# Bug 404141 - /etc/YaST/control.xml should be owned by some package
mkdir -p $RPM_BUILD_ROOT/etc/YaST2/
echo $RPM_BUILD_ROOT
install -m 644 /CD1/control.xml $RPM_BUILD_ROOT/etc/YaST2/

___CREATE_PRODUCT_FILES___
# this is a base product, create symlink
ln -s openSUSE.prod $RPM_BUILD_ROOT/etc/products.d/baseproduct

%post
test -n "$FIRST_ARG" || FIRST_ARG=$1
# XXX: hack to make sure the non-oss update repo is also added
# after "zypper dup". we need to find a better way ...
if [ $FIRST_ARG -gt 1 ]; then
	file="/etc/zypp/repos.d/repo-update-non-oss.repo"
	if [ ! -e "$file" ]; then
		cat > "$file".new <<-EOF
		# created by openSUSE-release on upgrade
		[repo-update-non-oss]
		name=openSUSE-12.2-Update-Non-Oss
		enabled=1
		autorefresh=1
		baseurl=http://download.opensuse.org/update/12.2-non-oss/
		path=/
		type=rpm-md
		keeppackages=0
		EOF
		mv "$file".new $file
	fi || true
fi

%files
%defattr(644,root,root,755)
%config /etc/SuSE-release
%config /etc/os-release
# Bug 404141 - /etc/YaST/control.xml should be owned by some package
%dir /etc/YaST2/
%config /etc/YaST2/control.xml
%config(noreplace) /etc/motd
%config(noreplace) /etc/issue
%config(noreplace) /etc/issue.net
/etc/products.d