maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [GUIDE for noobs] RPM packaging directly on your Jolla phone. (https://talk.maemo.org/showthread.php?t=92963)

Markkyboy 2015-01-04 19:18

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by Schturman (Post 1455166)
I don't know why it not worked for you from the first time, but it should...
I used this command in %post line for restart service in all my ambience packages and it always worked immediately without reboot etc..
Code:

systemctl-user restart ambienced.service
Example of spec file from one of my ambience packages:
Code:

Name:          ambience-green-hexagon
Version:      0.0.1
Release:      1
Summary:      Ambience Green Hexagon
Group:        System/Tools
Vendor:        Schturman
Distribution:  SailfisfOS
Packager: Schturman <schturman@hotmail.com>
URL:          www.dhrider.co.cc

License:      GPL

%description
This is a Green Hexagon ambience with sounds...

%files

%defattr(-,root,root,-)
/usr/share/ambience/*

%post
systemctl-user restart ambienced.service

%postun
if [ $1 = 0 ]; then
    // Do stuff specific to uninstalls
rm -rf /usr/share/ambience/ambience-green-hexagon
systemctl-user restart ambienced.service
else
if [ $1 = 1 ]; then
    // Do stuff specific to upgrades
echo "It's just upgrade"
systemctl-user restart ambienced.service
fi
fi

%changelog
* Sun Mar 16 2014 Builder <builder@...> 0.1
- First build.


I am using an edited copy of your spec, so apart from app name and my details, nothing has changed. Like I say, most of the time it all works out okay, then occasionally, it spits its dummy out and won't display the newly installed ambience.

I may be due to wipe and refresh my Jolla, I have edited lots of qml files all over the system, including in root, so maybe things are a bit messed up!, oh well, all part of the fun!, thanks again for your help :)

As per NielDK's suggestion, I may set up rpmbuild in Home and give that way a try.

Regards,

Schturman 2015-02-03 19:04

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Hi to all.
I found a way to create binary file from your script. For this you need SHC tool.
I already created .rpm file for easy installation on Jolla, but I don't know if I can share it (asked author, waiting for answer) :confused:.
Anyway, I decided to post here this instruction :D.
PDF instruction you can download here: https://dl.dropboxusercontent.com/u/..._for_Jolla.pdf

SHC – generic shell script compiler


(for Jolla phone)
· This tool will help you to create binary file from your script.
· Source: http://www.datsi.fi.upm.es/~frosal/
· Like author (Francisco Rosales) say:
Quote:

§ shc itself is not a compiler such as cc, it rather encodes and encrypts a shell script and generates C source code with the added expiration capability. It then uses the system compiler to compile a stripped binary which behaves exactly like the original script. Upon execution, the compiled binary will decrypt and execute the code with the shell –c option. Unfortunately, it will not give you any speed improvement as a real C program would.
§ shc's main purpose is to protect your shell scripts from modification or inspection. You can use it if you wish to distribute your scripts but don't want them to be easily readable by other people.
Option #1:
1. Download shc archive from http://www.datsi.fi.upm.es/~frosal/ (direct link)
2. Extract it and go to this directory (shc-3.8.9)
Code:

tar xvfz shc-3.8.9.tgz
cd /home/nemo/Downloads/shc-3.8.9

3. Create "shc" binary file (gcc package needed = pkcon install gcc):
Code:

gcc shc-3.8.9.c -o shc
4. Put the created file "shc" to /bin with permission: 0755
5. For create binary from your script:
a. cd to directory with your script and run:
Code:

shc -f myscript.sh
gcc myscript.sh.x.c -o mybinary

b. Binary file "mybinary" created and now you can delete these 3 files:
Code:

myscript.sh
myscript.sh.x
myscript.sh.x.c

6. Put your binary file ("mybinary") where it should be and give him a right permission.

Option #2:
1. Download shc archive from http://www.datsi.fi.upm.es/~frosal/ (direct link)
2. Extract it and go to this directory (shc-3.8.9)
Code:

tar xvfz shc-3.8.9.tgz
cd /home/nemo/Downloads/shc-3.8.9


3. Create "shc" binary file (make & gcc package needed = pkcon install make gcc):

Code:

cd /home/nemo/Downloads/shc-3.8.9
make


4. Put the created file "shc" to /bin with permission: 0755

5. For create binary from your script:
a. cd to directory with your script and run:
Code:

shc -f myscript.sh
cc -Wall myscript.sh.x.c -o mybinary

b. Binary file "mybinary" created and now you can delete these 3 files:
Code:

myscript.sh
myscript.sh.x
myscript.sh.x.c


6. Put your binary file ("mybinary") where it should be and give him a right permission.

---------------------------------------------------------------------------
For quick and easy convert of a few scripts, you can use this script:
Code:

#!/bin/bash

dir=${PWD##*/}
ls -a|grep ".*\.\(sh\)"|while read line; do shc -f "$line"; done
ls -a|grep ".*\.\(x.c\)"|while read line; do gcc "$line" -o "${line/.sh.x.c/}"; done
rm -f *.x* && mkdir -p $dir-source && mv -f *.sh $dir-source

  • Call this script "binary_creator", without ".sh" suffix and put it to the folder with your scripts.
  • Create binaries from your scripts in specific directory:
Code:

cd /path/to/scripts_dir
sh binary_creator

  • It will create binaries from your scripts, delete not needed files and save your original scripts in the "currentdirectory-source" directory, that you can save if you need them.

Schturman (03.02.2015)

coderus 2015-02-04 03:49

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Peoples inventing new things just not to start learning real programming. It's always easier to say: "I'm not a programmer, i just know how to write some scripts". Sad story :(

Schturman 2015-02-04 06:38

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by coderus (Post 1459473)
Peoples inventing new things just not to start learning real programming. It's always easier to say: "I'm not a programmer, i just know how to write some scripts". Sad story :(

What exactly a problem for you that I write some simple scripts and share them ? I'm sure you don't need them, but maybe someone yes.
And yes, it's more easy for me.. If I have time like you, probably I was going to learn programming instead to write simple scripts, but most of the time I see my PC only at night for 1-2 hours max..
And you don't need every time again to try to humiliate me.

coderus 2015-02-04 06:56

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
It's not about you, it's about shc. Peoples wasting time for "programming simulation" instead of using real programming languages. Scripts are okay for one-time job. I personally can't understand it. Having two academic hours per day is enough for everybody to start learning any programming language. But it's personal decision of everybody.

Schturman 2015-02-04 07:22

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by coderus
Having two academic hours per day is enough for everybody to start learning any programming language. But it's personal decision of everybody.

Agree 100%, but not when it's your rest time at the end of the day ;)

coderus 2015-02-04 07:27

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
As i said it just my personal optinion. Using shc is okay for "hiding" script code. What the purpose of shc in sailfish?

Schturman 2015-02-04 07:37

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by coderus (Post 1459489)
Using shc is okay for "hiding" script code. What the purpose of shc in sailfish?

No purpose, like you and author said for "hiding" script code.
When found it, was thinking it's nice to learn for myself converting script to binary. It's easy and fun, for me at least. That's all..

rcolistete 2015-02-04 12:20

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by coderus (Post 1459473)
Peoples inventing new things just not to start learning real programming. It's always easier to say: "I'm not a programmer, i just know how to write some scripts". Sad story :(

There are thousands of programming languages. Including many script languages. They have advantages and disadvantages if compared. For example, a Assembly programmer could also disdain C/C++ programmers because it is slower, generates large compiled code, etc.

It is up to us choose the best programming language for each task, each preference /style we have.

juiceme 2015-02-04 14:11

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
I have nothing against scripting languages, I fairly often still write shellscripts. And make is a kind of scripting language, too.
And what about javascript, which is really ECMAscript and has 'script' even in the name of the language :D

However, using techniques that hide your scripts from inspection and modification are pretty questionable IMHO. Just as distributing any kind of binary without sources, I feel it is a bad practice indeed. :mad:

Markkyboy 2015-05-03 10:26

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
I see no difference ultimately, how the software is made, you are both sharing your work with the wider community and that is fantastic!, you take your time, which is all we really have and you share what you created in that time - thank you, for your time! :)

I understand where Coderus is coming from and at the same time, I also understand where Schturman is coming from. We are not all the next `Bill Gates`, as some of us are busy with work, with family, with illness, with so many aspects of life - not everyone has the time to learn such complex things as programming - yeah, I know, make time!!, easier said than done. LIFE can get in the way of leisure and pleasure.

I say thank you to Coderus for all his apps and help, updating his apps.....
I also say thank you to Schturman for taking time to post his findings and answering my queries about his methods - either way, I have apps from Coderus and Schturman on my phone - you should both be happy with that - I like your works!

Let us not be divided by ego, but be united with the common ground that brings us all here in the first place - TECHNOLOGY/SAILFISH/N9/MEEGO/MAEMO/NOKIA.....you get what I'm saying. :)

Coderus, perhaps you'd consider sharing some of your programming prowess, by way of a video?, show us how-to script properly for Sailfish?, just a little simple app to get others started?, maybe you don't want to share your hard earned skills?, that I can also understand, but me, I like to share what I know! :)

Regards,

coderus 2015-05-03 11:31

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
I was thinking about sailfish developing twitch and youtube channel, but had no time to write program for it, as it shouldn't be improvisation :)

Markkyboy 2015-12-13 01:33

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Hey guys, I'd like to hide an app icon when installing an app. Sounds odd, I know but it's what I'd like to do and preferably not as a patch, unless there isn't a way around.

Basically, I'd like to hide the launcher icon for an existing app as my own app is installing. Then of course, I'd like to be able to return the launcher icon for the existing app if my app is uninstalled (my app does not create an icon as it's a 'quickaction'). Can this be done in the spec file?, perhaps in a '%pre' section in the existing spec file - if so, how would it be written?

Any info appreciated :)

nieldk 2015-12-13 05:24

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by Markkyboy (Post 1491352)
Hey guys, I'd like to hide an app icon when installing an app. Sounds odd, I know but it's what I'd like to do and preferably not as a patch, unless there isn't a way around.

Basically, I'd like to hide the launcher icon for an existing app as my own app is installing. Then of course, I'd like to be able to return the launcher icon for the existing app if my app is uninstalled (my app does not create an icon as it's a 'quickaction'). Can this be done in the spec file?, perhaps in a '%pre' section in the existing spec file - if so, how would it be written?

Any info appreciated :)

See this post

https://talk.maemo.org/showpost.php?...64&postcount=7

coderus 2015-12-13 09:14

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Nieldk :confused:

Right way to hidde an icon from launcher in SailfishOS is adding
Code:

NoDisplay=true
in .desktop file

Markkyboy 2015-12-13 12:39

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
hahahaha!, state the bleedin' obvious guys, ffs! @coderus and @nieldk

I'm well aware of NoDisplay=true/false, but that doesn't help me.
I'd like the process automated, so the 'other' icon is removed as I'm installing my app. IF the line NoDisplay= is to be added as the only way, then this means a patch?

coderus 2015-12-13 12:58

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
google sed ;)

pichlo 2015-12-13 17:44

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
Quote:

Originally Posted by Markkyboy (Post 1491361)
I'd like the process automated, so the 'other' icon is removed as I'm installing my app.

Coderus is right, you can automate it in your pre/post-install scripts.

However my advice would be - DO NOT DO IT! It is a bad idea for an app A to fiddle with the settings of app B. You add unnecessary dependencies, not to mention forcing the user down your path rather than letting the user choose.

olf 2020-01-22 13:45

Re: [GUIDE for noobs] RPM packaging directly on your Jolla phone.
 
As @Schturman's original guide (first post in this thread, from 2014-03-31) is well done, but contains a few, although significant flaws, I created and posted a condensed and rectified version, which includes some extrenal references for further reading.


All times are GMT. The time now is 08:13.

vBulletin® Version 3.8.8