diff options
| author | Christopher Aillon <caillon@redhat.com> | 2011-03-15 09:28:09 -0700 |
|---|---|---|
| committer | Christopher Aillon <caillon@redhat.com> | 2011-03-15 09:28:09 -0700 |
| commit | e911897962f7b1616570e9f2c326d8cce8af808b (patch) | |
| tree | b336ee043ad82168dc4d3bc6cd3a1379005273ba /scripts | |
| download | gecko-maint-e911897962f7b1616570e9f2c326d8cce8af808b.tar.gz gecko-maint-e911897962f7b1616570e9f2c326d8cce8af808b.tar.xz gecko-maint-e911897962f7b1616570e9f2c326d8cce8af808b.zip | |
Initial commit
scripts/moz-grab-langpacks is run to fetch langpack xpi files from
mozilla FTP servers and create a langpack tarball suitable for our
packages
scripts/ff-security-update.sh is run to automate the rebuilds that
need to happen in stable releases every time the gecko version
changes.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/ff-security-update.sh | 99 | ||||
| -rwxr-xr-x | scripts/moz-grab-langpacks | 181 |
2 files changed, 280 insertions, 0 deletions
diff --git a/scripts/ff-security-update.sh b/scripts/ff-security-update.sh new file mode 100755 index 0000000..53b0fef --- /dev/null +++ b/scripts/ff-security-update.sh @@ -0,0 +1,99 @@ +#!/bin/sh +# ff-security-update.sh - A script to automate rebuilds of gecko-dependent packages +# +# Copyright (C) 2007-2011 Red Hat, Inc. +# Author(s): Christopher Aillon <caillon@redhat.com> +# Jan Horak <jhorak@redhat.com> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. See http://www.gnu.org/copyleft/gpl.html for +# the full text of the license. +# + +if [ -z "$1" ]; then + echo "Usage: ff-security-update.sh -b fXX/master old-ver new-ver" +exit +fi +branch= +while getopts 'b:h' OPTION +do + case $OPTION in + b) + branch=$OPTARG + ;; + h) + printf "Usage: %s -b <branch> <old-gecko> <new-gecko>\n" $(basename $0) >&2 + ;; + esac +done +shift $(($OPTIND - 1)) +F12="mozvoikko gnome-web-photo perl-Gtk2-MozEmbed gnome-python2-extras galeon" #7 +F13=$F12 +F14=$F12 +devel=$F12 + +OLDGECKO=`echo $1|sed -e 's/\./\\\./g'` +NEWGECKO=$2 +packages= +if [ $branch = "f12" ]; then + packages=$F12 +elif [ $branch = "f13" ]; then + packages=$F13 +elif [ $branch = "f14" ]; then + packages=$F13 +elif [ $branch = "master" ]; then + packages=$devel +else + printf "Unknown branch: %s\n" $branch + exit 1; +fi + +saved_dir=`pwd` +cd ~/sources/fedoraproject.org +#rm -rf $packages +for package in $packages; do + fedpkg clone $package -B +done +#cvs -d$CVSEXTRAS co $packages +echo "Just did cvs checkout" +for package in $packages; do + cd ~/sources/fedoraproject.org + + # Get a clean and latest version + #rm -rf $package + #cvs -d$CVSEXTRAS co $package + #echo "Just did cvs checkout" + + cd $package/$branch + #sed -i -e "s/\<$OLDGECKO\>/$NEWGECKO/" ${package}.spec + sed '/%changelog/,//d' ${package}.spec > ${package}.spec.new + sed -i -e "s/\b$OLDGECKO[ \t]*$/$NEWGECKO/g" ${package}.spec.new + echo "%changelog" >> ${package}.spec.new + sed '1,/%changelog/d' ${package}.spec >> ${package}.spec.new + mv ${package}.spec.new ${package}.spec + if [ $branch = "F-8" ]; then + sed -i -e "s/$OLDFF/$NEWFF/" ${package}.spec + fi + #echo "Just ran sed for version updates" + rpmdev-bumpspec -c "- Rebuild against newer gecko" ${package}.spec + #echo "Just did bumpspecfile" + fedpkg clog + echo "Review changes:" + echo "-----------------------------------------------------------------------" + git diff + echo "-----------------------------------------------------------------------" + echo "Is it ok to commit [Y/N]? "; read ask + if [ $ask == 'y' ]; then + echo "Commit..." + else + echo "Skipping package: $package" + continue + fi + #echo "Just made clog" + fedpkg commit -F clog -p + fedpkg build --nowait + cd $saved_dir +done +rm -rf $packages diff --git a/scripts/moz-grab-langpacks b/scripts/moz-grab-langpacks new file mode 100755 index 0000000..bf56a6f --- /dev/null +++ b/scripts/moz-grab-langpacks @@ -0,0 +1,181 @@ +#!/usr/bin/python +# moz-grab-langpacks - A script to grab langpacks for Mozilla products +# +# Copyright (C) 2011 Red Hat, Inc. +# Author(s): Christopher Aillon <caillon@redhat.com> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. See http://www.gnu.org/copyleft/gpl.html for +# the full text of the license. + +import argparse +import pyfedpkg +import os +import sys +import subprocess +import glob +import shutil +import datetime +from xml.parsers import expat + +def parse_cmdline(): + parser = argparse.ArgumentParser(description = 'Mozilla Langpack Grabber', + prog = 'moz-grab-langpacks') + + parser.add_argument('-a', '--app', default=None, nargs=2, metavar=('APP', 'VERSION'), + help='Specify an app name and version. Required if the current working directory is not a fedora package directory') + + parser.add_argument('-b', '--build-number', type=int, default=0, + help='Specify the build number to grab langpacks for, useful for guessing the XPI URL if it is not passed.') + + parser.add_argument('-u', '--url', default=None, + help='Specify a URL to download langpacks from') + + parser.add_argument('--bz2', action='store_true', + help='If passed, creates a tar.bz2 instead of tar.xz') + + return parser.parse_args() + +def find_appversion(): + try: + fedpkg = pyfedpkg.PackageModule(os.getcwd(), None) + return (fedpkg.spec.rstrip('.spec'), fedpkg.ver) + except pyfedpkg.FedpkgError, e: + makeverrel = ['make', 'verrel'] + nvr = subprocess.check_output(makeverrel, stderr=None) + nvrlist = nvr.split('-') + count = len(nvrlist) + version = nvrlist[count - 2] + # Get rid of the release, and the version, so we're left with the name + nvrlist.pop(count - 1) + nvrlist.pop(count - 2) + appname = '-'.join(nvrlist) + return (appname, version) + +def guess_xpi_url(app, version, build_number): + if build_number > 0: + url = "ftp://ftp.mozilla.org/pub/mozilla.org/%s/nightly/%s-candidates/build%d/linux-i686/xpi/" % (app, version, build_number) + else: + url = "ftp://ftp.mozilla.org/pub/mozilla.org/%s/releases/%s/linux-i686/xpi/" % (app, version) + return url + +class LangpackXPIParser: + LANGPACK_ERROR_UNKNOWN = -1 + LANGPACK_OK = 0 + LANGPACK_ERROR_XMLDECL = 1 + LANGPACK_ERROR_US_ENGLISH = 2 + + def __init__(self, xpi): + self._xpi = xpi + self._error = self.LANGPACK_OK + self._parser = expat.ParserCreate() + self._parser.XmlDeclHandler = self._xml_handler + self._parser.StartElementHandler = self._elem_handler + self._haveXMLDeclaration = False + + def _extract_langpack(self): + self._tmpdir = "tmp-%s" % self._xpi + unzipcmd = ['unzip', '-qq', '-d', self._tmpdir, self._xpi] + subprocess.call(unzipcmd) + + def _xml_handler(self, version, encoding, standalone): + self._haveXMLDeclaration = True + + def _elem_handler(self, name, attrs): + if name == "Description" and "em:name" in attrs: + if attrs["em:name"] == "English (US) Language Pack": + self._error = self.LANGPACK_ERROR_US_ENGLISH + def parse(self): + try: + self._extract_langpack() + installRDF = "%s/install.rdf" % self._tmpdir + self._file = open(installRDF, 'r') + self._parser.ParseFile(self._file) + if not self._haveXMLDeclaration: + self._error = self.LANGPACK_ERROR_XMLDECL + except expat.ExpatError, e: + self._error = self.LANGPACK_ERROR_UNKNOWN + self._file.close() + return self._error + + def destroy(self): + shutil.rmtree(self._tmpdir) + +def create_langpack_tarball(app, version, url, use_xz=True): + cwd = os.getcwd() + langpackdir="%s-langpacks" % app + os.mkdir(langpackdir) + os.chdir(langpackdir) + + # Gotta catch em all! + print 'Downloading .xpi files...' + acclist = '??.xpi,???.xpi,??-??.xpi' + rejlist = 'en-US.xpi' + wgetcmd = ['wget', '-r', '-nd', '-np', '--accept', acclist, '--reject', rejlist, url] + subprocess.call(wgetcmd) + + # But we don't gotta keep em all + print 'Checking validity of .xpi files...' + readme = open('README', 'w') + readme.write('Generated by moz-grab-langpacks\n\n') + xpis = glob.glob('*.xpi') + xpis.sort() + for xpi in xpis: + parser = LangpackXPIParser(xpi) + rv = parser.parse() + parser.destroy() + if rv == LangpackXPIParser.LANGPACK_OK: + readme.write('%s ACCEPTED\n' % xpi) + elif rv == LangpackXPIParser.LANGPACK_ERROR_XMLDECL: + readme.write('%s REJECTED because the first node is not an XML Declaration\n' % xpi) + elif rv == LangpackXPIParser.LANGPACK_ERROR_US_ENGLISH: + readme.write('%s REJECTED because it is claims to be US English\n' % xpi) + else: + readme.write('%s REJECTED: Unknown Error\n' % xpi) + if rv != LangpackXPIParser.LANGPACK_OK: + os.remove(xpi) + readme.close() + + # Tar them up + print 'Creating tarball...' + os.chdir(cwd) + + if use_xz: + suffix = 'xz' + tarflags = '-cJf' + else: + suffix = 'bz2' + tarflags = '-cjf' + + now = datetime.datetime.now().strftime("%Y%m%d") + tarballname = '%s-langpacks-%s-%s.tar.%s' % (app, version, now, suffix) + tarcmd = ['tar', tarflags, tarballname, langpackdir ] + subprocess.call(tarcmd) + + print "Created %s" % tarballname + shutil.rmtree(langpackdir) + +if __name__ == '__main__': + args = parse_cmdline() + if not args.app: + try: + args.app = find_appversion() + except: + print "Error: Re-run this script from a fedora package directory.\n" \ + "Alternatively, you can pass --app on the command line." + sys.exit(1) + + (app, version) = args.app + if app not in ('firefox', 'thunderbird', 'seamonkey'): + print "Error: App name must be one of 'firefox', 'thunderbird', 'seamonkey'" + sys.exit(1) + + if not args.url: + args.url = guess_xpi_url(app, version, args.build_number) + + use_xz = not args.bz2 + create_langpack_tarball(app, version, args.url, use_xz) + sys.exit(0) + |
