make-srpm-cleanup(7)
| MAKE-SRPM-CLEANUP(7) | MAKE-SRPM-CLEANUP(7) |
NAME
make-srpm-cleanup - truntate unused files in SRPM packages stage by stage
SYNOPSIS
make status
make stage...
make stage...-status
make list-...
make show-...
make check-...
make update-...
make export...
make statclean
make clean...
make update-versions.sed
DESCRIPTION
In order to control the process of SRPM cleanup with make(1) copy the example Makefile from /usr/share/doc/srpm-cleanup/Makefile.example to Makefile in the working directory and modify it in accordance with your needs. You can also write your own configuration Makefile from scratch but don´t forget to include /usr/share/srpm-cleanup/main.mk at its end.
Stages
The whole process of SRPM cleanup is divided onto 5 following stages:
- Stage I: SRPM packages are rebuilt using hsh-separate-sources(1) and a list of unused files is written down for each package.
- Stage II: SRPM packages are rebuilt using srpm-cleanup(1) and a TAR with source files is written down for each package. Comparing to the original package, the resulting TAR doesn´t contain unused files.
- Stage III: For each TAR package the corresponding SRPM package is built using srpm-cleanup(1).
- Stage IV: SRPM packages from Stage III are rebuilt with hsh-separate-sources(1) in verification mode. The verification process checks there are no new unused files. However, in some situations that check should be toolerated (see TOOLERANCE below).
- Stage V: The resulting verified SRPM packages are rebuilt with additional options (for example --with-pre and --with-post). For packages that have failed with verification the corresponding original SRPMs are rebuilt instead.
On each stage the packages are rebuilt in parallel inside a number of hasher(1) slots on a set of build hosts. The results of that builds and the build log files are transferred from build hosts and collected in the configured directories. The results of one stage are used on the next stage.
When a package is processed the output of used tools such as hsh-separate-sources(1) is written to the stage log file. The tarnscript of low-level operation goes to the build log file. After the whole stage is passed the corresponding stage status file is updated. That status file is constituted from the stage log records plus a special status record for each package that is deduced from the stage log records related to it. With the stage status file it is very easy to find the resulting status of each particular package.
Knowing the resulting status of each package it is possible to retry the stage processing for only a subset of packages based on thier status and after making the necessary configuration changes (see "Stage retries" below).
For each stage the following common targets are available:
- stageN: Run the stage N for packages that havn´t yet been processed. Run the stage on all configured BUILDERS on all architectures (see CONFIGURATION below). The values for N are 1..4, 5v and 5o. The last two are for the separate substages of Stage V: rebuilt of verified and the original packages.
- stageN-status: Show statistics for stage N.
- list-stageN-C[-A]: List names and versions of packages that fall into category C and optionally architecture A in stage N. The packages are divided onto categories using information from the stage status file.
Available architectures A are those for which BUILDERS are defined (see CONFIGURATION below).
Popular C examples among different stages are:
- done: successfully built packages,
- noatt: there were no attempts to build these packages yet,
- excl: build failed because of ExclusiveArch or ExcludeArch declaration,
- blderr: any kind of build error,
- brkndep: build failed because of broken dependencies,
- chkerr: build failed in the %check section,
- nosrpm: the builder was unable to find the SRPM file for the given package,
- nospace: build failed due to no space left on device,
- noinode: build failed due to lack of inodes,
- logerr: hsh-separate-sources(1) failed to analize the build log,
- other: any other error,
- unused: the packages are not listed in SRPM_LISTS (see CONFIGURATION below).
Stage retries
When a lot of packages are processed, building some of them are often failed --- that´s normal. In that situation the first thing is to investigate the situation, then fix the problem and re-run the stage for the failed packages only.
To help the investigation the following additional targets are available for each stage:
- list-stageN-C[-A]-logs: List paths to the build logs of packages that fall into category C and optionally architecture A in stage N.
- show-stageN-C[-A]-status: Output the stage status log entries related to the packages that fall into category C and optionally architecture A in stage N.
- show-stageN-pkg-status: Output the stage status log entries related to a single package specified with PKG=PKG. For stages I, IV-V the architecture can be additionally limited with ARCH=ARCH.
To re-run the stage for the failed packages only use:
- stageN-retry-C[-A]: Retry the stage N for packages that fall into category C and optionally architecture A.
- stageN-retry-pkgs
If INDEP_LOGS (see CONFIGURATION) is set then a number of such jobs can be run for the same stage in parallel.
To re-run the stage for all packages (failed, done and not tried) use:
- •
- stageN-rebuild-all: Run stage N from scratch.
When re-running the stage it is possible to alter the configuration of builders, for instance, to change the number of hasher slots --- see BUILDERS in CONFIGURATION below. Additionaly, for Stage V (both 5v and 5o parts) it is possible to run the process for only a subset of architectures: use FOR_ARCHES=<arch1,arch2...> on the command line.
Partial Stage V targets
For Stage V the following partial subtartets are available:
- stage5v|o-all: Run the stage for not yet tried packages included in all defined architectures.
- stage5v|o-A: Run the stage for not yet tried packages of architecture A.
Complete stage rebuilds
The run of a stageN target selects and process packages that weren´t processed on that stage yet (that are the packages from noatt category). In order to run the stage for all listed SRPM packages use stageN-rebuild-all target. However, the hsh-separate-sources(1) and srpm-cleanup(1) tools are known to skip the already processed packages anyway. So, to really rebuild all packages delete the existing results with stageN-clean or add -f|--force to the OPTS (see Runtime options below).
Rebuilds with manual package selection and multistage retries
- stageN-retry-pkgs: Re-run stage N for a specified list of packages. These targets expect name-version-release of packages to be specified on the command line with PKGS=<PKGS...>. In order to rebuild a package forcily pass -f|--force to the OPTS (see Runtime options below).
- reclean-pkgs:
- reclean-and-rebuild-pkgs:
Dry runs
For each stage target, either the main stage target or any retry or additional target, there is the corresponding -dry-run target available. In the dry-run mode the stage isn´t actually run. Instead of that the list of command lines that would be executed in the normal stage run is printed out.
Moreover, for each stage target the corresponding -dry-run-run target is also available. In that "semi-dry" mode the tools are actually run (on remote hosts, if configured --- see BUILDERS), but each tools is run with --dry-run option.
In both dry-run modes no packages are built, the log files are not written and the stage status is not updated.
Building external SRPMs
It is possible to rebuild out of the repo SRPM packages passing WITH_SRPMS=EXTRA_DIR to any stage target. However, dist-tags of such packages are undefined!
Check and export
- •
- check-rebuild-lists: This target outputs the final statistics after stage IV separated the onto four following categories: done-included-all --- successfully rebuilt packages, included on all architectures; done-xincluded --- successfully rebuilt packages, included on some architectures (for each architecture); not-done-included-all --- failed packages, included on all architectures; not-done-xincluded --- failed packages, included on some architectures (for each architecture).
- These package lists constitute a plan for stage V. The successfully rebuilt packages go to V/1 substage and the rest goes to V/2 (rebuilt of the original packages).
- The target checks for intersections between the resulting lists and package coverage on each architecture (i. e. the number of all packages included in SRPM_LISTS versus the number of packages, planned for stage V).
- •
- check-rebuild-results-A: The target outputs statistics similar to check-rebuild-lists, but from stage V point of view: the number of planned verified and original builds can be compared with actual V/1 and V/2 results. The additional feature of the target is that the coverage is calculated twice: first as a plain number of packages successfully rebuilt on stage V, and a second time --- with additional number of packages, failed due to architecture exclusion (i. e. ExcludeArch and ExclusiveArch tags in the RPM spec file).
- The statistic is output for the specified architecture A only.
- check-versions: Runs check-included and then check-disttags if DISTTAG_OPTS is defined (see Configuring Stage V).
- check-included: Output the diff between SRPM_LISTS and the packages, actually included into processing on the stages I-V. Normally, the diff should be empty.
- check-disttags: Compares the dist-tags of packages in the reference repository REPO_DIR with dist-tags in the stage V resulting packages in REBUILD_V_DIR and REBUILD_O_DIR directories (see Configuring Stage V). Normally, the diff should be empty.
- export: Copy stage V results from REBUILD_V_DIR and REBUILD_O_DIR directories along with index files into the target directory DESTDIR=DESTDIR (can be specified on the command line or configured in the Makefile). Any extra RPM files in DESTDIR are removed making the source and destination synchronized.
- Additional options can be passed to rsync(1) via EXPORT_OPTS=EXPORT_OPTS.
- repo: Constructs an APT repository at OUTREPO (repo by default) with clean, orig, clean-dbg and orig-dbg packages sections.
- export-repo: Copies the repository to DESTDIR. By default the symbolic links to packages are resolved. In order to copy the links as is, override the EXPORT_REPO_OPTS with the empty or an other set of rsync(1) options without -L.
Clean targets
- statclean: Deletes all temporary files used to calculate statistic values for stageN-status targets.
- clean-stage5v-unused: Delete REBUILD_V_DIR packages that aren´t currently included in SRPM_LISTS.
- clean-stage5o-unused: Delete REBUILD_O_DIR packages that aren´t currently included in SRPM_LISTS.
- clean-indices: Remove the index files, first of all, the DISTTAG_INDEX file used for stage V (see Configuring Stage V). The indices can explicitly be re-created with index-rebuild target.
- stageN-clean: Delete all results and status files of stage N. WARNING! these targets are dangerous! In order to protect the results from accidentally deletion a confirmation is asked.
Other targets
- list-srpms: Output the list of all included SRPMs.
- show-builders: Output the resulting command-line for the configured BUILDERS (see the CONFIGURATION below) that is used for rebuilding of binary packages (stages I, IV-V).
- show-cleaners: Output the resulting command-line for the configured CLEANERS (see the CONFIGURATION below) that is used to clean-up source packages (stage II).
- show-srpm-builders: Output the resulting command-line for the configured BUILDERS (see the CONFIGURATION below) that is used for rebuilding of source packages (stage III).
Scripts
- •
- update-versions.sed: The script that is automatically prepared from BIN_LIST (see Configuring Stage V) and can be used to update version numbers in the existing SRPM lists.
CONFIGURATION
General configuration
- •
- SRPM_LISTS: Defines source package list files for each architecture. Each set of files should be added to SRPM_LISTS using $(call def_srpm_list,arch,files...), where arch is the name of an architecture and files is a space-separated list of files listing source RPM file names (name-version-release.src.rpm) line by line.
- For example:
-
SRPM_LISTS = $(call def_srpm_list,ppc64le,lists/alt-sp8-server-latest-ppc64le.iso.srpms) SRPM_LISTS += $(call def_srpm_list,aarch64,lists/alt-sp8-server-latest-aarch64.iso.srpms lists/alt-sp8-workstation-latest-aarch64.iso.srpms) SRPM_LISTS += $(call def_srpm_list,armh,lists/alt-sp8-workstation-01-mcom02-latest-armh.img.srpm-list) SRPM_LISTS += $(call def_srpm_list,i586,lists/alt-sp8-server-latest-i586.iso.srpms lists/alt-sp8-workstation-latest-i586.iso.srpms) SRPM_LISTS += $(call def_srpm_list,x86_64,lists/alt-sp8-server-latest-x86_64.iso.srpms lists/alt-sp8-workstation-latest-x86_64.iso.srpms)
- •
- BUILDERS: Defines the set of local and remote builders (hosts where hsh-separate-sources(1) can be run). Each builder should be added to BUILDERS using $(call def_builder,[user@]hostname,arches...,slots,workdir,repo[,nprofile]), where [user@]hostname defines the name of the remote host and an optional user name to connect with, arches is a space-separated list of architecture names, slots is a list of a range of Hasher slot numbers, workdir is the path to the working directory (on the remote host), repo is the path to package repository (on the remote host) and nprofile is the optional name of a CPU profile file.
- All of the def_builder argumentsare match the command line options of hsh-separate-sources(1). In order to build on the local machine use : for the name of the host and don´t specify the user name.
- Example:
- ``` BUILDERS = $(call def_builder,ppc,ppc64le,$(ppc_slots),/tmp/.private/builder/hashers,$(nfs_repo),$(nprocs))
BUILDERS += $(call def_builder,taishan1,aarch64 armh,$(arm_slots),/tmp/.private/builder/hashers,$(nfs_repo),$(nprocs))
BUILDERS += $(call def_builder,builder_new@ivkbuilder,x86_64 i586,$(ivk_slots),/tmp/.private/builder_new/hashers,$(ivk_repo),$(nprocs)) ```
- •
- CLEANERS: Defines the set of local and remote cleaners (hosts where srpm-cleanup(1) can be run). Each cleaner should be added to CLEANERS using $(call def_cleaner,[user@]hostname,slots,workdir,srpms), where [user@]hostname defines the name of the remote host and an optional user name to connect with, slots is a space-separated list of a range of Hasher slot numbers, workdir is the path to the working directory (on the remote host) and srpms is the path to the directory with SRPM files (on the remote host).
- All of the def_cleaner argumentsare match the command line options of srpm-cleanup(1). In order to build on the local machine use : for the name of the host and don´t specify the user name.
- Example:
-
CLEANERS = $(call def_cleaner,ppc,1-40,/tmp/.private/builder/hashers,$(nfs_repo)/files/SRPMS) CLEANERS += $(call def_cleaner,taishan1,1-40,/tmp/.private/builder/hashers,$(nfs_repo)/files/SRPMS) CLEANERS += $(call def_cleaner,builder_new@ivkbuilder,1-40,/tmp/.private/builder/hashers,$(ivk_repo)/files/SRPMS)
- •
- EXTRA_ARCHES: Specify extra arches of those builders that aren´t currently configured.
Remote options
- SSHDELAY: Log-in to the next remote host after a delay. Setting this to a positive non-zero value helps against SSH errors when a lot of parallel remote processes are started.
- CLEANUP: Set this to enable --cleanup mode with hsh-separate-sources(1) and srpm-cleanup(1) in order to save space on the remote hosts. Note, that --cleanup is incompatible with --selfie, so the scripts have to be copied to the hosts beforehand (see also Tools).
Tools
- HSH_SEPARATE_SOURCES: Sets the path to the hsh-separate-sources(1) script on all remote hosts (no customization yet).
- SRPM_CLEANUP: Sets the path to the srpm-cleanup(1) script on all remote hosts (no customization yet).
The default is to use the script from the current directory, then --- the script in PATH.
Log options
- LOG_SUF: Defines a suffix to use for stage log file names. Using the same stage log file name prevents from running multiple jobs for the same stage (for instace, retries with different options --- see Stage retries) simultaneously. That´s become possible if a different log filename suffix is used with each job. If INDEP_LOGS is set, i.e. not empty (the default) then random suffixes are used.
- INDEP_LOGS: Controls if random LOG_SUF values should be used for each stage run. The flag is set by default (a non empty value).
- BACKUP_LOGS: Set to a non-empty value to disable independent logs and enable making backups of the stage log file on each next stage run (including stage retries). Setting BACKUP_LOGS to a non-empty value prevents from running multiple jobs for the same stage simultaneously.
Configuring Stage I
- SKIPLIST_DIR: Directory to write the list of unused packages for each processed source package. The default is skip.
- INCLIST_DIR: Directory to write the list of used packages for each processed source package. The default is inc.
- STAGE1_LOG: Log file for Stage I. The default is logs/stage1.log.
- STAGE1_LOGDIR: Directory for Stage I package build logs. The default is logs/stage1.logs.
- STAGE1_STATUS: Status file for Stage I. The default is stage1.status.
Configuring Stage II
- TAR_DIR: Directory to output TAR packages to. The default is pkgs.
- STAGE2_LOG: Log file for Stage II. The default is logs/stage2.log.
- STAGE2_LOGDIR: Directory for Stage II package build logs. The default is logs/stage2.logs.
- STAGE2_STATUS: Status file for Stage II. The default is stage2.status.
- EXCEPTIONS: A file with the list of exception paths for srpm-cleanup(1) (-x|--exceptions). The default is exceptions.list. The list is also used with Stage IV.
Configuring Stage III
- SRPM_DIR: Directory to output SRPM packages to. The default is out.
- STAGE3_LOG: Log file for Stage III. The default is logs/stage3.log.
- STAGE3_LOGDIR: Directory for Stage III package build logs. The default is logs/stage3.logs.
- STAGE3_STATUS: Status file for Stage III. The default is stage3.status.
Configuring Stage IV
- RPM_DIR: Directory to output the resulting RPM packages to. The default is rpms.
- STAGE4_LOG: Log file for Stage IV. The default is logs/stage4.log.
- STAGE4_LOGDIR: Directory for Stage IV package build logs. The default is logs/stage4.logs.
- STAGE4_STATUS: Status file for Stage IV. The default is stage4.status.
- TOOLERANCE: SRPM cleanup verification toolerance, %. The default is 0%.
If EXCEPTIONS (see above) is defined, the name of the file is passed to hsh-separate-sources(1) with -x|--exceptions).
Configuring Stage V
- REPO_DIR: Path to the reference package repository (on the local host).
- BIN_LIST: Path to the bin.list file in the reference repository on the local host. The default is $(REPO_DIR)/files/list/bin.list.
- DISTTAG_INDEX: The name of the dist-tag index file. The dist-tag index depends on the BIN_LIST and is updated automatically. The default is disttag.index.
- DISTTAG_OPTS: Options to pass to hsh-separate-sources in order to enable dist-tags. The default is --disttag-index="$(DISTTAG_INDEX)".
- REBUILD_OPTS: Additional options to pass to hsh-separate-sources on Stage V. For example, the --with-pre and --with-post options. There is no default value for this option.
- REBUILD_V_DIR: Directory to write the verified, cleaned-up RPM packages to. The default is rebuild.v.
- STAGE5_V_LOG: Log file for Stage V/1. The default is logs/stage5.v.log.
- STAGE5_V_LOGDIR: Directory for Stage V/1 package build logs. The default is logs/stage5.v.logs.
- STAGE5_V_STATUS: Status file for Stage V/1. The default is stage5.v.status.
- STAGE5_V_EXCLUDE_LIST: Name of the file with the list of packages to exclude from Stage V/1. The listed packages are included in Stage V/2 even if they sucessfully passed Stage IV. The default is exclude.list.
- REBUILD_O_DIR: Directory to write the RPM packages resulted from rebuilding of the original SRPM packages, typically --- the packages that failed on Stage IV. The default is rebuild.o.
- STAGE5_O_LOG: Log file for Stage V/2. The default is logs/stage5.o.log.
- STAGE5_O_LOGDIR: Directory for Stage V/2 package build logs. The default is logs/stage5.o.logs.
- STAGE5_O_STATUS: Status file for Stage V/2. The default is stage5.o.status.
Runtime options
- OPTS: Any command line options to pass to a tool corresponding to the stage.
- FOR_ARCHES: Run the stage (I, IV-V) on the hosts of the specified architectures only. The architectures can be listed separated by spaces or commas.
- PKGS: List of packages to rebuild (stageN-retry-pkgs targets only).
SEE ALSO
hsh-separate-sources(1), hasher(1), gear(1), hsh(1).
COPYRIGHT
Copyright (C) 2020 BaseALT /basealt.ru/. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AUTHOR
- Anton V. Boyarshinov boyarsh@altlinux.org
- Michael Shigorin mike@altlinux.org
- Paul Wolneykien manowar@altlinux.org
REPORTING BUGS
Report bugs to https://bugzilla.altlinux.org/.
| May 2021 |
