Build from Source
Zypper has the capability to download the source code. Then we can utilize other tool to build from source.
General Requirement
We require to install rpm-build
and toolchain.
$ zypper in gcc make rpm-build
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 28 NEW packages are going to be installed:
binutils cpp cpp7 dwz gcc gcc7 gettext-runtime gettext-tools libasan4
libatomic1 libcilkrts5 libcroco-0_6-3 libgomp1 libisl15 libitm1 liblsan0
libmpc3 libmpfr4 libmpx2 libmpxwrappers2 libtsan0 libubsan0 make patch
rpm-build systemd-rpm-macros tar which
The following package is going to be upgraded:
libgcc_s1
1 package to upgrade, 28 new.
Overall download size: 38.9 MiB. Already cached: 0 B. After the operation,
additional 148.1 MiB will be used.
Continue? [y/n/...? shows all options] (y):
Download and Extract
I choose herbstluftwm as an example.
Source install in zypper will download source code,
and extract to into /usr/src/packages/
.
Downloading also install required package dependencies.
$ zypper source-install herbstluftwm
Retrieving repository 'Window Managers' metadata .............[done]
Building repository 'Window Managers' cache ..................[done]
...
The following 213 NEW packages are going to be installed:
Mesa Mesa-libEGL-devel Mesa-libEGL1 Mesa-libGL-devel Mesa-libGL1
...
xorg-x11-devel xorg-x11-util-devel xproto-devel xtrans xz-devel
zlib-devel
The following source package is going to be installed:
herbstluftwm
The following 5 packages are going to be upgraded:
glibc glibc-locale libgcrypt20 libstdc++6 python-base
5 packages to upgrade, 213 new, 1 source package.
Overall download size: 77.4 MiB. Already cached: 0 B. After the
operation, additional 281.5 MiB will be used.
Continue? [y/n/...? shows all options] (y):
Please click the figure for longer content.
Build Dependencies
You can also install only updated dependencies. This happen sometimes after a while, like after a month, there should be package update in tumbleweed.
$ zypper si --build-deps-only herbstluftwm
Reading installed packages...
Loading repository data...
Resolving package dependencies...
The following 2 NEW packages are going to be installed:
gcc-c++ gcc7-c++
2 new packages to install.
Overall download size: 9.3 MiB. Already cached: 0 B. After the
operation, additional 25.6 MiB will be used.
Continue? [y/n/...? shows all options] (y):
[
Source Path
Now we have these directories, we need the herbstluftwm.spec.
$ ls /usr/src/packages/
BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
$ ls -l /usr/src/packages/SPECS/
total 8
-rw-r--r-- 1 root root 4468 Aug 31 16:19 herbstluftwm.spec
Consider use SPECS path as working directory for build.
$ cd /usr/src/packages/SPECS/
Build
Just one command rpmbuild -ba
.
$ rpmbuild -ba herbstluftwm.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.bXhF1w
+ umask 022
+ cd /usr/src/packages/BUILD
+ cd /usr/src/packages/BUILD
+ rm -rf herbstluftwm-1335135043
+ /usr/bin/bzip2 -dc /usr/src/packages/SOURCES/herbstluftwm-1335135043.tar.bz2
...
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.SxVkky
+ umask 022
+ cd /usr/src/packages/BUILD
+ cd herbstluftwm-1335135043
+ rm -rf /usr/src/packages/BUILDROOT/herbstluftwm-1335135043-3.280.x86_64
+ exit 0
Install The RPM Output
Consider check if the output exist, and install.
$ ls -l /usr/src/packages/RPMS/x86_64/
total 152
-rw-r--r-- 1 root root 152794 Sep 3 17:28 herbstluftwm-1335135043-3.280.x86_64.rpm
$ rpm -iv /usr/src/packages/RPMS/x86_64/herbstluftwm-1335135043-3.280.x86_64.rpm
Preparing packages...
herbstluftwm-1335135043-3.280.x86_64
Now we are almost done.
Inspect Package
Often we need to inspect .rpm
package.
No need any zypper
command,
as this more like an rpm
issue.
rpmlint
Check for possible issue, similar to lintian or namcap.
$ rpmlint herbstluftwm-0.7.0-2.1.x86_64.rpm
herbstluftwm.x86_64: W: unstripped-binary-or-object /usr/bin/herbstclient
herbstluftwm.x86_64: W: unstripped-binary-or-object /usr/bin/herbstluftwm
herbstluftwm.x86_64: W: position-independent-executable-suggested /usr/bin/herbstclient
herbstluftwm.x86_64: W: position-independent-executable-suggested /usr/bin/herbstluftwm
herbstluftwm.x86_64: W: no-manual-page-for-binary dmenu_run_hlwm
herbstluftwm.x86_64: W: install-file-in-docs /usr/share/doc/herbstluftwm/INSTALL
herbstluftwm.x86_64: W: file-contains-current-date /usr/bin/herbstclient
herbstluftwm.x86_64: W: file-contains-current-date /usr/bin/herbstluftwm
1 packages and 0 specfiles checked; 0 errors, 8 warnings.
rpm -Qpl
You can also query file -Qpl
directly to the .rpm
package.
$ rpm -qpl /usr/src/packages/RPMS/x86_64/herbstluftwm-0.7.0-2.1.x86_64.rpm
/etc/bash_completion.d/herbstclient-completion
/etc/xdg/herbstluftwm
/etc/xdg/herbstluftwm/autostart
/etc/xdg/herbstluftwm/panel.sh
/etc/xdg/herbstluftwm/restartpanels.sh
/usr/bin/dmenu_run_hlwm
/usr/bin/herbstclient
/usr/bin/herbstluftwm
/usr/share/doc/herbstluftwm
/usr/share/doc/herbstluftwm/BUGS
rpmls
Or use the rpmls
from the rpmdevtools
package
$ rpmls /usr/src/packages/RPMS/x86_64/herbstluftwm-0.7.0-2.1.x86_64.rpm
-rw-r--r-- /etc/bash_completion.d/herbstclient-completion
drwxr-xr-x /etc/xdg/herbstluftwm
-rwxr-xr-x /etc/xdg/herbstluftwm/autostart
-rwxr-xr-x /etc/xdg/herbstluftwm/panel.sh
-rwxr-xr-x /etc/xdg/herbstluftwm/restartpanels.sh
-rwxr-xr-x /usr/bin/dmenu_run_hlwm
-rwxr-xr-x /usr/bin/herbstclient
-rwxr-xr-x /usr/bin/herbstluftwm
drwxr-xr-x /usr/share/doc/herbstluftwm
-rw-r--r-- /usr/share/doc/herbstluftwm/BUGS
rpm2cpio
This one also extract.
$ rpm2cpio /usr/src/packages/RPMS/x86_64/herbstluftwm-0.7.0-2.1.x86_64.rpm | cpio -vid
./etc/bash_completion.d/herbstclient-completion
./etc/xdg/herbstluftwm
./etc/xdg/herbstluftwm/autostart
./etc/xdg/herbstluftwm/panel.sh
./etc/xdg/herbstluftwm/restartpanels.sh
./usr/bin/dmenu_run_hlwm
./usr/bin/herbstclient
./usr/bin/herbstluftwm
./usr/share/doc/herbstluftwm
./usr/share/doc/herbstluftwm/BUGS
Hold Package
Zypper hold package using lock mechanism. This is just terminology.
Case Example
Suppose you want to do system upgrade, but you do not want to upgrade certain package. There is a good reason for these, such as keeping old driver, because the latest has a issue or such reason. Or maybe we want to keep our current beloved newly compiled herbstluftwm that equipped with super duper specific configuration parameter optimization.
$ zypper dup
Warning: ...
...
The following package is going to change vendor:
herbstluftwm -> obs://build.opensuse.org/X11
...
You can skip or ignore by hold package so that the package will kept intact while doing system upgrade.
Add Lock
We can add lock easily using zypper.
$ zypper al herbstluftwm
Specified lock has been successfully added.
This will put new package entry in /etc/zypp/locks
.
$ cat /etc/zypp/locks
type: package
match_type: glob
case_sensitive: on
solvable_name: herbstluftwm
Now you can view the entry in nice table.
$ zypper ll
# | Name | Type | Repository
--+--------------+---------+-----------
1 | herbstluftwm | package | (any)
Test Example
Now we have different result
when doing the same zypper dup
command.
$ zypper dup
Warning: ...
...
The following item is locked and will not be changed by any action:
Installed:
herbstluftwm
Remove Lock
You can unlock package by removing list
from configuration /etc/zypp/locks
or command line
$ zypper rl herbstluftwm
1 lock has been successfully removed.
Interesting Issue
systemd Dependencies
While solving the no manual problem, I encountered another issue.
$ zypper in man
This is somehow interesting, manual pages in openSUSE depend on systemd.
Why would a manual man
need to depend to an init ?
$ zypper info --requires man
Requires : [32]
cron
$ zypper info --requires cron
Requires : [5]
cronie = 1.5.1-66.3
$ zypper info --requires cronie
Requires : [26]
systemd
openSUSE minimal install allow the user to remove systemd, leaving the system without init.
Conclusion
These are just preliminary knowledge about Zypper.
Thank you for reading