Active Topics

 


Reply
Thread Tools
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#1
As far as you know I'm not programmer and don't know use SDK and all programmer stuff etc... By googling I found this way very useful and easy for myself for creating RPM packages directly on my Jolla phone.

Suggestions for improvement are welcome!

The PDF instruction you can download here.

Create RPM package directly on your Jolla phone.

For easy access to your phone, use WinSCP and PuTTy. Instruction you can find here or download this PDF file.
1. Connect to your phone via WinSCP, open PuTTy as ROOT.

2. Write this command:
Code:
mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS/armv7hl,SPECS}

3.
If rpm-build package not installed, run this command as ROOT:
Code:
pkcon install -y rpm-build

4.
Download this example package of custom ambience to your PC. Extract folder myfirstpackage-0.1-1.arm and transfer to your phone:
Code:
/root/rpmbuild/BUILD
Extract myfirstpackage.spec and transfer to your phone:
Code:
/root/rpmbuild/SPECS

5. Look in to structure of files and folders to understand how to create your own packages.


6.
Some explanation about SPEC file. When you use this method of creating RPM files it have a little problem when you go to uninstall your package. It will delete all your files like it should be, but it will leave your folders. Why, I don’t know… This is a reason that I suggest you to always use the postuninstall script in spec file to remove your folder (see example in my spec).

Also remember that SPEC file run your commands as ROOT, if you should run your commands as USER from SPEC file, use this template:
Code:
su -l nemo -c "command"
Code:
Name:          myfirstpackage
Version:       0.1
Release:       1
Summary:       My First package
Group:         System/Tools
Vendor:        Schturman
Distribution:  SailfisfOS
Packager: Schturman <your@mail.com>
URL:           www.yoursite.com

License:       GPL

%description
This is my first package of custom Ambience...

%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/myfirstpackage
    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.
7. Some parameters that you can use too (add them under line URL:):
· Obsoletes: - if you want to uninstall other versions
· Conflicts: - if you want to keep 1st installed rpm package and stop 2 other packages from installing
· Requires: - add name of dependency packages

8. Other parameters
· %files - under this put the path to your files that NOT need special permissions. For example:
Code:
%files
/usr/share/applications/openrepos-myfirstpackage.desktop
/usr/share/icons/hicolor/86x86/apps/openrepos-myfirstpackage-off.png
/usr/share/openrepos-myfirstpackage/*
· %defattr(-,root,root,-) - under this put the path to your files that NEED special permissions. For example:
Code:
%defattr(4755,root,root)
/usr/share/openrepos-myfirstpackage/myscript.sh
/usr/share/openrepos-myfirstpackage/myscript2.sh
/usr/share/openrepos-myfirstpackage/myscript-root
9. Preinstall, Postinstall, Preuninstall and Postuninstall scripts.
· %pre– preinstall script, example:
Code:
%pre
if [ $1 = 1 ]; then
       #Do stuff specific for first install
      echo "It's first time install"
  else
    if [ $1 = 2 ]; then
       #Do stuff specific to upgrades
      echo "It's upgrade"
    fi
fi
· %post – postinstall script, example:
Code:
%post
if [ $1 = 1 ]; then
       #Do stuff specific for first install
      echo "It's first time install"
  else
    if [ $1 = 2 ]; then
       #Do stuff specific to upgrades
      echo "It's upgrade"
    fi
fi
· %preun – preuninstall script, example:
Code:
%preun
if [ $1 = 0 ]; then
       #Do stuff specific for uninstalls
      echo "Going to uninstall"
  else
    if [ $1 = 1 ]; then
       #Do stuff specific to upgrades
      echo "It's upgrade"
    fi
fi
· %postun – postuninstall script, example:
Code:
%postun
if [ $1 = 0 ]; then
       #Do stuff specific for uninstalls
      echo "Going to uninstall"
  else
    if [ $1 = 1 ]; then
       #Do stuff specific to upgrades
      echo "It's upgrade"
    fi
fi
10. Creating RPM package, run as ROOT in PuTTy:
Code:
/bin/cp -rf /root/rpmbuild/BUILD/myfirstpackage-0.1-1.arm /root/rpmbuild/BUILDROOT
cd /root/rpmbuild
rpmbuild -bb SPECS/myfirstpackage.spec
11. Transfer your RPM package to Downloads folder for example:
Code:
/bin/cp -f /root/rpmbuild/RPMS/armv7hl/myfirstpackage-0.1-1.armv7hl.rpm /home/nemo/Downloads
12. Install your package as USER via any File browser or as ROOT from terminal:
Code:
pkcon install-local -y /home/nemo/Downloads/myfirstpackage-0.1-1.armv7hl.rpm
13. Uninstall your package from homescreen (long press -> X) or as ROOT from terminal:
Code:
pkcon remove myfirstpackage
Good luck! Use it on your own risk !

Schturman
29.03.2014

Some users poins:
* From what nieldk explained (here and here) you can do all this stuff as USER,
just replace the path /root/rpmbuild/....with /home/nemo/rpmbuild/

Last edited by Schturman; 2017-06-07 at 06:30.
 

The Following 29 Users Say Thank You to Schturman For This Useful Post:
Guest | Posts: n/a | Thanked: 0 times | Joined on
#2
good post, only one thing.
You dont need (read: should not) run as root.
There really are no necessary reason for running rpmbuild as root,
the %defatr section defines the default permissions (in your example user:root and group:root) you can, and should also set permission in the %files section as needed per folder/file, and in some cases the default %defattr root:root will result in eg configuration files not being readable by normal user (nemo)
As rpmbuild builds in ~/rpmbuild directory tree it is able to create the rpm as user nemo etc.
 

The Following 3 Users Say Thank You to For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#3
Originally Posted by nieldk View Post
good post, only one thing.
You dont need (read: should not) run as root.
There really are no necessary reason for running rpmbuild as root,
the %defatr section defines the default permissions (in your example user:root and group:root) you can, and should also set permission in the %files section as needed per folder/file, and in some cases the default %defattr root:root will result in eg configuration files not being readable by normal user (nemo)
As rpmbuild builds in ~/rpmbuild directory tree it is able to create the rpm as user nemo etc.
Thanks
I just never tried do this as USER, I use WinSCP and Putty and it easily to do as ROOT or as USER and transfer files where you want.
If you start as USER you can't create folders from the first commands and if you already did it as ROOT you can just continue to other commands as root too
 

The Following User Says Thank You to Schturman For This Useful Post:
flotron's Avatar
Posts: 418 | Thanked: 506 times | Joined on Jan 2012 @ Argentina
#4
Thanks man. Added to my bookmarks
 

The Following 2 Users Say Thank You to flotron For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#5
PDF instruction updated with screenshot from WinSCP and link to this thread
 

The Following User Says Thank You to Schturman For This Useful Post:
Guest | Posts: n/a | Thanked: 0 times | Joined on
#6
Originally Posted by Schturman View Post
Thanks
I just never tried do this as USER, I use WinSCP and Putty and it easily to do as ROOT or as USER and transfer files where you want.
If you start as USER you can't create folders from the first commands and if you already did it as ROOT you can just continue to other commands as root too
just replace the path /root/rpmbuild/....
with
/home/nemo/rpmbuild/.... (SPECS/SOURCES/RPMS/SRPMS)

 

The Following 2 Users Say Thank You to For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#7
 

The Following 2 Users Say Thank You to Schturman For This Useful Post:
flotron's Avatar
Posts: 418 | Thanked: 506 times | Joined on Jan 2012 @ Argentina
#8
%defattr could work also to execute a postint script as root?

like:
%defattr
ln -s /usr/share/harbour-mytheme /usr/share/themes
 

The Following User Says Thank You to flotron For This Useful Post:
flotron's Avatar
Posts: 418 | Thanked: 506 times | Joined on Jan 2012 @ Argentina
#9
after:

rpmbuild -bb SPECS/myfirstpackage.spec

i get: bash: rpmbuild: command not found
 

The Following User Says Thank You to flotron For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#10
Originally Posted by flotron View Post
after:

rpmbuild -bb SPECS/myfirstpackage.spec

i get: bash: rpmbuild: command not found
install rpmbuild:
Code:
pkcon install -y rpm-build
Add creating your symlink to the scripts (pre, post, preun or postun) where you need it...
 

The Following 2 Users Say Thank You to Schturman For This Useful Post:
Reply

Tags
jolla phone, on device


 
Forum Jump


All times are GMT. The time now is 18:20.