Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

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

    Reply
    Page 1 of 6 | 1   2     3   | Next | Last
    Schturman | # 1 | 2014-03-31, 17:11 | Report

    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/

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by Schturman; 2017-06-07 at 06:30.
    The Following 29 Users Say Thank You to Schturman For This Useful Post:
    ajalkane, Artyom, Feathers McGraw, flotron, Halftux, Iryus, J4ZZ, Jordi, juiceme, lal, Markkyboy, mautz, MAX9, meemorph, Mikkosssss, Penguin, peterleinchen, pichlo, rcolistete, rfa, rrunner64, spidernik84, stefanmohl, TeHeR, thedead1440, vlad_dracul, Wikiwide, www.rzr.online.fr

     
    nieldk | # 2 | 2014-03-31, 17:48 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 3 Users Say Thank You to For This Useful Post:
    mattaustin, Schturman, stefanmohl

     
    Schturman | # 3 | 2014-03-31, 18:02 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Schturman For This Useful Post:
    Wikiwide

     
    flotron | # 4 | 2014-03-31, 18:02 | Report

    Thanks man. Added to my bookmarks

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to flotron For This Useful Post:
    Schturman, Wikiwide

     
    Schturman | # 5 | 2014-03-31, 19:16 | Report

    PDF instruction updated with screenshot from WinSCP and link to this thread

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to Schturman For This Useful Post:
    Wikiwide

     
    nieldk | # 6 | 2014-03-31, 19:27 | Report

    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)


    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to For This Useful Post:
    mattaustin, Schturman

     
    Schturman | # 7 | 2014-03-31, 19:44 | Report

    Thanks
    I will add your points to the first post...

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Schturman For This Useful Post:
    Wikiwide

     
    flotron | # 8 | 2014-03-31, 20:49 | Report

    %defattr could work also to execute a postint script as root?

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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to flotron For This Useful Post:
    Wikiwide

     
    flotron | # 9 | 2014-03-31, 21:28 | Report

    after:

    rpmbuild -bb SPECS/myfirstpackage.spec

    i get: bash: rpmbuild: command not found

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to flotron For This Useful Post:
    Wikiwide

     
    Schturman | # 10 | 2014-03-31, 21:38 | Report

    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...

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Schturman For This Useful Post:
    flotron, Wikiwide

     
    Page 1 of 6 | 1   2     3   | Next | Last
vBulletin® Version 3.8.8
Normal Logout