[SCRIPT/HOW-TO] Sign files with terminal (Ubuntu)

Search This thread

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
sign files with a right click (Ubuntu) (Thanks Amon_RA)
-----------------------------------------------------------------------------------------------------------------
This little novice, 2-line script will help you sign update.zip files directly from any terminal window if you have the Android SDK set up on your machine. It might be pointless to some, but I thought it would be a nice idea to share.


  1. Navigate to your Android SDK directory.
  2. Create a folder and name it "sign".
    This is where you will put the update.zip that you want to sign.
  3. Download the attached testsign.jar file [extract from zip] and move it to the new /sign directory in your Android SDK.
  4. Navigate to your /tools directory and Right-Click > Create Document > Empty File.
  5. Give it a name without extension.
    example: sign
  6. Right-Click > Open with "Text Editor" and add the following:
    Change the directories according to your setup.
    #!/bin/sh
    java -classpath /AndroidSDK/sign/testsign.jar testsign /AndroidSDK/sign/update.zip /AndroidSDK/sign/update-signed.zip
  7. Give it executable permissions with the terminal -
    Code:
    cd /YOUR-SDK-DIRECTORY/tools/
    chmod a+x sign

Now you can simply drop the update.zip to your
/sign directory and from the terminal type:
Code:
sign
and it will sign it without having to add the long command yourself. :)

Of course you can edit the script to fit your needs.

---- Optional ----
By making a link (right-click > Make Link) of your /sign directory and adding it to your Desktop, you can drag and drop update.zip directly to this link and sign. This save you some time in the signing process and you have access to it from your Desktop.
---- Optional ----

Thank you Cyanogen for this reply.
 

Attachments

  • testsign.zip
    12.9 KB · Views: 1,812
Last edited:

njuncos

Senior Member
May 25, 2009
217
0
mods, please sticky this as i'm sure many will find this very informative :cool:
 

alritewhadeva

Senior Member
Mar 26, 2009
1,369
12
Thank you so much! :) Just started using ubuntu in a VM. Think you could write up a guide on setting up eclipse? That'd be absolutely super. Thanks again lol. Helped me sign files + set up the sdk. Great work.
 

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
Thank you so much! :) Just started using ubuntu in a VM. Think you could write up a guide on setting up eclipse? That'd be absolutely super. Thanks again lol. Helped me sign files + set up the sdk. Great work.

