#! /bin/sh rm -rf mozvoikko rm -f targets.tmp mkdir mozvoikko || exit 1 version= # Merges contents of incoming mozvoikko XPI packages (duplicate # files are overwritten without asking). Extracts em:targetPlatform # elements into a separate temporary file. for file in in/mozvoikko-*.xpi; do if ! ( cd mozvoikko && unzip -oq ../$file ); then echo "Failed to upzip $file" exit 1 fi dos2unix -q mozvoikko/install.rdf currver=$(grep '' mozvoikko/install.rdf |\ sed -e 's#[ ]*\(.*\)[ ]*$#\1#') if test "$currver" != "$version"; then if test "$version" != ""; then echo "Mixed versions" exit 1 fi version=$currver fi grep '' mozvoikko/install.rdf >>targets.tmp done # It is assumed for simplicity that install.rdf of source XPI packages contains exactly one # line with specified em:targetPlatform XML element. This condition is not verified. cat mozvoikko/install.rdf | awk 'BEGIN{on=1} //{on=0} {if (on) {print}}' >install.rdf cat targets.tmp >>install.rdf rm -f targets.tmp cat mozvoikko/install.rdf | awk 'BEGIN{on=0} {if (on) {print}} //{on=1}' >>install.rdf # Verify whether one can parse generated install.rdf file if ! xmllint --noout install.rdf ; then echo "Failed to parse generated RDF file" exit 1 fi # Generate merged XPI package. mv -f install.rdf mozvoikko/install.rdf rm -f mozvoikko-$version.xpi if ! ( cd mozvoikko && find . -type f | sed -e 's:^\./::' | zip -9@ ../mozvoikko-$version.xpi ) ; then echo "Failed to create merged XPI package" fi