From f0fa241751a1cf8dbae4a71994ce1e7be4fbdcde Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sat, 29 Jan 2011 09:32:21 +0000 Subject: [PATCH] Build a signed index in jar format, to be used by the next version of the client --- config.sample.py | 9 +++++++++ getsig/getsig.class | Bin 2690 -> 2933 bytes getsig/getsig.java | 45 ++++++++++++++++++++++++++++++-------------- update.py | 29 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 14 deletions(-) diff --git a/config.sample.py b/config.sample.py index 7bd574c6..0001a802 100644 --- a/config.sample.py +++ b/config.sample.py @@ -17,6 +17,15 @@ The official FDroid repository. Applications in this repository are official binaries built by the original application developers. """ +#The key (from the keystore defined below) to be used for signing the +#repository itself. Can be none for an unsigned repository. +repo_keyalias = None + +#If you're building a signed repository, you need the public key here. You +#can get the public key in the correct format by using 'getsig -f x.jar" where +#x.jar is any jar you have signed with it. +repo_pubkey = 'not set' + #The keystore to use for release keys when building. This needs to be #somewhere safe and secure, and backed up! keystore = "/home/me/somewhere/my.keystore" diff --git a/getsig/getsig.class b/getsig/getsig.class index ecd9f4ec06b571ddc245d25cc1a51ae8f023c9df..832b08c51498f6c6b05cc454319269ee281c3fe7 100644 GIT binary patch delta 1741 zcma)+TWnNC7{`CJdv@pS=_zb43mnR2TW)Qkv=nJ!p(2-Zv$P83(iZ6j%C&MUprEjb zDBcm)8wH`DcJ)CG7`JFi)tG2B;mt=)Aki2fF)_ghTEC%)J|J3~l{TwPfz^gn=TJ|B32V&QBL-Vzv(~23p^0Wq%Q8b=XS3d+l?^6rG+~owvqLUh zOxS8TZJI|N#uN?cJnB`=%g6^0lR=ZFDK&w8Fo1{xsQw z%iElBIm>C6PEIA7eO`JA=UmS7j?25empJN++Fc|KaxC$&uh`$k`-yA5QU2V9szg&@ zRARBeOl2Lvo|QP@kB$zu?%dPd)~<-;SN*ecP0NU9 zuPE%bI&lj9rBz9$74`-?86!!iFNME@!56VI11W;mC3K-xT4hxv;{&LD8|@)fH?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GP3ni!5h^@`$eZ`q2g89S)2R{*( znh3Zr;E{Htu2fHY#+dmHuAn=I$8!m9wY#qCD!$&u7tt}*U6aF#dcvN|_!Vc^VOF-{ zM+&0eus4TumbK>nKyXHmnP+Jz4Dh`b_0vBA3PM-Akn`7J!I;6!Lr!VXc>G}pMWa&eJ znTH$vVP7btz5OA7z`nqYKs@B{3)s6SumVeEd8#L5P1A(s>HAmSQLQHO=YtPjA{^C$ zayiv9HRYIX3YinNu2RzL30oH_jrzm>Kp@B5s2#R*lw|_tzHs<7;VVu^Lh5cvu>5T78X2#0I40 zh0GvGCP;{4!jv(a3c0WgDHY0GRtmD2O1a|mh%=vI7H~k)92UkAsyHU|bX+FsgiOmx zNj)O7Gb%gB<=^uK^?b<+azy!oMy}Ju4axWmtGGq84BKi|L8Ds8x{O*vn_9+t)yM|b zLc8jwLv5#1#pzOqh^f= 10 ? ('a' + d - 10) : ('0' + d)); } - // Get the MD5 sum of that... - MessageDigest md; - md = MessageDigest.getInstance("MD5"); - byte[] md5sum = new byte[32]; - md.update(csig); - md5sum = md.digest(); - BigInteger bigInt = new BigInteger(1, md5sum); - String md5hash = bigInt.toString(16); - while (md5hash.length() < 32) - md5hash = "0" + md5hash; - System.out.println("Result:" + md5hash); + String result; + if(full) { + result = new String(csig); + } else { + // Get the MD5 sum... + MessageDigest md; + md = MessageDigest.getInstance("MD5"); + byte[] md5sum = new byte[32]; + md.update(csig); + md5sum = md.digest(); + BigInteger bigInt = new BigInteger(1, md5sum); + String md5hash = bigInt.toString(16); + while (md5hash.length() < 32) + md5hash = "0" + md5hash; + result = md5hash; + } + + System.out.println("Result:" + result); System.exit(0); } catch (Exception e) { diff --git a/update.py b/update.py index 5449e01b..b12f147a 100644 --- a/update.py +++ b/update.py @@ -240,6 +240,8 @@ repoel = doc.createElement("repo") repoel.setAttribute("name", repo_name) repoel.setAttribute("icon", repo_icon) repoel.setAttribute("url", repo_url) +if repo_keyalias != None: + repoel.setAttribute("pubkey", repo_pubkey) addElement('description', repo_description, doc, repoel) root.appendChild(repoel) @@ -357,6 +359,33 @@ output = doc.toxml() of.write(output) of.close() +if repo_keyalias != None: + + if not options.quiet: + print "Creating signed index." + + #Create a jar of the index... + p = subprocess.Popen(['jar', 'cf', 'index.jar', 'index.xml'], + cwd='repo', stdout=subprocess.PIPE) + output = p.communicate()[0] + if options.verbose: + print output + if p.returncode != 0: + print "ERROR: Failed to create jar file" + sys.exit(1) + + # Sign the index... + p = subprocess.Popen(['jarsigner', '-keystore', keystore, + '-storepass', keystorepass, '-keypass', keypass, + os.path.join('repo', 'index.jar') , repo_keyalias], stdout=subprocess.PIPE) + output = p.communicate()[0] + if p.returncode != 0: + print "Failed to sign index" + print output + sys.exit(1) + if options.verbose: + print output + #Copy the repo icon into the repo directory... iconfilename = os.path.join(icon_dir, repo_icon) shutil.copyfile(repo_icon, iconfilename)