View Single Post
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: