Presentation is loading. Please wait.

Presentation is loading. Please wait.

Workshop: Advanced Packaging

Similar presentations


Presentation on theme: "Workshop: Advanced Packaging"— Presentation transcript:

1 Workshop: Advanced Packaging
Miroslav Suchý

2 Workshop Overview Assumptions You built at least one RPM package.
Hopefully you are familiar with Mock Limitations This workshop skips common problems and shows only variety of tips and trick which are hard to spot (or easy to skip) in documentations. Information Feel free to ask question

3 Dynamic macro The internal Lua interpreter can be used for dynamic macro content creation: %{lua: print("Requires: foo >= 1.2")} Source:

4 %pretrans Can be run during kickstart
No packages installed yet. Not even shell. You should use lua (embedded in rpm) %pre -p <lua> print("Hello from Lua") Source:

5 Triggers %triggerin –- sendmail ln -sf /usr/bin/sendmail /etc/mymailer/mailer %trigger{un|in|postun} Source:

6 Tags are macros License: BSD This is tag %build echo %{license}
Print BSD Can sometimes work in reverse. i.e. you can redefine %name, which change %buildroot, but does not change actual package name.

7 Saving state between scriptlets
%pre touch %{_localstatedir}/lib/rpm- state/%{name}.DoSomethingLater %posttrans if [ -e %{_localstatedir}/lib/rpm- state/%{name}.DoSomethingLater ]; then # do some conditional stuff rm -f %{_localstatedir}/lib/rpm- state/%{name}.DoSomethingLater fi Source:

8 Create user and group Users can come from NIC or LDAP. Use:
Requires(pre): shadow-utils %pre getent group GROUPNAME >/dev/null || \ groupadd -r GROUPNAME getent passwd USERNAME >/dev/null || \ useradd -r -g GROUPNAME -d HOMEDIR -s /sbin/nologin \ c "Useful comment about the purpose of this account" \ USERNAME exit 0 Source: oups

9 Verbose file listing rpm -qplv some.rpm
-rwxr-xr-x 1 root root Feb 4 23:01 /usr/sbin/rpmconf drwxr-xr-x 2 root root Feb 4 23:01 /usr/share/licenses/rpmconf -rw-r--r root root Dec 1 13:08 /usr/share/licenses/rpmconf/LICENSE -rw-r--r root root Feb 4 23:01 /usr/share/man/man8/rpmconf.8.gz

10 Renaming package Use both Provides and Obsoletes Name: bar
Version: 1.0 Release: 4%{?dist} Provides: foo = %{version}-%{release} Obsoletes: foo <= # Important: We set the Obsoletes release to 4 to be higher than the previous Release: 3%{?dist} Source:

11 Symlinks Relative symlinks: ln -s ./bar %{buildroot}/bin/foo
Absolute Symlinks ln -s %{_bindir}/bar %{buildroot}/bin/foo Can break in buildtime or check phase. Source:

12 Ghost files Declare that files are owned by package
Not actually installed, but removed when package uninstalled. %install touch $RPM_BUILD_ROOT%{_localstatedir}/log/blather.log %files %ghost %{_localstatedir}/log/blather.log Source:

13 Directories inside /run
Create %{_tmpfilesdir}/%{name}.conf d /run/NAME PERM USER GROUP - Source1: %{name}-tmpfiles.conf %install mkdir -p %{buildroot}%{_tmpfilesdir} install -m 0644 %{SOURCE1} %{buildroot}%{_tmpfilesdir}/%{name}.conf # The next two lines may not be needed if the upstream's install script creates them mkdir -p %{buildroot}/run install -d -m 0755 %{buildroot}/run/%{name}/ %files %dir /run/%{name}/ %{_tmpfilesdir}/%{name}.conf Source:

14 Rpmlint / fedora-review
Guidelines evolves. Every few years: Run rpmlint on spec and binary packages. fedora-review -rn some.src.rpm

15 nosrc.rpm NoSource: 0, 1 Source package, but without Source0 and Source1 files. Useful when you cannot distribute source (e.g. OracleDB). See proprietary-software/

16 mock mock -r fedora-23-x86_64 some.src.rpm
Use /etc/mock/fedora-23-x86_64.cfg mock -r ./custom-fedora-23-x86_64.cfg some.src Use $PWD/custom-fedora-23-x86_64.cfg

17 Mock customization /etc/mock/site-defaults.cfg
All tunables with comments. ~/.mock/user.cfg Your personal changes.

18 Mock building in memory
Can reduce buildtime to 16% (small pkgs) – 70 % (big packages) config_opts['plugin_conf']['tmpfs_enable'] = True config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '50g' Source: _build_packages_in_memory/

19 Mock and LVM config_opts['plugin_conf']['root_cache_enable'] = False config_opts['plugin_conf']['lvm_root_enable'] = True config_opts['plugin_conf']['lvm_root_opts'] = { 'volume_group': 'my-volume-group', 'size': '8G', 'pool_name': 'mock', 'check_size': True, } Source:

20 Mock shell mock –chroot ls * No shell expansion
well there is if there is only one arg eg. Mock –chroot 'ls *' mock –shell ls '*' Shell expanded in chroot. mock –shell Gives you shell in chroot

21 Mock --copyin Mock -r fedora-23-x86_64 --init
Mock –copyin foo.tar.gz /builddir/build/SOURCES/ Mock -r fedora-23-x86_64 --no-clean some.nosrc.rpm

22 Mock-scm dnf install mock-scm
mock -r fedora-22-x86_64 --scm-enable \ --scm-option method=git \ --scm-option package=rpmconf \ --scm-option git_get=set \ --scm-option spec=rpmconf.spec \ --scm-option branch=master --scm-option write_tar=True --scm-option git_get='git clone

23 Koji config Koji mock-config --task=XX Fedpkg mock-config

24 Secondary arch ppc-koji arm-koji s390-koji
Part of fedora-packager package.

25 rpmdev-* rpmdev-bumpspec foo.spec rpmdev-vercmp 1.2.3 1.2.a
rpmdev-extract foo.src.rpm spectool –-list-files foo.spec

26 Tito tito init tito tag tito build –rpm tito build –rpm –test
tito release fedora-git man tito, tito.props, releasers.conf

27 SCL dnf install scl-utils scl-utils-build spec2scl
spec2scl foo.spec > foo-slc.spec


Download ppt "Workshop: Advanced Packaging"

Similar presentations


Ads by Google