6 Commits

Author SHA1 Message Date
Scott Little
5003bb100d Extend GITREVCOUNT to inputs other than SRC_DIR and PKG_BASE
Changes in brief:

1) TIS_PATCH_VER will now accept new automatic variables
'OTHER_GITREVCOUNT' and 'SRC_GITREVCOUNT'.

2) New BASE_SRCREV variables are supported, 'SRC_BASE_SRCREV' and
'BASE_SRCREV_FOR_PATH'

3) OPT_DEP_LIST_FOR_BUILD_TYPE[<build-type>] joins OPT_DEP_LIST as
a way to list files that affect the build, but are not included
in the assembled src.rpm.

4) Some code relating to interpreting build_srpm.data files,
and producing a list of files that affect the build, are relocated
to 'srpm-util' and restructured for greater utility.

The details:

TIS_PATCH_VER=<expression>
                     # An integer, or one of the supported
                     # variables listed below, or the sum of
                     # variables and integers.
                     #  e.g.
                     #  TIS_PATCH_VER=PKG_GITREVCOUNT+SRC_GITREVCOUNT+5

   PKG_GITREVCOUNT   # Count git revisions relative to PKG_BASE.
                     # Optionally only count from PKG_BASE_SRCREV

   SRC_GITREVCOUNT   # Count git revisions relative to SRC_DIR.
                     # Optionally only count from SRC_BASE_SRCREV

   GITREVCOUNT       # Deprecated, please use SRC_GITREVCOUNT instead.
                     # Count git revisions relative to SRC_DIR.
                     # Optionally only count from TIS_BASE_SRCREV

   OTHER_GITREVCOUNT # count git revisions from all sources excluding
                     # PKG_BASE and SRC_DIR
                     # Optionally only count from
                     # BASE_SRCREV_FOR_PATH[<path>]

PKG_BASE_SRCREV=<sha>   # Limit PKG_GITREVCOUNT revision count to
                        # commits since <sha>

SRC_BASE_SRCREV=<sha>   # Limit SRC_GITREVCOUNT revision count to
                        # commits since <sha>

TIS_BASE_SRCREV=<sha>   # Deprecated, please use SRC_BASE_SRCREV
                        # instead
                        # Limit GITREVCOUNT revision count to commits
                        # since <sha>

BASE_SRCREV_FOR_PATH[<path>]=[<sha>|OTHER_PKG_BASE_SRCREV]
                        # Limit OTHER_GITREVCOUNT revision count for
                        # commits under <path> to commits since <sha>.
                        # If <path> is the PKG_BASE of another package
                        # (not the current package) then the keyword
                        # 'OTHER_PKG_BASE_SRCREV' can be used to extract
                        # the 'PKG_BASE_SRCREV' value of the other
                        # package.
                        #
                        # The <path> can reference variables like
                        # $STX_BASE and $GIT_BASE.

OPT_DEP_LIST=<path-list>  # Add a space separated list of paths that
                          # don't contribute to the content of a src.rpm
                          # but do contribute to triggering a rebuild,
                          # and possibly modifying the TIS_PATCH_VER via
                          # use of OTHER_GITREVCOUNT.

OPT_DEP_LIST_FOR_BUILD_TYPE[<build-type>]=<path-list>
                          # For a specific build type only, add a space
                          # separated list of paths that don't
                          # contribute to the content of src.rpm,
                          # but do contribute to triggering a
                          # rebuild, and possibly modifying the
                          # TIS_PATCH_VER via use of OTHER_GITREVCOUNT.

Story: 2006166
Task: 39765
Change-Id: I9e7d409d4eefdb41a7083db1b801d531c443b678
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-06-10 17:48:26 -04:00
Scott Little
9b77e2e1b3 Build avoidance fixes
1) Build avoidance fails on a clean workspace because directory
$MY_WORKSPACE/tmp doesn't exist when mktemp needs to
create a forth subdir under that path.

Add a 'mkdir -p $MY_WORKSPACE/tmp' to ensure it exists
prior to mktemp.

2) Failed to rebuild kmods after a kernel change and
building with build-avoidance enabled.  The problem was
a missing dependency cache that would have listed
the kmods as having dependencies on the kernel.
Reusing kmods from a prior build in conjunction with
a rebuilt kernel results int load with unusable kmods
due to a key mismatch.

Add the dependancy-cache to the list of artifacts to
syncronize as part of build avoidance.  A primed
dependency cache will allow build-pkgs to determine
that kmods must be rebuilt when the kernel has changed.

3) Make sure $MY_WORKSPACE/$BUILD_TYPE/repo
symlink exists after a build avoidance build.
If no packages require a rebuild, it was missing.

4) Fix an error message that was puzzling while debugging
the above issues.

Closes-Bug: 1864110
Change-Id: Ia912b2e3e110efbe69004d7978109ebb089d684b
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-02-21 16:07:05 -05:00
Scott Little
b2286535c9 Update to build tools to support Build layering.
1: Building rpms now produces an rpm.lst file.  This file serves to
list all rpms produced by the build.  A seperate rpm.lst file
is producede for each build type (std, rt, installer). The file is
co-resident with the matching repodata directory.

The rpm.lst files will need to be published by cengn for each layer build.

The download tools in stx-tools will need to find the rpm.lst files
of lower layer builds, and use it to direct the download of rpms
from the lower layer.

2: Building rpms now produces an image.inc file.  This file serves
to list all rpms that the layer recommends be built into an iso.
The file is stored under the $MY_WORKSPACE/<build-type> subdirectory,
although it has identical content for any build-type.

The image.inc file will need to be published by cengn for each layer
build.

The download tools in stx-tools will need to download the per-layer
image.inc files to the $MY_REPO/cgcs-centos-repo/layer_image_inc/
sub-directory, renaming the file in some layer specific way.

The build-iso tool will process any *.inc files found under
$MY_REPO/cgcs-centos-repo/layer_image_inc/ ,
adding those rpms to the iso.

3) Add a mechanism for layer specific mock.cfg prototypes.
This will allow special handling of the real-time (aka 'rt'),
repositories for layer builds that need to do a 'rt' build.

4) Add support for a $MY_REPO/cgcs-centos-repo/rt subdirectory,
a place to build a repo of real-time rpms originating from
lower layer builds.

The download tools in stx-tools will need to populate the new
rt repos.

As of this writing, non-rt rpms remain in $MY_REPO/cgcs-centos-repo/.
i.e. there is not a new $MY_REPO/cgcs-centos-repo/std/ directory.

5) Some changes to make us more flexible about where we find
realease and bsp files.

6) Found that kernel mudules were not reliably building against
the hearnel-headers of our modified kernel.  Found that adding '--update'
to our mock build command was not working.  Does mock expect '--update'
to only be used independently of a build command?  It does work when
used in that manner, so that's what we will do.

7) The build-pkgs, build-srpms, build-rpms family of commands
can take a layer argument and/or will read the LAYER environment
variable.  Current the only use of this variable is to modify
the build-info.  It does NOT limit the compile to packages
for a specific layer.

Story: 2006166
Task: 37094

Depends-On: https://review.opendev.org/698756
Depends-On: https://review.opendev.org/700819
Change-Id: I817e08a19cdabe08b3fcc47dee63a36b461c13c0
Co-Authored-by: Martin Chen <haochuan.z.chen@intel.com>
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-02-07 16:36:40 -05:00
Jason McKenna
331e07254f Handle multiple optional dependancies and copy list
RPMs which are built from a build_srpm.data file may have optional
COPY_LIST_TO_TAR and OPT_DEP_LIST items listed in the file.  These
variables are assumed to be single items by the md5sums_from_input_vars
function used by build-srpms during build-avoidance.

What this means is that listing multiple items are not currently
handled by build-srpms during build-avoidance.

This change handles each item in the variables independently.

Change-Id: I57494d23680b726eb8dca712444c45879897ca50
Signed-off-by: Jason McKenna <jason.mckenna@windriver.com>
Closes-Bug: 1800675
2018-11-02 14:48:05 +00:00
Scott Little
1aee4a42e6 Refusal to build libvirt src.rpm after CTRL-C
Problem:
An incremental build was interrupted by CTRL-C.
Libvirt was one of the packages interrupted mid build.
Subsequent incremental builds failed to rebuild libvirt.

The BUILD_NEEDED logic fails to trigger if the working
directory has been created, but is empty of src.rpms's.

Solution:
Add additional tests to ensure empty working directories
trigger a BUILD_NEEDED condition.

