http://wiki.webos-internals.org/api.php?action=feedcontributions&user=FranTruong&feedformat=atomWebOS Internals - User contributions [en]2024-03-29T09:07:05ZUser contributionsMediaWiki 1.35.1http://wiki.webos-internals.org/index.php?title=Packaging_Homebrew_Apps_for_Stock_Pre_without_Rooting&diff=8570Packaging Homebrew Apps for Stock Pre without Rooting2010-01-19T20:08:08Z<p>FranTruong: </p>
<hr />
<div>{{template:deprecated |<br />
Please use the Palm software development kit instead at [[http://developer.palm.com]].<br />
}} <br />
{{template:patch}}<br />
= How To Create Packages for Installation on a Stock Pre=<br />
<br />
'''Brought to you by...'''<br />
* xorg - started the initiative, host of this page<br />
* simplyflipflops - discovered the install via email link (no longer works with OS 1.0.4)<br />
* Shaya Potter - provided details for creating signatures and [http://www.term-paper.biz/custom-term-paper.html buy a paper]<br />
<br />
= Summary=<br />
<br />
There are three main components to creating/installing homebrew application packages:<br />
<br />
1) Packaging the application for Debian ipkg <br />
<br />
2) Generating a signature for the package <br />
<br />
3) Installing using the [http://www.webos-internals.org/wiki/Tutorials_webOS_Installing_An_Ipk PreBrew method.] (replaced the email link method)<br />
<br />
and an extra important 4th...<br />
4) Testing... Please test your code well and be responsible. Others will help you succeed and develop quality apps in this [http://forums.precentral.net/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html Pre Central forum thread]. Please post your tests in that thread with a beta disclaimer before releasing to the public.<br />
<br />
This guide does not show how to build new applications, just how to package your existing application for distribution on a stock Pre. Here is [http://predev.wikidot.com/building-webos-mojo-applications a guide for creating your own WebOS applications.]<br />
<br />
= Packaging Instructions (xorg method)=<br />
<br />
This section is geared towards those already experienced with Linux/Unix and Debian packaging. Some commands may require slight modifications depending on platform you package on. See other methods below.<br />
<br />
How to create a signed package for public distribution on a stock Pre. This assumes you already have your application functioning on a [http://predev.wikidot.com/rooting rooted Pre] in god mode. Your app should be located in /var/usr/palm/applications/yourappfolder. <br />
<br />
'''Only distribute __your__ code'''<br />
Be careful to follow copyright laws and not include code that isn't yours unless you have permission. If you include open source code, follow those rules. Publicly distributing mods of stock Pre applications is not recommended.<br />
<br />
'''Dependencies'''<br />
You'll need '''openssl''', possibly full '''gnutar''' and a full featured '''ar''' command to //create// archives. I'm not going to explain how to get these in the //experienced// section. If you package on a full Linux box with development tools, this should not be an issue. If packaging within a rooted Pre, you'll need to install the arm-based version of these programs (hint: /opt/bin/ipkg-opt install openssl, binutils, tar). Post in this [http://forums.precentral.net/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html Pre Central forum thread] if you need more help finding/installing these.<br />
<br />
'''Download this sample package into a blank project directory'''<br />
wget http://bit.ly/10ROa8 -O sample.ipk<br />
<br />
<br />
'''Extract sample and build the core files'''<br />
Extract the contents, this is how your bundle should look...<br />
ar -x sample.ipk<br />
<br />
Extract the contents of control.tar.gz. You'll need to change the control file to fit your app and tarball it back.<br />
tar xzvf control.tar.gz<br />
vi control <br />
(edit the structure to fit your app, the "package" must match the "id" in your appinfo.json file.)<br />
tar czvf control.tar.gz ./control ./rules<br />
<br />
Note the structure of data.tar.gz, which contains the /usr/palm/applications (the actual program). Note that it has an absolute leading /<br />
tar tzvf data.tar.gz<br />
<br />
tarball your entire app directory into data.tar.gz with the P flag to get absolute paths with a leading /. Not all distros have P flag in tar. You may need to get/use gnutar.<br />
tar cvPzf data.tar.gz /usr/palm/applications/(your application folder)<br />
<br />
confirm that you have a leading slash ('''/'''usr/.... not '''./'''usr/...)<br />
tar tzvf data.tar.gz<br />
<br />
'''How to sign a package''' (thanks to Shaya Potter)<br />
create a private key <br />
(depending on platform, this command may ask for location data, just hit enter through each. ignore the error this command may generate. if you get a mycert.pem greater than 0 bytes, it probably worked. you'll find out in the sig validation test.)<br />
<br />
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem<br />
<br />
extract the public key<br />
openssl rsa -in mycert.pem -pubout -out pubkey.pem<br />
<br />
sign your ipk<br />
cat control.tar.gz data.tar.gz debian-binary | openssl dgst -sha1 -sign mycert.pem -out signature.sha1<br />
<br />
validate the signature<br />
cat control.tar.gz data.tar.gz debian-binary | openssl dgst -sha1 -verify pubkey.pem -signature signature.sha1<br />
<br />
Verified OK <br />
<br />
'''Package it up'''<br />
package it up with ar<br />
ar -r (yourpackagename).ipk control.tar.gz data.tar.gz debian-binary pubkey.pem signature.sha1<br />
<br />
confirm your .ipk package looks ok...<br />
ar -t (yourpackagename).ipk<br />
<br />
(yourpackagename, obviously, should be unique and does not need to start with "com.": The general idea is to use the "reverse domain name" notation like the one commonly used by the [http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html java package names]. this allows globally unique names without the need of a central "Creator Registry" like the one used in Classic PalmOS)<br />
<br />
'''Install''' (PreBrew method)<br />
The email link method no longer works on OS1.0.4 or newer. Here is the latest [http://www.webos-internals.org/wiki/Tutorials_webOS_Installing_An_Ipk PreBrewmethod.] <br />
<br />
'''Test Deletion'''<br />
It is important you test that the application can be deleted on a stock Pre (non-rooted) before releasing to the public. Make sure the package name in the 'control' file matches the id name in the json file. Check the json file , refer to json entries in [http://predev.wikidot.com/building-webos-mojo-applications The HowTo Guide.]<br />
<br />
'''Test, Test and ReTest'''<br />
Test your application well before releasing to the public. Send it to friends first before releasing or post on [http://forums.precentral.net/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html Pre Central forum thread] for others to test as a pre-release. Don't rush releasing. You may tarnish the homebrew community if it is flooded with poorly written untested apps. Be responsible and consider following the upcoming recommended best practices. I'll be posting more about Best Practices later.<br />
<br />
= Variations of Commands=<br />
List variations of commands that may need to be tried depending on distribution.<br />
<br />
Is tar P flag and data file path with leading / required? We've debated this. Some say it's needed others say it's not. Since original stock Pre packages use a leading /, I also structured it that way.<br />
<br />
tar - you may need a tar command that has -P flag. If you have gnutar, it may be located in /opt/bin/gnutar depending on your distro. Change all tar commands with gnutar.<br />
<br />
tar vs ar - can you just use tar instead of ar in final packaging? When I look at an original stock app ipkg, I can only open it with ar, so it would seem using ar is needed. Others say they have just used tar but probably safest to use ar.<br />
<br />
openssl - some versions ask for location info - just hit enter through each. Other versions may give an error that it can't find the location file - just ignore it as long as it generated a mycert.perm greater than zero bytes.<br />
<br />
= Homebrew Repository=<br />
Pre Central has started a [http://forums.precentral.net/homebrew-apps/ homebrew repository] to post your completed app. You can create a thread dedicated to your app. You need to have a fully functioning app before you are allowed to create your own thread.<br />
<br />
= Packaging Services=<br />
If you have an application and are say, a strong web developer but not strong in linux or packaging, you could ask someone to package your app for you. Ask someone in this [http://discussion.treocentral.com/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html Pre Central thread] if they would be willing to package your app for you. With scripts, it only takes a few nanoseconds if the app directory is supplied.<br />
<br />
simplyflipflops is looking into a web service to automate generating the package. See page 14 of the thread above.<br />
<br />
= Packaging Script (quailish method)=<br />
<br />
Packaging script from quailish with more specific tar methods. Use this after you've made all of the file mods needed.<br />
<br />
package.sh<br />
<br />
<pre><nowiki><br />
<br />
#!/bin/sh<br />
tar -czv -f control.tar.gz ./control ./rules<br />
tar -cPv --no-recursion -f data.tar / /usr /usr/palm /usr/palm/applications<br />
tar -rPv --recursion -f data.tar /usr/palm/applications/com.myappname<br />
gzip --best data.tar<br />
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem<br />
openssl rsa -in mycert.pem -pubout -out pubkey.pem<br />
cat control.tar.gz data.tar.gz debian-binary | openssl dgst -sha1 -sign mycert.pem -out signature.sha1<br />
cat control.tar.gz data.tar.gz debian-binary | openssl dgst -sha1 -verify pubkey.pem -signature signature.sha1<br />
ar -r (yourpackagename).ipk control.tar.gz data.tar.gz debian-binary pubkey.pem signature.sha1<br />
ar -t (yourpackagename).ipk <br />
</nowiki></pre><br />
<br />
= Makefile (dsevil's method)=<br />
<br />
This approach is suited for those who develop WebOS applications on their laptop or desktop computer.<br />
<br />
It does not (yet) support applications that contain files outside the root application directory.<br />
<br />
- run: wget -O Makefile http://webonastick.com/webos/Makefile.txt<br />
<br />
- Edit the top section.<br />
<br />
- Make sure your package files are in the directory named by TARGET in the Makefile.<br />
<br />
- Run "make package" or just "make" to generate your package.<br />
<br />
NOTES:<br />
<br />
- Not guaranteed to work unless you have GNU tar, make, ar, du, and possible other utilities installed.<br />
<br />
- The usual general-lack-of-warranty disclaimer applies.<br />
<br />
- Requires installation of OpenSSL command-line utilities.<br />
<br />
- You don't edit appinfo.json; you edit Makefile; running 'make' generates it for you. <br />
<br />
Original post: [http://forums.precentral.net/showthread.php?p=1708112#post1708112 on Pre Central]<br />
<br />
= Another Approach (pimpmypre method)=<br />
<br />
Method to create an ipk by using a Linux hosted web server.<br />
<br />
You will need SSH access to your server - ask your provider and they will give it to you.<br />
<br />
<br />
Create 3 folders (to make it easy).<br />
<br />
Control<br />
Data<br />
Package<br />
<br />
Put your control files in the control folder.<br />
<br />
Put usr/palm/applications/(your app) folders in the data folder.<br />
<br />
In the data folder, type:<br />
tar cvPzf data.tar.gz .<br />
<br />
//(xorg note: some think data path above needs a leading / but pmp said this works for him. keep in mind that stock Pre apps use an absolute path using leading /, not this relative path method. see command variation section above.)//<br />
<br />
Move the tarball to the package folder.<br />
cd to the control folder<br />
tar cvPzf control.tar.gz .<br />
<br />
move this tarball to the package folder<br />
cd to the package folder<br />
echo "2.0" > debian-binary<br />
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem<br />
--(enter through the fields)<br />
<br />
openssl rsa -in mycert.pem -pubout -out pubkey.pem<br />
cat control.tar.gz data.tar.gz debian-binary | openssl dgst -sha1 -sign mycert.pem -out signature.sha1<br />
<br />
ar -crf (package name).ipk debian-binary data.tar.gz control.tar.gz mycert.pem pubkey.pem signature.sha1 <br />
<br />
<br />
= Cygwin Approach (Packaging in Windows)=<br />
<br />
How to package in Windows...<br />
<br />
First [http://www.cygwin.com/setup.exe download Cygwin here], then simply click next till you get to a screen called "Select Packages". In the top right click the "View" button. The list is in alphabetical order and you will have to enable 2 items by clicking the "skip" text. The first one is "binutils - The GNU assembler, linker and binary utilities. The second one is "openssl: The OpenSSL runtime environment".<br />
<br />
With these setup you can now do the commands described above. <br />
<br />
If anyone has successfully packaged and tested this method, please comment here that this method works. I had issues with it.<br />
<br />
Hmm... I wrote it so I would hope it works.<br />
<br />
Update: I followed the xorg method on windows with cygwin and it worked. - d0lph1nk1ng<br />
<br />
= Another Approach (yourname method)=<br />
<br />
If you have another packaging method, such as packaging scripts and got it working, please post it here - or a link to your scripts. Create an "Another Approach" tag for each new method. You may credit yourself in this section and add yourself as a contributor at the bottom of this page.<br />
<br />
<br />
= Disclaimer=<br />
<br />
Our intent is to help the Pre/webOS development world release applications. We do not support or encourage using this information for malware. We completely oppose misuse. <br />
<br />
We are white hat developers (friendly to the community and wide open with approach), not black hat hackers. The intent is to provide direly needed momentum for the development community and for Palm. If Palm wants to shut down this initiative, I will comply. Palm can contact me at Pre Central as xorg. <br />
<br />
= Discuss=<br />
<br />
See discussion and how this unfolded [http://forums.precentral.net/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html on Pre Central]. Is a good read for those would like to see how white hat hackers sleuth. <br />
<br />
BTW, we made the [http://www.precentral.net/homebrewed-apps-coming-non-rooted-devices Pre Central headlines].<br />
And [http://www.engadget.com/2009/06/22/pre-apps-successfully-installed-on-non-rooted-phone-world-waits/ Engadget].<br />
<br />
= Original Credits=<br />
The team...<br />
* xorg - started the initiative<br />
* simplyflipflops - discovered the install via email link<br />
* Shaya Potter - provided details for creating signatures<br />
<br />
Please consider crediting the three of us somewhere in your applications. Thanks.<br />
<br />
= Contributors=<br />
If you have contributed another method or usable information, please credit yourself here.<br />
<br />
qualish - submitted another packaging method with script<br />
<br />
dsevil - submitted Makefile packaging method<br />
<br />
<br />
<br />
= Below is the original post and how we got it done=<br />
<br />
= Discuss Ideas Here =<br />
<br />
Yo yo yo, xorg here. I've been trying to figure out a way to install a homegrown app on a Pre that has not been rooted (while we wait for the SDK to be released). I've been searching the the app installer code to see if there is another way to load other than through the App Catalog. <br />
<br />
Ideas...<br />
*I was hoping to find something that checks a folder on /media/internal but haven't found anything. <br />
*If we can figure out how the app is packaged (tarballed, ipkg or whatever) from the App Catalog, maybe there is a resource tag to autolaunch the installer when opening. This might allow sending the packaged app via email and opening from there.<br />
*Update: Looks like apps are packaged with ipkg. We need to find a way to launch ipkg on the homebrew pkg bundle without rooting the phone.<br />
<br />
Would like to brainstorm with others. There are no bad ideas. Throw out anything on where to look.<br />
<br />
= Places To Investigate=<br />
<br />
grep through subdirectories...<br />
/usr/palm/applications/com.palm.app.findapps<br />
<br />
Launch apps based on extension. Can we trick one of these to open a packaged app?<br />
/usr/palm/command-resource-handlers.json<br />
<br />
Put youse thinking caps on and throw out any ideas. Update here and/or [http://forums.precentral.net/web-os-development/187331-installing-homebrew-apps-w-out-rooting.html on Pre Central].<br />
<br />
Let's beat the SDK to the punch! The challenge is to find a way to install an app with permission of user but without making root changes. Make it so.<br />
<br />
<br />
= Progress=<br />
<br />
<br />
Update 6.20 afternoon: simplyflipflops (sff) has successfully installed an existing app by emailing himself a link to a Debian package and opening from email (something I suspected would be possible through email, which prompted me to start this initiative - sff found how). It won't work from the Pre browser, you must email the link to yourself and open from Pre email. Again, this will not work directly from the Pre web browser.<br />
<br />
Several have confirmed this works on a non-rooted Pre. <br />
<br />
The next question is... Does this require a signed package? <br />
<br />
<br />
Update 6.21 morning<br />
<br />
sff and I have made a lot of progress on figuring out the packaging. sff tried a homebrew app but is running into possibly signature issues. xorg is attempting to bypass signatures altogether.<br />
<br />
<br />
Update: 6.21 afternoon<br />
<br />
We've got packaging down pat and have moved on to signatures/keys. I repackaged a stock app with the stock keys/sigs and it works. Taking the key/sigs out is a no go, although a checksum itself might be the issue alone.<br />
<br />
I was able to confirm that the package does not require a palm.com address to install. I was able to download and install a stock app installed on another web server.<br />
<br />
We've confirmed signatures are required. Shaya Potter has been helping out with signatures. That's the major open item.<br />
<br />
<br />
= SUCCESS!!!!!=<br />
<br />
Update: 6.21 3:45pm cst<br />
<br />
We got it working thanks to Shaya Potter's knowledge of signatures and packaging. He doesn't have a Pre but walked us through how to do sigs. Pre Central has agreed to host the sample program. <br />
<br />
A sample mailto link can be found at [http://www.precentral.net/right-now-install-homebrew-app Pre Central article on the success] . Note that after receiving the email and clicking the link, nothing appears to happen. However, if you bring up the launcher and scroll to the bottom of the first page, a new icon will be there.</div>FranTruong