File skelcd-education-desktop.spec of Package skelcd-education-desktop

#
# spec file for package skelcd-education-desktop 
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#

# norootforbuild

Name:           skelcd-education-desktop
Summary:        CD skeleton for Education Desktop Add on CD
License:        GPLv2
Group:          Metapackages
Version:        %suse_version
Release:        0
Conflicts:      skelcd-SUSE_Linux skelcd skelcd-SUSE_Linux-Addon skelcd-sles
BuildRequires:  recode zip gpg unix2dos
%if 0%{?suse_version} == 1020
BuildRequires:  opensuse-education-docu
%endif
AutoReqProv:    off
Source:         license-education.tar.bz2
Source1:        docu-education.tar.bz2
#Source2:       autoyast.tar.bz2
Source10:       README.BETA
Source11:       README.txt
Source12:       README.de
Source13:       README.it
Source100:      GPL.txt
Source101:      autorun.sh
Source102:      installation.xml
Source106:      gpg-pubkey-b7005b33-46554e84.asc
Source107:      oss-edu.ico
Source108:      autorun.inf
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         edu_version 1.0

%description
This package contains the CD content which is not placed as RPM on the media: 

* README, README.BETA files

* Documentation (=> docu directory)

* License files

* installation.xml file for YaST2


Authors:
--------
    Lars Vogdt

%if 0%{?suse_version} > 1140
%define         distribution_name openSUSE
%define         distribution_version 12.0
%define         distribution_release "Alpha0"
%endif
%if 0%{?suse_version} > 1140
%define         distribution_name openSUSE
%define         distribution_version 11.4
%define         distribution_release "Alpha0"
%endif
%if 0%{?suse_version} == 1130
%define         distribution_name openSUSE
%define         distribution_version 11.3
%define         distribution_release "Alpha0"
%endif
%if 0%{?suse_version} == 1120 
%define         distribution_name openSUSE
%define         distribution_version 11.2
%define         distribution_release "Alpha0"
%endif
%if 0%{?suse_version} == 1110 
%define         distribution_name openSUSE
%define         distribution_version 11.1
%define         distribution_release "RC1"
%endif
%if 0%{?suse_version} == 1100 
%define         distribution_name openSUSE
%define         distribution_version 11.0
%define         distribution_release "RC2"
%endif
%if 0%{?suse_version} == 1030 
%define         distribution_name openSUSE
%define         distribution_version 10.3
%define         distribution_release "RC5"
%endif
%if 0%{?suse_version} == 1020
%define         distribution_name openSUSE
%define         distribution_version 10.2
%define         distribution_release "RC2"
%endif
%if 0%{?sles_version} == 10
%define         distribution_name SLE
%define         distribution_version 10.1
%define         distribution_release "RC2"
%endif


%prep
%setup -n skelcd  -a1 
# -a2 
install -m 644 %{SOURCE10} .
install -m 644 %{SOURCE11} .
install -m 644 %{SOURCE12} .
install -m 644 %{SOURCE13} .
%if 0%{?suse_version} > 1030
install -m 644 %{SOURCE102} .
%endif
find -type d -name .svn -print0 | xargs -0 rm -rf {} \;

%build

