#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 DEBIANDIR = $(CURDIR)/debian LINKDIR = $(DEBIANDIR)/moodle-locale- ZIPSDIR = $(CURDIR)/zips MOODLELANGDIR = var/lib/moodle/lang FETCHADDRESS = http://download.moodle.org/lang16/ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir # Add here commands to compile the package. touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp # Add here commands to clean up after the build process. #-$(MAKE) clean @set -e; cd $(DEBIANDIR) ; \ RMDIRS=`find . -mindepth 1 -maxdepth 1 -type d -printf "%P\n" |sed -n "/^moodle-locale-/p" | tr "\n" " "` ; \ echo "Clean-up $${RMDIRS} from previous package building..." ; \ for dir in $${RMDIRS} ; do \ rm -rf "$${dir}" ; \ done @set -e; if ! diff $(DEBIANDIR)/locales.desired $(DEBIANDIR)/locales.packaged > /dev/null ; then \ echo "-----------------------------------------------------------------" ; \ echo "Desired locales and packaged locales do not match. It's a PROBLEM" ; \ echo "You have to execute fakeroot debian/rules update-zips maybe " ; \ echo "-----------------------------------------------------------------" ; \ exit 1 ; \ fi dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs @set -e; LANGUAGES="`cat $(DEBIANDIR)/locales.desired`" ; \ for lang in $${LANGUAGES} ; do \ ZIPFILE="$(ZIPSDIR)/$${lang}_utf8.zip" ; \ echo "Processing locale $${lang}" ; \ mkdir -p $(LINKDIR)$${lang}/$(MOODLELANGDIR) ; \ if [ -f $${ZIPFILE} ] ; then \ echo "Zip file for locale $$lang exists" ; \ unzip -q -o -d $(LINKDIR)$${lang}/$(MOODLELANGDIR) $${ZIPFILE} ; \ echo "Deleting problematic files..." ;\ find $(LINKDIR)$${lang}/$(MOODLELANGDIR) -name ".cvsignore" -exec rm {} \; ; \ echo "Fixing execution permission of upstream files" ; \ find $(LINKDIR)$${lang}/$(MOODLELANGDIR) -type f -exec chmod -x {} \; ; \ else \ echo "Zip file for locale $$lang does not exists" ; \ exit 1 ; \ fi ; \ done # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_link dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture-dependent files here. binary-arch: build install # We have nothing to do because architecture is all. clean-zips: dh_testdir rm -f $(CURDIR)/zips/* update-zips: wget update-debian-files update-changelog wget: @set -e; LANGUAGES="`cat $(DEBIANDIR)/locales.desired`" ; \ for lang in $${LANGUAGES} ; do \ if [ "$${lang}" != "qcv" ] ; \ then \ echo "Downloading $${lang} moodle translation file." ; \ if ! wget --quiet -N -P $(CURDIR)/zips $(FETCHADDRESS)$${lang}_utf8.zip ; \ then \ echo "Problem downloading zipfile for locale $${lang}" ; \ echo "Fix locales debian/locales.desired file" ; \ exit 1 ; \ fi ; \ else \ if [ ! -f "$(ZIPSDIR)/qcv_utf8.zip" ] ; \ then \ echo "Valencian zipfile not found. Please add the zipfile" ; \ exit 1 ; \ else \ echo "Valencian zipfile found. Ok" ; \ fi ; \ fi ; \ done update-debian-files: cp -f $(CURDIR)/debian/templates/control.template $(CURDIR)/debian/control -mv -f $(CURDIR)/debian/locales.packaged $(CURDIR)/debian/locales.packaged.old @set -e; LANGUAGES="`cat $(DEBIANDIR)/locales.desired`" ; \ for lang in $${LANGUAGES} ; do \ if [ ! -f "$(ZIPSDIR)/$${lang}_utf8.zip" ] ; then \ echo "Some zipfile missing. Execute fakeroot debian/rules wget after" ; \ exit 1 ; \ else \ CURLOCALE="$${lang}" ; \ CURLANG="$${CURLOCALE}" ; \ CURLOCALESMALL=`echo $${CURLOCALE} | tr "[:upper:]" "[:lower:]"` ; \ CURLANGXPATH=`xpath -q -e "//*[@iso_639_1_code=\"$$CURLANG\"]/@name" /usr/share/xml/iso-codes/iso_639.xml` ; \ [ "$${CURLANG}" = "qcv" ] && CURLANGXPATH=" name=\"Valencian\"" ; \ [ "$${CURLANG}" = "ca" ] && CURLANGXPATH=" name=\"Catalan\"" ; \ CURLANGNAME=`printf "%s" "$${CURLANGXPATH}" | sed 's/ name="// ; s/"//'` ; \ if [ -e $(CURDIR)/debian/templates/$${CURLOCALESMALL}/control ] ; \ then cat $(CURDIR)/debian/templates/$${CURLOCALESMALL}/control >> $(CURDIR)/debian/control ; \ else \ sed "s/CURLOCALESMALL/$${CURLOCALESMALL}/g;s/CURLOCALE/$${CURLOCALE}/g;s/CURLANGNAME/$${CURLANGNAME}/g;s/CURLANG/$${CURLANG}/g" \ $(CURDIR)/debian/templates/package.template >> $(CURDIR)/debian/control; \ fi; \ echo $${CURLOCALE} >> $(CURDIR)/debian/locales.packaged ; \ if [ -e $(CURDIR)/debian/templates/$${CURLOCALESMALL}/README.Debian ] ;\ then cp -f $(CURDIR)/debian/templates/$${CURLOCALESMALL}/README.Debian $(CURDIR)/debian/moodle-locale-$${CURLOCALESMALL}.README.Debian ; \ fi ; \ fi ; \ done update-changelog: @set -e; ADDED="`diff $(DEBIANDIR)/locales.packaged.old $(DEBIANDIR)/locales.packaged | sed -n "/^>/ s%> %%p" | tr "\n" " " `" ; \ CONTENT_ADDED="" ; \ for d in $${ADDED} ; do \ CONTENT_ADDED="Moodle support for language $${d} added @ $${CONTENT_ADDED}" ; \ done ; \ REMOVED="`diff $(DEBIANDIR)/locales.packaged.old $(DEBIANDIR)/locales.packaged | sed -n "/^