From 751f1159831bb0645e019b1fc5581f4cb1e9d9b4 Mon Sep 17 00:00:00 2001 From: Nick White Date: Thu, 16 Jun 2011 01:29:43 +0100 Subject: Basic firefox update support, minor css update --- Makefile | 18 ++++++++++++++++-- gecko/genpub.sh | 11 +++++++++++ gecko/gensig.sh | 22 ++++++++++++++++++++++ gecko/install.ttl | 4 +++- gecko/updates.ttl | 20 ++++++++++++++++++++ simplyread.js | 2 +- 6 files changed, 73 insertions(+), 4 deletions(-) create mode 100755 gecko/genpub.sh create mode 100755 gecko/gensig.sh create mode 100644 gecko/updates.ttl diff --git a/Makefile b/Makefile index a4c1629..c880959 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,21 @@ NAME = simplyread -VERSION = 0.4 +VERSION = 0.5 WEBSITE = http://njw.me.uk/software/$(NAME)/ KEYFILE = private.pem all: web/chromium-updates.xml web/index.html dist xpi crx +# TODO: test makefile dependency is portable (and correct) +web/gecko-updates.rdf: web/$(NAME)-$(VERSION).xpi + /tmp/uhura -o $@ -k $(KEYFILE) web/$(NAME)-$(VERSION).xpi $(WEBSITE)/$(NAME)-$(VERSION).xpi + +# gensig not working yet +#web/gecko-updates.rdf: gecko/updates.ttl +# sed -e "s/VERSION/$(VERSION)/g" \ +# -e "s/HASH/`sha1sum web/$(NAME)-$(VERSION).xpi|awk '{print $$1}'`/g" \ +# -e "s/SIG/`sh gecko/gensig.sh gecko/updates.ttl $(KEYFILE)`/g" \ +# < $< | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null > $@ + web/chromium-updates.xml: chromium/updates.xml sed "s/VERSION/$(VERSION)/g" < $< > $@ @@ -38,7 +49,10 @@ xpi: cp gecko/chrome/content/simplyread.xul gecko-build/chrome/content/ cp simplyread.js gecko-build/chrome/content/ rsvg -w 22 -h 22 icon.svg gecko-build/chrome/content/icon.png - sed "s/VERSION/$(VERSION)/g" < gecko/install.ttl | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null > gecko-build/install.rdf + #rsvg -w 64 -h 64 icon.svg gecko-build/icon.png + cp icon.svg gecko-build/icon.svg + sed -e "s/VERSION/$(VERSION)/g" -e "s/PUBKEY/`sh gecko/genpub.sh $(KEYFILE)`/g" \ + < gecko/install.ttl | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null > gecko-build/install.rdf cd gecko-build; zip -r ../web/$(NAME)-$(VERSION).xpi . 1>/dev/null gpg -b < web/$(NAME)-$(VERSION).xpi > web/$(NAME)-$(VERSION).xpi.sig rm -rf gecko-build diff --git a/gecko/genpub.sh b/gecko/genpub.sh new file mode 100755 index 0000000..12768dd --- /dev/null +++ b/gecko/genpub.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if test $# -ne 1; then + echo "Usage: $0 pem" + echo "Outputs a public key suitable for use in install.rdf" + exit 1 +fi + +openssl rsa -pubout -outform DER < "$1" 2>/dev/null \ +| openssl enc -e -a 2>/dev/null \ +| awk '{printf("%s", $0)}' | sed 's/\//\\\//g' diff --git a/gecko/gensig.sh b/gecko/gensig.sh new file mode 100755 index 0000000..13c0447 --- /dev/null +++ b/gecko/gensig.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Currently not working - using uhura instead. + +if test $# -ne 2; then + echo "Usage: $0 update.rdf pem" + echo "Outputs a signature suitable for use in update.rdf" + exit 1 +fi + +# serialise all but the signature entry +# in mccoy this is serializeResource(), in mexumgen it's ser() +# exerything else seems to rewrite things, but we *might* get away with sed-ing away the bad line and outputting as rdfxml +# sha512 hash +# sign the hash +# der encode & base64 + +sed '/em:signature/d' < "$1" | rapper -i turtle -o rdfxml /dev/stdin 2>/dev/null \ +| sha512sum \ +| openssl sha1 -sha1 -binary -sign "$2" \ +| openssl enc -e -a 2>/dev/null \ +| awk '{printf("%s", $0)}' | sed 's/\//\\\//g' diff --git a/gecko/install.ttl b/gecko/install.ttl index 655f3d6..dc40853 100644 --- a/gecko/install.ttl +++ b/gecko/install.ttl @@ -13,5 +13,7 @@ em:name "SimplyRead"; em:description "Stop browsing, start reading. Press Ctrl-Alt-r or click the 'sr' icon in the status bar to toggle SimplyRead."; em:creator "Nick White"; - em:homepageUrl "http://njw.me.uk/software/simplyread/"; + em:homepageURL "http://njw.me.uk/software/simplyread/"; + em:updateURL "http://njw.me.uk/software/simplyread/gecko-updates.rdf"; + em:updateKey "PUBKEY"; . diff --git a/gecko/updates.ttl b/gecko/updates.ttl new file mode 100644 index 0000000..34325db --- /dev/null +++ b/gecko/updates.ttl @@ -0,0 +1,20 @@ +# currently not used as uhura is generating it. + +@prefix rdf: . +@prefix em: . + + + em:signature "SIG"; + em:updates [ a rdf:Seq ; + rdf:li <:VERSION>; + ]. + +<:VERSION> + em:version "VERSION"; + em:targetApplication [ + em:id "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; + em:minVersion "3.0"; + em:maxVersion "4.0.*"; + em:updateLink "http://njw.me.uk/simplyread/simplyread-VERSION.xpi"; + em:updateHash "sha1:HASH"; + ]. diff --git a/simplyread.js b/simplyread.js index cc3c730..f7e3d3e 100755 --- a/simplyread.js +++ b/simplyread.js @@ -64,7 +64,7 @@ function simplyread() doc.body.innerHTML = "" + "