%install
# create needed directories first
install -dD 755 %buildroot/CD1/docu
install -dD 755 %buildroot/CD1/license-education
install -dD 755 %buildroot/CD1/media.1
#
# now copy the sources
#
cp docu/*                    %buildroot/CD1/docu
%if 0%{?suse_version} == 1020
install -m644 /usr/share/doc/opensuse-education-docu/*.pdf %buildroot/CD1/docu/
%endif
cp license-education/*       %buildroot/CD1/license-education
#cp autoyast/*                %buildroot/CD1/
install -m 644  %{SOURCE100} %buildroot/CD1
install -m 644  %{SOURCE101} %buildroot/CD1
install -m 644  %{SOURCE107} %buildroot/CD1
install -m 644  %{SOURCE108} %buildroot/CD1
# to be shure that autorun.inf works on Windows-Boxes:
unix2dos %buildroot/CD1/autorun.inf
#
# adapt READMEs and License files
#
DATE_ENG=`date +"%%Y/%%m/%%d"`
DISTRIBUTION_VERSION=%distribution_version
DISTRIBUTION_NAME=%distribution_name
EDUCATION_VERSION=%edu_version

if [[ %distribution_release != RC* ]]; then
    DISTRIBUTION_RELEASE=%distribution_release
    PRODUCT_VERSION=$EDUCATION_VERSION-$DISTRIBUTION_RELEASE
else
    DISTRIBUTION_RELEASE=""
    PRODUCT_VERSION=$EDUCATION_VERSION
fi

# Create media.1/products file
echo "/ openSUSE-EDU-Add-on $EDUCATION_VERSION" > %buildroot/CD1/media.1/products 
#
# Create content file
%if 0%{?suse_version} < 1110
cat > %buildroot/CD1/content << EOF
PRODUCT openSUSE-EDU-Addon
VERSION $EDUCATION_VERSION 
VENDOR  openSUSE-Education Community
RELNOTESURL http://www.opensuse-education.org/download/relnotes/%edu_version/$DISTRIBUTION_VERSION/release-notes-edu.rpm
%ifarch x86_64
ARCH.x86_64 x86_64 i686 i586 i486 i386 noarch
%endif
ARCH.i686 i686 i586 i486 i386 noarch
ARCH.i586 i586 i486 i386 noarch
ARCH.i486 i486 i386 noarch
ARCH.i386 i386 noarch
%ifarch x86_64
DEFAULTBASE x86_64
%else
DEFAULTBASE i586
%endif
EOF
case $DISTRIBUTION_NAME in
  SLE*)
      case $DISTRIBUTION_VERSION in
          10)
              echo "REQUIRES %distribution_name = %distribution_version" >> %buildroot/CD1/content
              echo "PROVIDES openSUSE-Edu = $EDUCATION_VERSION"          >> %buildroot/CD1/content
              DISTRIBUTION_VERSION="SUSE LINUX Enterprise 10"
          ;;
          10.1)
              echo "REQUIRES product:SUSE_SLE >= %distribution_version" >> %buildroot/CD1/content
              echo "PROVIDES product:openSUSE-Edu = $EDUCATION_VERSION" >> %buildroot/CD1/content
              DISTRIBUTION_VERSION="SUSE LINUX Enterprise 10"
          ;;
      esac
  ;;
  *SUSE*)  
    case $DISTRIBUTION_VERSION in 
        10) # Enterprise version - not tested yet (TODO)
            echo "REQUIRES %distribution_name = %distribution_version" >> %buildroot/CD1/content
            echo "PROVIDES openSUSE-Edu = $EDUCATION_VERSION"          >> %buildroot/CD1/content
        ;;
        10.1|10.2) # 10.1 and 10.2 doesn't know anything about "product"
            echo "REQUIRES %distribution_name = %distribution_version" >> %buildroot/CD1/content
            echo "PROVIDES openSUSE-Edu = $EDUCATION_VERSION"          >> %buildroot/CD1/content
        ;;
		11.*)
            echo "REQUIRES product:%distribution_name = %distribution_version openSUSE-Education-release" >> %buildroot/CD1/content
            echo "PROVIDES product:openSUSE-Edu = $EDUCATION_VERSION"          >> %buildroot/CD1/content
            echo "PATTERNS education-full" >> %buildroot/CD1/content
		;;
        *)
            echo "REQUIRES product:%distribution_name = %distribution_version openSUSE-Education-release" >> %buildroot/CD1/content
            echo "PROVIDES product:openSUSE-Edu = $EDUCATION_VERSION"          >> %buildroot/CD1/content
        ;;
    esac
  ;;
esac
cat >> %{buildroot}/CD1/content << EOF
RECOMMENDS pattern:education-full
LABEL openSUSE Education Addon $EDUCATION_VERSION for $DISTRIBUTION_VERSION 
DESCRDIR suse/setup/descr
DATADIR suse
FLAGS update
LANGUAGE en_US
EOF
%else
cat > %buildroot/CD1/content << EOF
CONTENTSTYLE  11
NAME          openSUSE-Education
VERSION       $EDUCATION_VERSION
RELEASE       0
DISTRIBUTION  openSUSE-Education
SUMMARY       openSUSE Education Add on
DESCRDIR      suse/setup/descr
DATADIR       suse
LABEL         openSUSE-Education $EDUCATION_VERSION
VENDOR        openSUSE-Education
BASEARCHS     i586 x86_64
REFERENCES    openSUSE-Education-release = 1.0
PATTERNS      education-full
RELNOTESURL   http://www.opensuse-education.org/download/relnotes/%edu_version/%{distribution_version}/release-notes-edu.rpm
EOF
%endif
#
# Apapt README files
#
for i in README* ; do
 sed -e "s@__DATE__@$DATE_ENG@g" \
     -e "s@__VERSION__@$DISTRIBUTION_VERSION@g" \
     -e "s@__EDUVERSION__@$EDUCATION_VERSION@g" \
     -e "s@__RELEASE__@$DISTRIBUTION_RELEASE@g" $RPM_SOURCE_DIR/$i \
    > %buildroot/CD1/$i
 cp %buildroot/CD1/$i %buildroot/CD1/$i.mac
 recode utf8..mac %buildroot/CD1/$i.mac
 mv %buildroot/CD1/$i.mac %buildroot/CD1/${i/.txt/}.mac.txt
 unix2dos %buildroot/CD1/$i
done
#
# Adapt media.1/media file
#
FULLDATE="$(date +"%Y%m%d%H%M")00"
echo "openSUSE-Education Community" > %buildroot/CD1/media.1/media
echo "$FULLDATE" >> %buildroot/CD1/media.1/media
echo "1" >> %buildroot/CD1/media.1/media 
#
# Copy licenses
#
for i in license-education/license* ; do
 sed -e "s@__DATE__@$DATE_ENG@g" \
     -e "s@__VERSION__@$DISTRIBUTION_VERSION@g" \
     -e "s@__EDUVERSION__@$EDUCATION_VERSION@g" \
     -e "s@__RELEASE__@${DISTRIBUTION_RELEASE}@g" $RPM_BUILD_DIR/skelcd/$i \
    > $i.new
    mv $i.new $i
done
%if 0%{?suse_version} < 1100
(cd license-education;zip -9 license.zip *txt;cp license.zip %{buildroot}/CD1/media.1/)
%else
(cd license-education;tar -czf license.tar.gz *txt; cp license.tar.gz %{buildroot}/CD1/)
%endif
rm -rf %buildroot/CD1/license-education
#
# copy gpg-keys
#
install -m 644 %{SOURCE106} %buildroot/CD1
install -m 644 %{SOURCE106} %buildroot/CD1/content.key
install -m 644 %{SOURCE106} %buildroot/CD1/media.1/products.key
install -d ~/.gnupg
touch %buildroot/CD1/pubring.gpg
gpg --no-options --no-default-keyring --keyring %buildroot/CD1/pubring.gpg --fast-import %{SOURCE106}
#test -s /usr/lib/rpm/gnupg/pubring.gpg || exit 1
#cp -v /usr/lib/rpm/gnupg/pubring.gpg %{buildroot}/CD1/
#(cd %{buildroot}/CD1 ; /usr/lib/rpm/gnupg/dumpsigs ./pubring.gpg >/dev/null 2>&1 ; /usr/lib/rpm/gnupg/dumpsigs ./pubring.gpg )
#pwd
rm -rf ~/.gnupg
test -f %buildroot/CD1/pubring.gpg~ && rm %buildroot/CD1/pubring.gpg~

#
# prepare Beta-Popup
#
if [[ %distribution_release != RC* ]]; then
    cp %buildroot/CD1/README.BETA %buildroot/CD1/media.1/info.txt
    mkdir -p %buildroot/CD1/suse/setup/descr
    cp %buildroot/CD1/README.BETA %buildroot/CD1/suse/setup/descr/common.war
else
    rm %buildroot/CD1/README.BETA*
fi

%clean 
rm -rf %buildroot;

%files
%defattr(644,root,root,755)
/CD1

%changelog
openSUSE Build Service is sponsored by