mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Build a signed index in jar format, to be used by the next version of the client
This commit is contained in:
parent
cbd42b2a62
commit
f0fa241751
@ -17,6 +17,15 @@ The official FDroid repository. Applications in this repository are official
|
|||||||
binaries built by the original application developers.
|
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
|
#The keystore to use for release keys when building. This needs to be
|
||||||
#somewhere safe and secure, and backed up!
|
#somewhere safe and secure, and backed up!
|
||||||
keystore = "/home/me/somewhere/my.keystore"
|
keystore = "/home/me/somewhere/my.keystore"
|
||||||
|
Binary file not shown.
@ -13,13 +13,23 @@ public class getsig {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
if (args.length != 1) {
|
String apkPath = null;
|
||||||
|
boolean full = false;
|
||||||
|
|
||||||
|
if(args.length == 1) {
|
||||||
|
apkPath = args[0];
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
if(!args[0].equals("-f")) {
|
||||||
|
System.out.println("Only -f is supported");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
apkPath = args[1];
|
||||||
|
full = true;
|
||||||
|
} else {
|
||||||
System.out.println("Specify the APK file to get the signature from!");
|
System.out.println("Specify the APK file to get the signature from!");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String apkPath = args[0];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
JarFile apk = new JarFile(apkPath);
|
JarFile apk = new JarFile(apkPath);
|
||||||
@ -64,17 +74,24 @@ public class getsig {
|
|||||||
csig[j*2+1] = (byte)(d >= 10 ? ('a' + d - 10) : ('0' + d));
|
csig[j*2+1] = (byte)(d >= 10 ? ('a' + d - 10) : ('0' + d));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the MD5 sum of that...
|
String result;
|
||||||
MessageDigest md;
|
if(full) {
|
||||||
md = MessageDigest.getInstance("MD5");
|
result = new String(csig);
|
||||||
byte[] md5sum = new byte[32];
|
} else {
|
||||||
md.update(csig);
|
// Get the MD5 sum...
|
||||||
md5sum = md.digest();
|
MessageDigest md;
|
||||||
BigInteger bigInt = new BigInteger(1, md5sum);
|
md = MessageDigest.getInstance("MD5");
|
||||||
String md5hash = bigInt.toString(16);
|
byte[] md5sum = new byte[32];
|
||||||
while (md5hash.length() < 32)
|
md.update(csig);
|
||||||
md5hash = "0" + md5hash;
|
md5sum = md.digest();
|
||||||
System.out.println("Result:" + md5hash);
|
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);
|
System.exit(0);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
29
update.py
29
update.py
@ -240,6 +240,8 @@ repoel = doc.createElement("repo")
|
|||||||
repoel.setAttribute("name", repo_name)
|
repoel.setAttribute("name", repo_name)
|
||||||
repoel.setAttribute("icon", repo_icon)
|
repoel.setAttribute("icon", repo_icon)
|
||||||
repoel.setAttribute("url", repo_url)
|
repoel.setAttribute("url", repo_url)
|
||||||
|
if repo_keyalias != None:
|
||||||
|
repoel.setAttribute("pubkey", repo_pubkey)
|
||||||
addElement('description', repo_description, doc, repoel)
|
addElement('description', repo_description, doc, repoel)
|
||||||
root.appendChild(repoel)
|
root.appendChild(repoel)
|
||||||
|
|
||||||
@ -357,6 +359,33 @@ output = doc.toxml()
|
|||||||
of.write(output)
|
of.write(output)
|
||||||
of.close()
|
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...
|
#Copy the repo icon into the repo directory...
|
||||||
iconfilename = os.path.join(icon_dir, repo_icon)
|
iconfilename = os.path.join(icon_dir, repo_icon)
|
||||||
shutil.copyfile(repo_icon, iconfilename)
|
shutil.copyfile(repo_icon, iconfilename)
|
||||||
|
Loading…
Reference in New Issue
Block a user