Well, setting up eclipse is fairly simple!
  1. download Eclipse
  2. unzip it any directory
    /AndroidSDK/Eclipse | /home/wddglr/Apps/Eclipse
  3. set up the ADT following the information in this page: [http://developer.android.com/sdk/1.5_r3/installing.html]
 

soulehmoo

Senior Member
Aug 25, 2009
117
0
if you use lots of different named update zips.
This is step 6
#!/bin/sh
echo -n "Source Zip Filename : "
read input

echo -n "Output Zip Filename : "
read output

java -classpath /androidsdk/sign/testsign.jar testsign /androidsdk/sign/"$input" /androidsdk/sign/"$output"

echo "Finished signing $input as $output"

Just input the source file and the output and it does the rest.
Was useful for me as I sign different zips.
Use as you wish, thanks to wddglr.
 

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,470
1,649
Detroit, Mi
I don't know why I can never get this to work.
This is exactly what I see when I ls /AndroidSDK/sign:

greg@Ubuntu:~$ ls /AndroidSDK/sign
testsign.jar update.zip

greg@Ubuntu:~$ sign
Exception in thread "main" java.lang.NoClassDefFoundError: testsign
at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: testsign not found in gnu.gcj.runtime.SystemClassLoader{urls=[], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at gnu.java.lang.MainThread.run(libgcj.so.90)
 
Last edited:

joe v

Senior Member
Feb 22, 2009
145
0
I don't know why I can never get this to work.
This is exactly what I see when I ls /AndroidSDK/sign:

greg@Ubuntu:~$ ls /AndroidSDK/sign
testsign.jar update.zip

I was wondering if you were you able to solve this? Becouse I'm getting the same.. I'm thinking it has something to do with jave. But not sure what I need to do to fix it.. thanks for any info ....
 

jamezelle

Retired Forum Mod / Retired Recognized Developer
Nov 4, 2007
1,712
100
Ohio
www.jamezelle.com
yea me toooo:confused:

edit i figured it out

Code:
# Right-Click > Open with "Text Editor" and add the following:

    Change the directories according to your setup.
    Quote:
    #!/bin/sh
    java -classpath [B]/AndroidSDK[/B]/sign/testsign.jar testsign /[B]AndroidSDK[/B]/sign/update.zip /AndroidSDK/sign/update-signed.zip

yeah that is not where my tools are lol
 
Last edited:

ccriffman

Senior Member
Sep 5, 2009
375
9
Spokane, Wa
sign files with a right click (Ubuntu) (Thanks Amon_RA)
-----------------------------------------------------------------------------------------------------------------
This little novice, 2-line script will help you sign update.zip files directly from any terminal window if you have the Android SDK set up on your machine. It might be pointless to some, but I thought it would be a nice idea to share.


  1. Navigate to your Android SDK directory.
  2. Create a folder and name it "sign".
    This is where you will put the update.zip that you want to sign.
  3. Download the attached testsign.jar file [extract from zip] and move it to the new /sign directory in your Android SDK.
  4. Navigate to your /tools directory and Right-Click > Create Document > Empty File.
  5. Give it a name without extension.
    example: sign
  6. Right-Click > Open with "Text Editor" and add the following:
    Change the directories according to your setup.
  7. Give it executable permissions with the terminal -
    Code:
    cd /YOUR-SDK-DIRECTORY/tools/
    chmod a+x sign

Now you can simply drop the update.zip to your
/sign directory and from the terminal type:
Code:
sign
and it will sign it without having to add the long command yourself. :)

Of course you can edit the script to fit your needs.

---- Optional ----
By making a link (right-click > Make Link) of your /sign directory and adding it to your Desktop, you can drag and drop update.zip directly to this link and sign. This save you some time in the signing process and you have access to it from your Desktop.
---- Optional ----

Thank you Cyanogen for this reply.
I tried every way I could, and as stupid as I am, I could not get it to work!!!
ccriffman@ccriffman-laptop:~$ sign
bash: sign: command not found
ccriffman@ccriffman-laptop:~$ cd /home/ccriffman/android/tools
ccriffman@ccriffman-laptop:~/android/tools$ sign
bash: sign: command not found
ccriffman@ccriffman-laptop:~/android/tools$ cd /home/ccriffman/android
ccriffman@ccriffman-laptop:~/android$ sign
bash: sign: command not found
ccriffman@ccriffman-laptop:~/android$ cd /sign
bash: cd: /sign: No such file or directory
ccriffman@ccriffman-laptop:~/android$ cd /home/ccriffman/android/sign
bash: cd: /home/ccriffman/android/sign: No such file or directory
ccriffman@ccriffman-laptop:~/android$ cd /tools
bash: cd: /tools: No such file or directory
ccriffman@ccriffman-laptop:~/android$ cd tools
ccriffman@ccriffman-laptop:~/android/tools$ sign
bash: sign: command not found
ccriffman@ccriffman-laptop:~/android/tools$ cd sign
bash: cd: sign: Not a directory
ccriffman@ccriffman-laptop:~/android/tools$ sign
bash: sign: command not found
ccriffman@ccriffman-laptop:~/android/tools$
:confused:
 

pconwell

Senior Member
Aug 31, 2009
77
8
Nashville, TN
testsign.jar in wrong spot

I got mine fixed. I had testsign.jar inside of the testsign folder inside the sign folder.

testsign.jar needs to be in the 'root' of the sign folder, or you need to modify the sign script to point to the correct location.
 

freebirds87

Senior Member
Nov 27, 2009
107
6
Alabama
I got mine fixed. I had testsign.jar inside of the testsign folder inside the sign folder.

testsign.jar needs to be in the 'root' of the sign folder, or you need to modify the sign script to point to the correct location.

..... damnit.

I did the same thing


======EDIT=======

Now I am getting this error:
sign
No command 'sign' found, did you mean:
Command 'bsign' from package 'bsign' (universe)
Command 'psign' from package 'radiance' (universe)
sign: command not found

Help?
 
Last edited:

crackpot

Senior Member
Oct 25, 2009
376
342
SC
crackpot.ws
This script worked great, I really appreciate it. I did modify it a bit so that I don't have to necessarily sign update.zip every time. It is similar to the script posted on the first page, but rather than it asking for the input and output, you simply add parameters to the sign command. For example:
Code:
sign <input> <output>

See the code below, make sure you change the directory to where you have the sign folder located.
Code:
#!/bin/sh
java -classpath /opt/android/sign/testsign.jar testsign /opt/android/sign/$1 /opt/android/sign/$2
echo "Finished signing $1 as $2"
Hope this helps anyone.
 

lbcoder

Senior Member
Jan 21, 2009
2,613
98
An even better modification is to make it only take ONE parameter:

#!/bin/bash
mv $1 /tmp/$$-$1
java -classpath /opt/android/sign/testsign.jar testsign /tmp/$$-$1 $1
rm /tmp/$$-$1

Note that this form is also independent of the location of the archive to sign -- it is nicer to enter that particular directory and just run "sign file.zip".
 

wedsxcrfv

New member
Jun 15, 2009
2
0
You should really mention that the tools directory has to be added to $PATH..
Not everyone has this, if you don't then simply typing sign will not work
 

crackpot

Senior Member
Oct 25, 2009
376
342
SC
crackpot.ws
You should really mention that the tools directory has to be added to $PATH..
Not everyone has this, if you don't then simply typing sign will not work

Well it should be correctly assumed that $PATH was correctly set when they installed the Android SDK, because if they followed the instructions provided by the SDK's documentation then it says to set the $PATH var in "~/.bashrc" or "~/.bash_profile".

From: http://developer.android.com/sdk/installing.html
On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ directory to it. If you don't see a line setting the path, you can add one:

export PATH=${PATH}:<your_sdk_dir>/tools
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    sign files with a right click (Ubuntu) (Thanks Amon_RA)
    -----------------------------------------------------------------------------------------------------------------
    This little novice, 2-line script will help you sign update.zip files directly from any terminal window if you have the Android SDK set up on your machine. It might be pointless to some, but I thought it would be a nice idea to share.


    1. Navigate to your Android SDK directory.
    2. Create a folder and name it "sign".
      This is where you will put the update.zip that you want to sign.
    3. Download the attached testsign.jar file [extract from zip] and move it to the new /sign directory in your Android SDK.
    4. Navigate to your /tools directory and Right-Click > Create Document > Empty File.
    5. Give it a name without extension.
      example: sign
    6. Right-Click > Open with "Text Editor" and add the following:
      Change the directories according to your setup.
      #!/bin/sh
      java -classpath /AndroidSDK/sign/testsign.jar testsign /AndroidSDK/sign/update.zip /AndroidSDK/sign/update-signed.zip
    7. Give it executable permissions with the terminal -
      Code:
      cd /YOUR-SDK-DIRECTORY/tools/
      chmod a+x sign

    Now you can simply drop the update.zip to your
    /sign directory and from the terminal type:
    Code:
    sign
    and it will sign it without having to add the long command yourself. :)

    Of course you can edit the script to fit your needs.

    ---- Optional ----
    By making a link (right-click > Make Link) of your /sign directory and adding it to your Desktop, you can drag and drop update.zip directly to this link and sign. This save you some time in the signing process and you have access to it from your Desktop.
    ---- Optional ----

    Thank you Cyanogen for this reply.