maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   [Tutorial] Creating a deb for apks to be used in conjunction with apkenv (https://talk.maemo.org/showthread.php?t=87597)

MFaroTusino 2012-10-27 07:39

[Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
1 Attachment(s)
So you may have seen this thing called apkenv, which allows a very "small" set of Android apks to be run inside Harmattan.

If you follow me on Twitter, you would have seen I have been doing some experimental packaging, make these apks appear to be fully fledged apps (launcher icon, app mgr info, tap>hold>uninstall, etc).

NOTE:This method still requires you to install apkenv+libraries before you can use the apps you make. It also will work assuming you followed the original tutorial EXACTLY! I also assume you use linux (I use ubuntu VM ).

Obviously, I do not condone publishing apks for those you do not have the right to use, so I will simply post a tutorial using a skeleton archive (attached) to help.

First up, extract the archive to the desktop.

Rename the folder to whatever you wish to call the app. (Will call it foobar from here-in).

Inside foobar there is a debian folder, opt folder and foobar.desktop. First, we will modify the opt folder.

In the opt folder, you should have a sub directory foobar. This is where you store your .apk, icon.png (80x80), and execution script. The execution script isn't too important if you are confident at running command using the foobar.desktop file. However, I still suggest using this method, as it has greater control over tasks in my opinion.

Once you have opt/ all sorted, it is time to move on to the debian directory. Inside this we have postinst , changelog, control, foobar.install, mainfest.aegis, readme and rules. The only files you need to edit are postinst, changelog, control and foobar.install.

Open foobar.install in a text editor, changing the paths used to suit the /opt of your app. Same goes for postinst, simply adjust the paths to suit your package.

Changelog simply change foobar and the author information. In control, change the Description, Maintainer, source, package and x-Maemo-Display-Name fields. Everything Else can stay the same.

Finally, edit the foobar.desktop file. Here, we control what the user sees on the launcher page. The icon and exec fields simply need to have their paths altered. Change Name= to the name you want displayed.

P.S: I simply re-use the same structure for all my packaging (due to my app's being scripts and not QML/GUI based) so you may see out of place names eg. Harmoji, ABSapce etc. If so, I apologise, I have triple checked everything but I could have missed something. I trust if you're skilled enough to be doing this sort of thing, you will have the logic to change them accordingly.

Next, is compiling the deb.

To compile, I suggest you take a look at this guide. It is extensive, and helped me out once.
http://talk.maemo.org/showthread.php?t=80908

Huge thanks to NovaG for being the first to teach me how to package .deb files.

AJMAL P.M 2012-10-28 08:31

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
Is that _MACOSX folder is necessary in the package?

thedead1440 2012-10-28 08:41

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
Quote:

Originally Posted by AJMAL P.M (Post 1286589)
Is that _MACOSX folder is necessary in the package?

No its a default folder mac puts in for its own indexing...

AJMAL P.M 2012-10-28 16:57

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
There is something wrong with the archive. (May be not.) I had to do two things to make a successful deb.

1) When I tried with exact similar archive it showed dependency error. With modified control file in the archive I got installation interrupted error.

(Then I tried your angry birds control elements with modification.)

2) desktop file moved to /usr/share/applications

BTW I tried deb packaging on N9 not Pc.

PS: there is a hidden unwanted DSstore file too in that archive may be from your system. Easy to confuse people like me. :)

thedead1440 2012-10-28 17:00

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
Yes DSstore is not required too...

Maybe you want to post what you have done?

AJMAL P.M 2012-10-29 13:53

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
Yup sure. Wait a little. Writing... Now saved game datas are working seperate for each games. You can reboot/play another game without fear of losing saved datas.

AJMAL P.M 2012-11-01 07:37

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
2 Attachment(s)
All right. Here is it. Wrote it with people like me in mind. You might know most of the part. Still have a read. I don't have an N900 but I think the steps are working for N900 too.

Install apkenv and binaries from apkenv wiki page or from here. Strongly recommend you to put apkenv and binaries in /home/user/apkenv.

With apkenv you can run android games on your N9/N900. You will lose game datas after every boot or you will lose previously played game's datas when you try another game. To run an apk execute

Code:

cd /home/user/apkenv

./apkenv /path/to/your/apk

Only a few games are working. Consider it as a beta release. Lets pray for the future developments and improvements from the dev, thp.

Now download scripts.zip and extract. It contains apkenvwrp.sh and make-deb.sh. Open terminal or filebox. Create a folder .apkenvwrp in /home/user/ and copy apkenvwrp.sh to the folder created.

Code:

mkdir -p /home/user/.apkenvwrp

cp -r /path/to/downloaded/apkenvwrp.sh /home/user/.apkenvwrp