Closes-Bug: 1798191
Change-Id: I99e1fe76b016a5779d623d2ff91cc924b45a9338
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-10-18 10:17:09 -04:00
Scott Little
b20ac0164d Build Avoidance
Purpose:
   Reduce build times after a repo sync by pulling in pre-generated
srpms and rpms and other build products created by a local reference build.

Usage:
  repo sync
  generate-cgcs-centos-repo.sh ...
  populate_downloads.sh ...
  build-pkgs --build-avoidance [--build-avoidance-user <user> \
     --build-avoidance-host <addr> --build-avoidance-dir <dir>]

Reference builds:
- A server performs a regular (daily?), automated builds using
  existing methods. Call these the reference builds.

- The builds are timestamped, and preserved for some time. (weeks?)
  The MY_WORKSPACE directory for the build shall have a common root
  directory, and a leaf directory that is a UTC time stamp of format
  YYYYMMDDThhmmssZ.
  e.g.
  MY_WORKSPACE=/localdisk/loadbuild/jenkins/StarlingX/20180719T113021Z

  Alternative formats are possible by setting values in ...
  "$MY_REPO/local-build-data/build_avoidance_source"
  e.g.
  BUILD_AVOIDANCE_DATE_FORMAT="%Y-%m-%d"
  BUILD_AVOIDANCE_TIME_FORMAT="%H-%M-%S"
  BUILD_AVOIDANCE_DATE_TIME_DELIM="_"
  BUILD_AVOIDANCE_DATE_TIME_POSTFIX=""
  BUILD_AVOIDANCE_DATE_UTC=0

  Which results in YYYY-MM-DD_hh-mm-ss format using local time.
  The one property that the timestamp must have is that they
  are sortable, and that the reference build and the consumer of
  the reference builds agree on the format.

- A build CONTEXT is captured, consisting of the SHA of each and every
  git that contributed to the build.

- For each package built, a file shall capture he md5sums of all the
  source code inputs to the build of that package.

- All these build products are accessible locally (e.g. a regional
  office) via rsync (other protocols can be added later).  ssh
  is also required to run remote query commands on the reference build.

  Initial ground work to support a selection variable ....
  BUILD_AVOIDANCE_FILE_TRANSFER="my-transfer-protocol"
  in $MY_REPO/local-build-data/build_avoidance_source"
  has been created, but "rsync" is the only valid value at this time.

- Location of the reference build can be specified via command line, or
  defaults can be put in $MY_REPO/local-build-data/build_avoidance_source.
  The local-build-data directory is gitignored by stx-root and so can be
  customized for local needs.
  e.g.
  cat $MY_REPO/local-build-data/build_avoidance_source
  BUILD_AVOIDANCE_USR="jenkins"
  BUILD_AVOIDANCE_HOST="stx-build-server.myco.com"
  BUILD_AVOIDANCE_DIR="/localdisk/loadbuild/jenkins/StarlingX"

Notes:
- Build avoidance is only used if requested.
- Build avoidance does not necessarily use the latest reference build.
  It compares the git context of all available reference builds vs your
  own git context, and chooses the most recent for which you gits have
  all the conent.  i.e. all your gits will be same or newer than that
  used by the reference build.  This also meens that some packages might
  still need to be rebuilt after the download step.
- Normally build avoidance remembers the last download context and will only
  consider reference builds newer than the last download.   You can reset
  using 'build-pkgs --build-avoidance --clear' to erase the download history.
  When might this matter to me?  If you change to an old branch that
  hasn't been synced recently and want to build in that context.
- The primary assumtion of Build Avoidance is that it is faster to
  download packages than to build them.  This is typically true of a
  good LAN, but likely not true of a WAN. This is why we emphasize the
  local nature of your reference build server.

Also in this update:
- reworked context generation to be relative to 'dirname $MY_REPO'
- Moved md5sum calculation to a common file, and fixed case where
  symlinks where canonacalized to paths outside of $MY_REPO.
  We'll make an exception to canonacalization to keep paths
  relative to $MY_REPO.
- In future other functions could be moved to the common file.

Story: 2002835
Task: 22754
Change-Id: I757780190cc6063d0a2d3ad9d0a6020ab5169e99
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-09-17 16:41:31 -04:00