Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: How does zypper configure from rpm?

Hybrid View

  1. #1

    Default How does zypper configure from rpm?

    Hi,
    a bit of an odd question, but I was wondering how zypper installs and configures apps from the rpm. For example, if I install sddm (simple desktop display manager), not only do the various files get installed in /lib, /share etc as they are listed in the rpm files but also the sddm user and group gets created, the folder /var/lib/sddm gets created, permissions get set and a few other things.

    At first I thought there is some script in the rpm that gets detected and run during the install but I can find any such thing in the rpm.

    How does zypper do these extra configurations? Where are the scripts or what controls it?

    Thanks,
    Chris.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,124

    Default Re: How does zypper configure from rpm?

    I do not know about this specific case, but it is quite normal for an RPM to have "after installation" scripts that will then be run. But because you say (though not prove/show) that there isn't such a script within this specific RPM package I do not know.
    Henk van Velden

  3. #3

    Default Re: How does zypper configure from rpm?

    Hi,

    There is a script and it is called a specfile, files the end is .spec but it is not included in a normal rpm. have a look at OBS and you will see some examples of a spec files.
    Also at software.opensuse.org you can follow the links and for the packages and you will see the spec files.


    Code:
    https://build.opensuse.org/package/show/openSUSE%3AFactory/sddm

    Code:
    https://build.opensuse.org/package/view_file/openSUSE:Factory/sddm/sddm.spec?expand=1
    I hope that helps.
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,124

    Default Re: How does zypper configure from rpm?

    I am not sure that is what he means. He does not mean any specifications while building it, but scripts that are inside an RPM and that are run at e.g. installation and de-installation.
    Code:
    man rpm
    talks about
    ... %pre, %post, %preun, %postun %pretrans, and %posttrans scriptlet(s).
    Last edited by hcvv; 01-Sep-2018 at 03:57. Reason: typo
    Henk van Velden

  5. #5
    Join Date
    Oct 2014
    Location
    Italy
    Posts
    1,674

    Default Re: How does zypper configure from rpm?

    You can check the rpm with the --scripts option, for instance:
    Code:
    bruno@LT_B:~/Downloads> rpm -q --scripts libblkid1-2.29.2-8.1.x86_64.rpm
    postinstall program: /sbin/ldconfig
    postuninstall program: /sbin/ldconfig
    bruno@LT_B:~/Downloads>
    Main: Leap 15 Gnome on i7 4720HQ + Geforce GTX960M
    Test: Leap 42.3 (& others) on Core2Duo + GM965

  6. #6

    Default Re: How does zypper configure from rpm?

    Hi all and thank you for the replies. Using the rpm switch --scripts does indeed show me the spec file pre and post install scriptlet that I was after:

    Code:
    chris@asus-rog:~> rpm -q --scripts lightdm
    preinstall scriptlet (using /bin/sh):
    /usr/sbin/groupadd -r lightdm 2> /dev/null || :
    /usr/sbin/useradd -r -g lightdm -s /bin/false -c "LightDM daemon" \
      -d /var/lib/lightdm lightdm 2> /dev/null || :
    postinstall scriptlet (using /bin/sh):
    # Special trick: migrate users from lxdm to lightdm
    # see https://lists.opensuse.org/opensuse-factory/2016-07/msg00417.html
    . /etc/sysconfig/displaymanager
    if [ -z "$DISPLAYMANAGER" -o "$DISPLAYMANAGER" = "lxdm" ] ; then
        sed -i 's/^DISPLAYMANAGER=".*"/DISPLAYMANAGER="lightdm"/' /etc/sysconfig/displaymanager
    fi
    postuninstall scriptlet (using /bin/sh):
    if [ "$1" -eq 0 ]; then
        . /etc/sysconfig/displaymanager
        if [ "$DISPLAYMANAGER" == "lightdm" ] ; then
            sed -i 's/^DISPLAYMANAGER="lightdm"/DISPLAYMANAGER=""/' /etc/sysconfig/displaymanager
        fi
    fi
    However it only works for installed packages. When I tried to examine the sddm package that I only downloaded I got :

    Code:
    chris@asus-rog:~> rpm -q --scripts sddm-0.17.0-lp150.8.1.x86_64.rpm
    package sddm-0.17.0-lp150.8.1.x86_64.rpm is not installed
    chris@asus-rog:~> ls sddm*
    sddm-0.17.0-lp150.8.1.x86_64.rpm
    chris@asus-rog:~>
    I did find that the sddm spec file is contained in the source rpm folder at https://download.opensuse.org/source...50.8.1.src.rpm

    So I am making an assumption here that when a package gets installed via zypper that the source rpm gets downloaded too so that the spec file is accessed.

    But what bugs me now is that since the rpms are deleted after installation, where is the --scripts switch finding the info. I can only assume it is in the rpm database at /var/lib/rpm.
    Code:
    chris@asus-rog:~> ls -al /var/lib/rpm
    total 224628
    drwxr-xr-x 1 root root       276 Jun  7 20:11 .
    drwxr-xr-x 1 root root       846 Aug 16 14:29 ..
    drwxr-xr-x 1 root root      1368 Sep  1 12:12 alternatives
    -rw-r--r-- 1 root root  15319040 Sep  1 13:06 Basenames
    -rw-r--r-- 1 root root     20480 Sep  1 12:12 Conflictname
    -rw-r--r-- 1 root root   5652480 Sep  1 13:06 Dirnames
    -rw-r--r-- 1 root root     77824 Sep  1 13:06 Group
    -rw-r--r-- 1 root root     86016 Sep  1 13:06 Installtid
    -rw-r--r-- 1 root root    270336 Sep  1 13:06 Name
    -rw-r--r-- 1 root root     57344 Sep  1 12:12 Obsoletename
    -rw-r--r-- 1 root root 200830976 Sep  1 13:06 Packages
    -rw-r--r-- 1 root root   5943296 Sep  1 13:06 Providename
    -rw-r--r-- 1 root root   1069056 Sep  1 13:05 Requirename
    -rw-r--r-- 1 root root         0 Mar 12 16:28 .rpm.lock
    -rw-r--r-- 1 root root    442368 Sep  1 13:06 Sha1header
    -rw-r--r-- 1 root root    274432 Sep  1 13:06 Sigmd5
    -rw-r--r-- 1 root root      8192 Sep  1 12:11 Triggername
    Is there a guide/howto on how package management process works - what gets downloaded/run/archive/deleted etc? This is just for my idle curiosity as I am playing with "Linux From Scratch" in a virtual machine trying to understand linux a little better.

    Thanks,
    Chris.

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,124

    Default Re: How does zypper configure from rpm?

    Please a hint for the future.

    You said in your first post here
    At first I thought there is some script in the rpm that gets detected and run during the install but I can find any such thing in the rpm.
    but you failed to tell how that search was done. That left us with the big question, did he use
    Code:
    rpm -q --scripts
    or not?

    So please, next time always explain in detail what you did and got (preferable by copy/past between CODE tags) and do not only tell vague stories. That is the only way to make others to answer with anything useful.

    and on your question to learn more about RPM, apart from
    Code:
    man rpm
    there is http://rpm.org/ , really not difficult to find using a search engine on the internet.
    Henk van Velden

  8. #8
    Join Date
    Oct 2014
    Location
    Italy
    Posts
    1,674

    Default Re: How does zypper configure from rpm?

    Quote Originally Posted by kitman View Post
    However it only works for installed packages. When I tried to examine the sddm package that I only downloaded I got :

    Code:
    chris@asus-rog:~> rpm -q --scripts sddm-0.17.0-lp150.8.1.x86_64.rpm
    package sddm-0.17.0-lp150.8.1.x86_64.rpm is not installed
    chris@asus-rog:~> ls sddm*
    sddm-0.17.0-lp150.8.1.x86_64.rpm
    chris@asus-rog:~>
    Are you sure? This is what I get:
    Code:
    bruno@LT_B:~/Downloads> rpm -q --scripts sddm-0.17.0-lp150.9.3.1.x86_64.rpm
    preinstall scriptlet (using /bin/sh):
    /usr/sbin/groupadd -r sddm 2> /dev/null || :
    /usr/sbin/useradd -r -g sddm -s /bin/false -c "SDDM daemon" \
        -d /var/lib/sddm sddm 2> /dev/null || :
    postinstall scriptlet (using /bin/sh):
    if [ $1 -eq 2 -a -f /etc/sddm.conf ]; then
        # Avoid changing sddm.conf's timestamp if no modifications done
        tempconf="$(mktemp)"
    
        # SDDM 0.14.0 moved maui into the built-in resources
        # SDDM <= 0.15.0 had no system config dir, so we need to remove the
        # moved configuration options from the old single config file
        sed -e 's/^Current=maui$/Current=/g' \
            -e '\#^DisplayCommand=/etc/X11/xdm/Xsetup#d' \
            -e '\#^MinimumVT=7$#d' \
            -e '\#^ServerPath=/usr/bin/X$#d' \
            -e '\#^SessionCommand=/etc/X11/xdm/Xsession$#d' \
            /etc/sddm.conf > "${tempconf}"
    
        cmp -s "${tempconf}" "/etc/sddm.conf" || cp "${tempconf}" "/etc/sddm.conf"
        rm "${tempconf}"
    fi
    /usr/sbin/update-alternatives --install /usr/lib/X11/displaymanagers/default-displaymanager \
      default-displaymanager /usr/lib/X11/displaymanagers/sddm 25
    postuninstall scriptlet (using /bin/sh):
    [ -f /usr/lib/X11/displaymanagers/sddm ] || /usr/sbin/update-alternatives \
      --remove default-displaymanager /usr/lib/X11/displaymanagers/sddm
    bruno@LT_B:~/Downloads>
    Using gdm/Gnome here, so sddm is definitely not installed:
    Code:
    bruno@LT_B:~/Downloads> zypper se -iv sddm
    Loading repository data...
    Reading installed packages...
    No matching items found.
    bruno@LT_B:~/Downloads>
    Main: Leap 15 Gnome on i7 4720HQ + Geforce GTX960M
    Test: Leap 42.3 (& others) on Core2Duo + GM965

  9. #9

    Default Re: How does zypper configure from rpm?

    Hi everyone,

    Quote Originally Posted by OrsoBruno View Post
    Are you sure? This is what I get:
    Code:
    bruno@LT_B:~/Downloads> rpm -q --scripts sddm-0.17.0-lp150.9.3.1.x86_64.rpm
    preinstall scriptlet (using /bin/sh):
    /usr/sbin/groupadd -r sddm 2> /dev/null || :
    /usr/sbin/useradd -r -g sddm -s /bin/false -c "SDDM daemon" \
        -d /var/lib/sddm sddm 2> /dev/null || :
    postinstall scriptlet (using /bin/sh):
    if [ $1 -eq 2 -a -f /etc/sddm.conf ]; then
        # Avoid changing sddm.conf's timestamp if no modifications done
        tempconf="$(mktemp)"
    
        # SDDM 0.14.0 moved maui into the built-in resources
        # SDDM <= 0.15.0 had no system config dir, so we need to remove the
        # moved configuration options from the old single config file
        sed -e 's/^Current=maui$/Current=/g' \
            -e '\#^DisplayCommand=/etc/X11/xdm/Xsetup#d' \
            -e '\#^MinimumVT=7$#d' \
            -e '\#^ServerPath=/usr/bin/X$#d' \
            -e '\#^SessionCommand=/etc/X11/xdm/Xsession$#d' \
            /etc/sddm.conf > "${tempconf}"
    
        cmp -s "${tempconf}" "/etc/sddm.conf" || cp "${tempconf}" "/etc/sddm.conf"
        rm "${tempconf}"
    fi
    /usr/sbin/update-alternatives --install /usr/lib/X11/displaymanagers/default-displaymanager \
      default-displaymanager /usr/lib/X11/displaymanagers/sddm 25
    postuninstall scriptlet (using /bin/sh):
    [ -f /usr/lib/X11/displaymanagers/sddm ] || /usr/sbin/update-alternatives \
      --remove default-displaymanager /usr/lib/X11/displaymanagers/sddm
    bruno@LT_B:~/Downloads>
    I discovered why rpm reported no installed package. It was because rpm was run against a downloaded rpm file. If I run against the package name only I get info.

    Code:
    chris@asus-rog:~> rpm -qi --scripts sddm-0.17.0-lp150.8.1.x86_64.rpm
    package sddm-0.17.0-lp150.8.1.x86_64.rpm is not installed
    chris@asus-rog:~> rpm -qi --scripts sddm
    Name        : sddm
    Version     : 0.14.0
    Release     : 5.1
    Architecture: x86_64
    Install Date: Wed 14 Mar 2018 04:53:50 PM AWST
    Group       : System/GUI/KDE
    Size        : 4367555
    License     : GPL-2.0+
    Signature   : RSA/SHA256, Tue 11 Jul 2017 10:21:15 PM AWST, Key ID b88b2fd43dbdc284
    Source RPM  : sddm-0.14.0-5.1.src.rpm
    Build Date  : Tue 11 Jul 2017 10:20:55 PM AWST
    Build Host  : lamb11
    Relocations : (not relocatable)
    Packager    : http://bugs.opensuse.org
    Vendor      : openSUSE
    URL         : https://github.com/sddm/sddm
    Summary     : QML-based display manager
    Description :
    SDDM is a display manager for X11. It uses technologies like QtQuick,
    which in turn gives the designer the ability to create animated user
    interfaces.
    Distribution: openSUSE Leap 42.3
    preinstall scriptlet (using /bin/sh):
    /usr/sbin/groupadd -r sddm 2> /dev/null || :
    /usr/sbin/useradd -r -g sddm -s /bin/false -c "SDDM daemon" \
        -d /var/lib/sddm sddm 2> /dev/null || :
    postinstall scriptlet (using /bin/sh):
    if [ $1 -eq 2 -a -f /etc/sddm.conf ]; then
        sed -i -e 's/^Current=maui$/Current=/g' /etc/sddm.conf
    fi

    Quote Originally Posted by hcvv

    and on your question to learn more about RPM, apart from
    Code:
         man rpm
    there is http://rpm.org/ , really not difficult to find using a search engine on the internet.
    I have browsed the man page and had a quick look at the rpm.org pages - maybe there are more details in that web site. But perhaps in my ignorance I did not explain properly what I was after. I doubt I will ever write an rpm file but I would like to at least understand the processes and flow path of activity (something with block diagrams and arrows) of adding and updating a program -

    1. Adding a repo (easy)
    2. How does yast/zypper read the various files in the repo?
    3. Does yast/zypper access the source rpm at the same time to get the spec file when installing a program?
    4. When do the databases in /var/lib/rpm get updated and by what files.
    5. How does yast/zypper detect an updated program? (from the https://download.opensuse.org/update/... site?)
    6. too many questions


    Just put this down to curiosity rather than a problem.

    Thanks again,
    Chris.

  10. #10

    Default Re: How does zypper configure from rpm?

    Hi,

    The backend that zypper is using is called libzypp see

    the output of

    Code:
    zypper --no-refresh if libzypp
    and the docs

    Code:
    https://doc.opensuse.org/projects/libzypp/HEAD/
    How that works, i don't know...
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •