#!/bin/sh
# Build all tars required for fedora-release-notes RPM
#
# This script fetches the six documents included in fedora-release-notes.rpm from
# git, makes the omf files for release notes, does all the fedora-docs-utils
# builds, and makes the tarballs which will be included in the rpm.
#
# The script makes no changes to git or CVS and hence may be run recklessly.
#
# Note that the spec file from the previous release is in CVS, not git,
# and will need to be adjusted for the new version.  But also note that
# in the next version, less should be done using fedora-docs-utils
# so this will need to be significantly changes.
#
# Begin by updating the version number and date in rpm-info.xml for
#  - about-fedora
#  - homepage
#  - readme
#  - readme-burning-isos
#  - readme-live-image
#
# You may also need to adjust copyright dates in some of these
#
# in release-notes:
#  - The second string in "sed -i 's|Fedora Release Notes|" ... below must
#    match a string in Article_Info.xml
#  - Since release notes are updated every release, copyright dates
#    and version numbers should be up to date
#
# Change VER and RELDATE below to reflect the current version
#
# If there are changes to available languages, adjust the numerous
#  language strings scattered throughout this file.
#
#
# Once this is done you may then run this script, takes about 20
# minutes.  When done, copy the tarballs to ~/rpmbuild/SOURCES,
# grab the spec, and
#   rpmbuild -ba fedora-release-notes.spec
#
# To publish the rpm, the srpm and specfile are pushed to cvs
# by a packager.
#
# If you wish to test the rpm, it is best to do it on a VM or
# USB stick so the system can be easily reverted to a previous
# version.  A USB stick is especially convenient since the
# persistent overlay can be easily saved off the stick.
#
#
VER="11.0.0"
RELDATE="2009-05-08"
rm -Rf work
mkdir work
rm -Rf tars
mkdir tars
rm -Rf rpm
mkdir rpm
cd work
git clone git://git.fedorahosted.org/git/fedora-doc-utils docs-common
#
#  release-notes
#
# git clone git://git.fedorahosted.org/git/docs/release-notes.git
# pushd release-notes
# # Now make the place where we will build the tar
# TARG="../../tars/fedora-release-notes-${VER}"
# mkdir $TARG
# cp Makefile $TARG
# #  merge in translation repository
# git merge --no-commit origin/f11-tx
# TFXLAN=(as    bn_IN ca    cs    da    de    el    es    fi    fr    gu    he    hi    hr    hu    id    it    ja    kn    ko    ml    mr    ms    nb    nl    or    pa    pl    pt_BR pt    ru    sk    sr_Latn    sr    sv    ta    te    uk    zh_CN zh_TW)
# PUBLAN=(as-IN bn-IN ca-ES cs-CZ da-DK de-DE el-GR es-ES fi-FI fr-FR gu-IN he-IL hi-IN hr-HR hu-HU id-ID it-IT ja-JP kn-IN ko-KR ml-IN mr-IN ms-MY nb-NO nl-NL or-IN pa-IN pl-PL pt-BR pt-PT ru-RU sk-SK sr-Latn-RS sr-RS sv-SE ta-IN te-IN uk-UA zh-CN zh-TW)

# #
# #  Merge the po's and move them to the target
# #
# for NUM in {0..39} ; do
#     mv po/${TFXLAN[${NUM}]}.po po/${PUBLAN[${NUM}]}.po
#     mkdir ${PUBLAN[${NUM}]}
#     for POTFILE in pot/*.pot; do
#         msgmerge po/${PUBLAN[${NUM}]}.po ${POTFILE} | msgattrib --no-obsolete  \
#                  > ${PUBLAN[${NUM}]}/$(basename ${POTFILE} .pot).po
#     done
#     cp -r ${PUBLAN[${NUM}]} $TARG
#   done
# #make update-po-all
# #
# # Build the .omf files
# #
# sed -i 's|Fedora Release Notes|Release Notes for Fedora 11|g' en-US/fedora-release-notes.omf.in
# xml2po -e -o po/release-notes.pot en-US/Release_Notes.xml en-US/Article_Info.xml en-US/rpm-info.xml
# mkdir omf
# for NUM in {0..39} ; do
#   LANG=${PUBLAN[$NUM]}
#   FLAN=${TFXLAN[$NUM]}
#   if [ ! -f po/$LANG.po ]; then cp po/release-notes.pot po/$LANG.po; else msgmerge -U -q po/$LANG.po po/release-notes.pot; touch po/$LANG.po; fi
#   mkdir -p $LANG
#   pushd po && xml2po -e -p $LANG.po ../en-US/fedora-release-notes.omf.in >../$LANG/fedora-release-notes.omf.in && popd
#   sed -e "s!@RELEASE@!$VER!g" $LANG/fedora-release-notes.omf.in > omf/fedora-release-notes-$FLAN.omf
#   sed -i "s!@DATE@!$RELDATE!g" omf/fedora-release-notes-$FLAN.omf
#   sed -i "s!@LANG@!$LANG!g" omf/fedora-release-notes-$FLAN.omf
#   sed -i "s!@LANGC@!$FLAN!g" omf/fedora-release-notes-$FLAN.omf
# done
# sed -e "s!@RELEASE@!$VER!g" en-US/fedora-release-notes.omf.in > omf/fedora-release-notes-C.omf
# sed -i "s!@DATE@!$RELDATE!g" omf/fedora-release-notes-$FLAN.omf
# sed -i "s!@LANG@!en-US!g" omf/fedora-release-notes-$FLAN.omf
# sed -i "s!@LANGC@!C!g" omf/fedora-release-notes-$FLAN.omf
# #
# #  Now move everything to the target
# #
# cp -r en-US $TARG
# cp -r omf $TARG
# cd $TARG
# cd ..
# tar -czf ../rpm/fedora-release-notes-${VER}.tar.gz fedora-release-notes-${VER}
# popd
#
#    homepage
#
git clone git://git.fedorahosted.org/git/docs/homepage.git
pushd homepage
# NOTE: No rule to make as id lv or
# NOTE: failure on bal
LANGS="bn_IN ca cs de el en_US es fi fr gu hr it ja ml ms nb nl pa pl pt_BR pt ru sk sr_Latn sr sv ta uk zh_CN zh_TW"
TARG="../../tars/homepage-${VER}"
mkdir $TARG
mkdir $TARG/homepage
mkdir $TARG/images
mkdir $TARG/img
mkdir $TARG/stylesheet-images
for LANG in $LANGS ; do
  make html-${LANG}
  cp homepage-${LANG}/index.html ${TARG}/homepage/index-${LANG}.html
done
cp homepage-en_US/fedora.css ${TARG}/homepage/homepage.css
cp homepage-en_US/stylesheet-images/* ${TARG}/stylesheet-images/
cp startpage-images/* ${TARG}/images/
cp img/* ${TARG}/img/
cd $TARG
cd ..
tar -czf ../rpm/homepage-${VER}.tar.gz homepage-${VER}
popd
#
#  README
#
git clone git://git.fedorahosted.org/git/docs/readme.git
pushd readme
make txt
TARG="../../tars/README-${VER}"
mkdir $TARG
cp *.txt $TARG/
cd $TARG
cd ..
tar -czf ../rpm/README-${VER}.tar.gz README-${VER}
popd
#
#  README-BURNING-ISOS
#
git clone git://git.fedorahosted.org/git/docs/readme-burning-isos.git
pushd readme-burning-isos
make txt
TARG="../../tars/README-BURNING-ISOS-${VER}"
mkdir $TARG
cp *.txt $TARG/
cd $TARG
cd ..
tar -czf ../rpm/README-BURNING-ISOS-${VER}.tar.gz README-BURNING-ISOS-${VER}
popd
#
#  readme-live-image
#
git clone git://git.fedorahosted.org/git/docs/readme-live-image.git
pushd readme-live-image
make txt
TARG="../../tars/readme-live-image-${VER}"
mkdir $TARG
cp *.txt $TARG/
cd $TARG
cd ..
tar -czf ../rpm/readme-live-image-${VER}.tar.gz readme-live-image-${VER}
popd
#
#    about-fedora
#
git clone git://git.fedorahosted.org/git/docs/about-fedora.git
pushd about-fedora
#make xml-all
#make omf
make release-pkg
LANGS="bn_IN ca cs de el en_US es fi fr gu hr it ja ml ms nb nl or pa pl po pt pt_BR ro ru sk sr sr_Latn sv ta uk zh_CN zh_TW"
TARG="../../tars/about-fedora-${VER}"
mkdir $TARG
mkdir $TARG/about-fedora
for LANG in $LANGS ; do
  #cp ${LANG}/about-fedora.omf ${TARG}/about-fedora-${LANG}.omf
  mkdir ${TARG}/about-fedora/${LANG}
  cp ${LANG}/about-fedora.xml ${TARG}/about-fedora/${LANG}/
done;
mkdir ${TARG}/about-fedora/C
cp en_US/about-fedora.xml ${TARG}/about-fedora/C/
cp about-fedora-/* ${TARG}
cd $TARG
cd ..
tar -czf ../rpm/about-fedora-${VER}.tar.gz about-fedora-${VER}
popd