chmod +x /home/user/.apkenvwrp/apkenvwrp.sh

This script will allow you to save/load game datas seperately. So you won't lose it after a reboot or after playing another game.

To run apk files with apkenvwrp script. Execute it like

Code:

cd /home/user/.apkenvwrp

sh apkenvwrp.sh /path/to/your/apk

Always use the above method to run an apk to avoid losing saved game datas. Here ends the apkenv part. Now lets move on to deb packaging on your N9/N900 if you are interested. You can forget the terminal for ever once you installed a game in this way. (Only a few changes from the apk to deb tutorial by MFaroTusino. Main focus is on deb packaging.) You can skip this deb packaging tutorial and read my next post on this thread to find an easy way to launch apks from launcher view with saved game datas.

TUTORIAL: Deb Packaging

Let's do some necessary things first. Hope you still have the downloaded scripts.zip file. Extract it and get make-deb.sh

Code:

devel-su
enter password

cp -r /path/to/downloaded/make-deb.sh /usr/bin/make-deb

chmod +x /usr/bin/make-deb

apt-get install binutils

exit

As an example we are going to pack the foobar archive as deb. Download foobar.zip from attachments. You don't have to edit anything as of now in this example package. But You have to replace every foobar occurence with your name when you try another file. (replace folder name, file names, and edit the file inside folders using text editor. Just replace foobar with your name.)

Extract foobar.zip. You will get a foobar directory. Inside are 3 sub folders named DEBIAN, opt and usr. Inside DEBIAN you have a control file and postinst file. Inside opt there is a foobar folder and inside it you have an 80x80 icon file, and an apk file. Inside /usr/share/applications/ you will find foobar.desktop.

Steps for Deb Packaging

1) Copy the foobar directory to /home/user/

Code:

cp -r /path/to/foobar /home/user/
If you get error try without root access. If still having error try /usr/bin/ instead of /home/user/

2) Give read and execute permission to DEBIAN and content inside it.

Code:

chmod 755 /home/user/foobar/DEBIAN/

chmod 755 /home/user/foobar/DEBIAN/*

3) Now let's make the deb

Code:

make-deb /home/user/foobar
4) Copy the created deb to desired location using filebox or terminal.

Code:

cp -r /home/user/foobar_0.1.deb /home/user/MyDocs/
Now you know how to make a deb in easy steps. Please note that the foobar.apk we have in /foobar/opt/foobar/ is just a dummy file. It won't work with apkenv in either way. Download an android game which is working with apkenv. Lets say Angry Birds Rio. Rename the file to AngryBirdsRio.apk and replace the foobar.apk with it. Now rename all folders and files named foobar to AngryBirdsRio. Using a text editor replace all occurrence of foobar with AngryBirdsRio in control, postinst, and AngryBirdsRio.desktop files. Save the changes. Then follow the deb packaging step. Install the deb you created. That's it. Now onwards tap icons and play the games right from launcher view without fearing data loss. Cheers!

If you have any confusion feel free to ask. All the informations are taken from various TMO threads. Credits go to the respective authors with my respect.

Credits
apkenv: thp
apkenvwrp.sh: PIDk
deb packaging: ammyt, Zas
make-deb script: Zas
apk to deb tutorial: MFaroTusino

AJMAL P.M 2012-11-01 07:37

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
1 Attachment(s)
For you people who said Angry Birds Seasons is not working. Try it with apkenvwrp.sh script described above. It will work!

cd /home/user/.apkenvwrp

sh apkenvwrp.sh /path/to/angrybirdsseasons.apk

And for those who want an icon in launcher view but don't want to do deb packaging or don't want to lose some storage sapce just make a desktop file with path to icon and exec=sh /home/user/.apkenvwrp/apkenvwrp.sh /path/to/your/apk


EDIT: Incase of extreme laziness, I have attached a sample desktop file. Edit it and place it in /usr/share/applications to launch your apk.

devel-su
password

cp -r /path/to/your/desktop /usr/share/applications

panjgoori 2012-11-01 07:51

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
what about N900 ? Will this guide work for it also or just harmattan ?

AJMAL P.M 2012-11-01 09:05

Re: [Tutorial] Creating a deb for apks to be used in conjunction with apkenv
 
Quote:

Originally Posted by panjgoori (Post 1288446)
what about N900 ? Will this guide work for it also or just harmattan ?

Everything is said to be working with N9 and N900. I do not have an N900. Trying won't make any harm I guess.

Atleast I can say apkenvwrp part is working for both N9 and N900 for sure. You can read this thread for complete deb packing on N900.


All times are GMT. The time now is 15:24.

vBulletin® Version 3.8.8