rpm-software-management / mock

Mock is a tool for a reproducible build of RPM packages.
GNU General Public License v2.0
381 stars 226 forks source link

_rpmbuild_noclean_option #999

Open tpgxyz opened 1 year ago

tpgxyz commented 1 year ago

Short description of the problem

Looks like every build a rpmbuild --help is called just to check if rpmbuild does have an option called --noclean. This was introduced here https://github.com/rpm-software-management/mock/commit/cab12758da074e8af87189bd8f4a11c73a1f1ebf

Accoding to comments in that new code it seems this _rpmbuild_noclean_option is only needed for RHEL 6. Nice overkill thb.

Output of rpm -q mock

[tpg@omv-rockpro64 ~/OpenMandriva/gettext]$ rpm -q mock mock-3.3-4.noarch

Build logs snippet.

Mock Version: 3.3
INFO: Mock Version: 3.3
INFO: Mock Version: 3.3
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/dev/pts
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/dev/pts
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/dev/shm
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/dev/shm
DEBUG: kernel version == 5.19.0
DEBUG: touching file: /var/lib/mock//cooker-aarch64/root/etc/fstab
DEBUG: touching file: /var/lib/mock//cooker-aarch64/root/etc/yum/yum.conf
DEBUG: touching file: /var/lib/mock//cooker-aarch64/root/etc/dnf/dnf.conf
DEBUG: touching file: /var/lib/mock//cooker-aarch64/root/var/log/yum.log
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/proc
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-t', 'tmpfs', '-o', 'rprivate', 'tmpfs', '/var/lib/mock//cooker-aarch64/root/proc'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/proc
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'rbind', '/proc', '/var/lib/mock//cooker-aarch64/root/proc'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'remount,nodev,noexec,nosuid,readonly,rprivate,rbind', '--target', '/var/lib/mock//cooker-aarch64/root/proc'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/sys
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-t', 'tmpfs', '-o', 'rprivate', 'tmpfs', '/var/lib/mock//cooker-aarch64/root/sys'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/sys
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'rbind', '/sys', '/var/lib/mock//cooker-aarch64/root/sys'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'remount,nodev,noexec,nosuid,readonly,rprivate,rbind', '--target', '/var/lib/mock//cooker-aarch64/root/sys'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/dev/shm
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-t', 'tmpfs', 'tmpfs', '/var/lib/mock//cooker-aarch64/root/dev/shm'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/dev/pts
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-t', 'devpts', '-o', 'gid=5,mode=0620,ptmxmode=0666,newinstance', 'devpts', '/var/lib/mock//cooker-aarch64/root/dev/pts'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/var/cache/yum
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'bind', '/var/cache/mock/cooker-aarch64/yum_cache', '/var/lib/mock//cooker-aarch64/root/var/cache/yum'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/var/cache/dnf
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/mount', '-n', '-o', 'bind', '/var/cache/mock/cooker-aarch64/dnf_cache', '/var/lib/mock//cooker-aarch64/root/var/cache/dnf'] with env {'TERM': 'vt100', 'SHELL': '/bin/sh', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: rootdir = /var/lib/mock//cooker-aarch64/root
DEBUG: resultdir = /home/omv/output
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/etc/pki/mock
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/etc/dnf
DEBUG: configure DNF vars
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/sbin/userdel', '-f', 'mockbuild'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/sbin/groupdel', 'mock'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/sbin/groupadd', '-g', '135', 'mock'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/sbin/useradd', '-o', '-m', '-u', '996', '-g', '135', '-d', '/builddir', 'mockbuild'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: useradd warning: mockbuild's uid 996 outside of the UID_MIN 1000 and UID_MAX 60000 range.
DEBUG: useradd: warning: the home directory /builddir already exists.
DEBUG: useradd: Not copying any file from skel directory into it.
DEBUG: Creating mailbox file: File exists
DEBUG: Child return code was: 0
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/RPMS
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/RPMS
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/SPECS
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/SPECS
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/SRPMS
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/SRPMS
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/SOURCES
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/BUILD
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/BUILD
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/BUILDROOT
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/BUILDROOT
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir/build/originals
DEBUG: creating dir: /var/lib/mock//cooker-aarch64/root/builddir/build/originals
DEBUG: ensuring that dir exists: /var/lib/mock//cooker-aarch64/root/builddir
DEBUG: touching file: /var/lib/mock//cooker-aarch64/root/.initialized
Finish: chroot init
Start: build phase for gettext-0.21.1-1.src.rpm
Start: build setup for gettext-0.21.1-1.src.rpm
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/bin/rpm', '-Uvh', '--nodeps', '/builddir/build/originals/gettext-0.21.1-1.src.rpm'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Updating / installing...
DEBUG: gettext-0.21.1-1                      ########################################
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['/usr/bin/rpm', '-qpl', '/builddir/build/originals/gettext-0.21.1-1.src.rpm'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: 0001-Backport-libcroco-upstream-merge-request-parser-limi.patch
DEBUG: gettext-0.19.1-drop-kde-example.patch
DEBUG: gettext-0.20.1-unescaped-left-brace.patch
DEBUG: gettext-0.21.1-covscan.patch
DEBUG: gettext-0.21.1.tar.xz
DEBUG: gettext.rpmlintrc
DEBUG: gettext.spec
DEBUG: po-mode-init.el
DEBUG: Child return code was: 0
DEBUG: child environment: None
DEBUG: Executing command: ['rpmbuild', '--help'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Usage: rpmbuild [OPTION...]
DEBUG: Build options with [ <specfile> | <tarball> | <source package> ]:
DEBUG:       -bp                        build through %prep (unpack sources and apply
DEBUG:                                  patches) from <specfile>
DEBUG:       -bf                        build through %conf (%prep, then %conf) from
DEBUG:                                  <specfile>
DEBUG:       -bc                        build through %build (%prep, %conf, then
DEBUG:                                  compile) from <specfile>
DEBUG:       -bd                        check build dependencies <specfile>
DEBUG:       -bi                        build through %install (%prep, %conf, %build,
DEBUG:                                  then install) from <specfile>
DEBUG:       -bl                        verify %files section from <specfile>
DEBUG:       -ba                        build source and binary packages from
DEBUG:                                  <specfile>
DEBUG:       -bb                        build binary package only from <specfile>
DEBUG:       -bs                        build source package only from <specfile>
DEBUG:       -br                        build source package only from <specfile> -
DEBUG:                                  calculate dynamic build requires
DEBUG:       -rp                        build through %prep (unpack sources and apply
DEBUG:                                  patches) from <source package>
DEBUG:       -rf                        build through %conf (%prep, then %conf) from
DEBUG:                                  <specfile>
DEBUG:       -rc                        build through %build (%prep, %conf, then
DEBUG:                                  compile) from <source package>
DEBUG:       -rd                        check build dependencies <source package>
DEBUG:       -ri                        build through %install (%prep, %conf, %build,
DEBUG:                                  then install) from <source package>
DEBUG:       -rl                        verify %files section from <source package>
DEBUG:       -ra                        build source and binary packages from <source
DEBUG:                                  package>
DEBUG:       -rb                        build binary package only from <source
DEBUG:                                  package>
DEBUG:       -rs                        build source package only from <source
DEBUG:                                  package>
DEBUG:       -rr                        build source package only from <source
DEBUG:                                  package> - calculate dynamic build requires
DEBUG:       -tp                        build through %prep (unpack sources and apply
DEBUG:                                  patches) from <tarball>
DEBUG:       -tf                        build through %conf (%prep, then %conf) from
DEBUG:                                  <specfile>
DEBUG:       -tc                        build through %build (%prep, %conf, then
DEBUG:                                  compile) from <tarball>
DEBUG:       -td                        check build dependencies <tarball>
DEBUG:       -ti                        build through %install (%prep, %conf, %build,
DEBUG:                                  then install) from <tarball>
DEBUG:       -ta                        build source and binary packages from
DEBUG:                                  <tarball>
DEBUG:       -tb                        build binary package only from <tarball>
DEBUG:       -ts                        build source package only from <tarball>
DEBUG:       -tr                        build source package only from <tarball> -
DEBUG:                                  calculate dynamic build requires
DEBUG:       --rebuild                  build binary package from <source package>
DEBUG:       --recompile                build through %install (%prep, %build, then
DEBUG:                                  install) from <source package>
DEBUG:       --buildroot=DIRECTORY      override build root
DEBUG:       --build-in-place           run build in current directory
DEBUG:       --clean                    remove build tree when done
DEBUG:       --nobuild                  do not execute any stages of the build
DEBUG:       --nodeps                   do not verify build dependencies
DEBUG:       --nodirtokens              generate package header(s) compatible with
DEBUG:                                  (legacy) rpm v3 packaging
DEBUG:       --noclean                  do not execute %clean stage of the build
DEBUG:       --noprep                   do not execute %prep stage of the build
DEBUG:       --nocheck                  do not execute %check stage of the build
DEBUG:       --rmsource                 remove sources when done
DEBUG:       --rmspec                   remove specfile when done
DEBUG:       --short-circuit            skip straight to specified stage (only for
DEBUG:                                  c,i)
DEBUG:       --target=CPU-VENDOR-OS     override target platform
DEBUG: Common options for all rpm modes and executables:
DEBUG:   -D, --define='MACRO EXPR'      define MACRO with value EXPR
DEBUG:       --undefine=MACRO           undefine MACRO
DEBUG:   -E, --eval='EXPR'              print macro expansion of EXPR
DEBUG:       --target=CPU-VENDOR-OS     Specify target platform
DEBUG:       --macros=<FILE:...>        read <FILE:...> instead of default file(s)
DEBUG:       --load=<FILE>              load a single macro file
DEBUG:       --noplugins                don't enable any plugins
DEBUG:       --nodigest                 don't verify package digest(s)
DEBUG:       --nosignature              don't verify package signature(s)
DEBUG:       --rcfile=<FILE:...>        read <FILE:...> instead of default file(s)
DEBUG:   -r, --root=ROOT                use ROOT as top level directory (default: "/")
DEBUG:       --dbpath=DIRECTORY         use database in DIRECTORY
DEBUG:       --querytags                display known query tags
DEBUG:       --showrc                   display final rpmrc and macro configuration
DEBUG:       --quiet                    provide less detailed output
DEBUG:   -v, --verbose                  provide more detailed output
DEBUG:       --version                  print the version of rpm being used
DEBUG: Options implemented via popt alias/exec:
DEBUG:       --with=<option>            enable configure <option> for build
DEBUG:       --without=<option>         disable configure <option> for build
DEBUG:       --scm=<scm>                shortcut for '--define="__scm <scm>"'
DEBUG:       --buildpolicy=<policy>     set buildroot <policy> (e.g. compress man
DEBUG:                                  pages)
DEBUG:       --trace                    trace macro expansion
DEBUG:       --nodebuginfo              do not generate debuginfo for this package
DEBUG: Help options:
DEBUG:   -?, --help                     Show this help message
DEBUG:       --usage                    Display brief usage message
DEBUG: Child return code was: 0
INFO: ENTER ['do_with_status'](['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --noclean --target aarch64 --nodeps /builddir/build/SPECS/gettext.spec'], chrootPath='/var/lib/mock//cooker-aarch64/root'env={'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'}shell=Falselogger=<mockbuild.trace_decorator.getLog object at 0xffff98643b90>timeout=86400uid=996gid=135user='mockbuild'nspawn_args=[]unshare_net=TrueprintOutput=False)
DEBUG: child environment: None
DEBUG: Executing command: ['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --noclean --target aarch64 --nodeps /builddir/build/SPECS/gettext.spec'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'LANG': 'C.UTF-8'} and shell False
DEBUG: Building target platforms: aarch64
DEBUG: Building for target aarch64
DEBUG: Wrote: /builddir/build/SRPMS/gettext-0.21.1-1.src.rpm
praiskup commented 1 year ago

Thank you for the report. The DEBUG output is annoying, I bet. Or what is your proposal?

praiskup commented 1 year ago

Ok, I thought we have cleanup_on_success=True by default, but that's not truth. Users most often don't specify --resultdir explicitly, and therefore we reset this default to cleanup_on_success=False. Thus, this is mostly a ubiquitous check actually.

I tend to think cleanup_on_success has nothing to do with the --noclean rpmbuild option now. With this in mind, I think we should stop overusing the already complicated cleanup_on_success and have a new, much simpler option rpmbuild_has_noclean_option=True. We would stop "runtime checking", and users could re-set it to False when needed (for EL6 and older). We could fix eol/epel-6 configs for education purposes...