summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-10-03 14:24:48 -0300
committerdrebs <drebs@leap.se>2013-10-04 14:25:08 -0300
commit3c23f4aa7eeabff0382f7789cfb7ad0c3090615a (patch)
treeb7970f3d7fef0ceabb4293f135c97f257fe6baef /Makefile
Initial import.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 62 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7d23b14
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+EXTNAME := bitmask-thunderbird
+PREFIX := .
+FILES_TO_PACKAGE := chrome,chrome.manifest,install.rdf
+RSA_FILE := META-INF/zigbert.rsa
+
+# the following variables are updated automatically
+COMMIT := $(shell git --no-pager log -1 --format=format:%h)
+VERSION := $(shell grep \<em:version\> $(PREFIX)/install.rdf | sed -e s/[^\>]\\\+\>// -e s/\<[^\>]\\\+\>//)
+PKGNAME := $(EXTNAME)-$(VERSION)-$(COMMIT).xpi
+TARGET := $(CURDIR)/build/$(PKGNAME)
+TEMPDIR := $(shell mktemp -d -u)
+
+# make sure CERTDIR and CERTNAME are defined for signing
+USAGE := "Usage: make CERTDIR=<certificate directory> CERTNAME=<certificate name> DEFAULTKEY=<key id>"
+ifeq ($(MAKECMDGOALS),signed)
+ifndef CERTDIR
+ $(error $(USAGE))
+endif
+ifndef CERTNAME
+ $(error $(USAGE))
+endif
+ifndef DEFAULTKEY
+ $(error $(USAGE))
+endif
+endif
+
+# make sure DEFAULTKEY was given to sign the calculated hashes
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),upload)
+ifndef DEFAULTKEY
+ $(error "Usage: make DEFAULTKEY=<key id>")
+endif
+endif
+endif
+
+# main rule
+all: clean $(TARGET)
+
+# main target: .xpi file
+
+$(TARGET): clean
+ mkdir -p $(TEMPDIR)
+ cp -r $(PREFIX)/{$(FILES_TO_PACKAGE)} $(TEMPDIR)/
+ (cd $(TEMPDIR) && zip -r $(TARGET) ./)
+ rm -rf $(TEMPDIR)
+ (cd build/ && sha512sum $(PKGNAME) > SHA512SUMS && gpg --default-key $(DEFAULTKEY) --sign SHA512SUMS)
+
+signed: clean
+ mkdir -p $(TEMPDIR)
+ cp -r $(PREFIX)/{$(FILES_TO_PACKAGE)} $(TEMPDIR)/
+ signtool -d $(CERTDIR) -k $(CERTNAME) $(TEMPDIR)/
+ (cd $(TEMPDIR) && zip $(TARGET) ./$(RSA_FILE) && zip -r -D $(TARGET) ./ -x ./$(RSA_FILE))
+ rm -rf $(TEMPDIR)
+ (cd build/ && sha512sum $(PKGNAME) > SHA512SUMS && gpg --default-key $(DEFAULTKEY) --sign SHA512SUMS)
+
+clean:
+ rm -f $(TARGET) build/*
+
+upload:
+ scp build/* downloads.leap.se:~/public/thunderbird_extension/
+
+.PHONY: all clean signed