173 Commits
Author SHA1 Message Date
Tudor Marcu cb48ad864f Release v5.0.2
This release fixes several bugs dealing with running in a docker
container, and provides better warnings/error messages when the
environment and conf are not setup correctly.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-31 10:52:28 -07:00
Tudor Marcu 68274c4257 Release v5.0.1
This release fixes issues with setting up the new mixer.state file. The
file now correctly transfers over the FORMAT version from the builder.conf,
falling back to the system /usr/share/defaults/swupd/format, and only then
defaulting to "1".
Deletes now persist in manifests over minversions. The only time they should
be removed is when performing a format bump.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-26 10:51:45 -07:00
Tudor Marcu 66b2f6ff6d Release v5.0.0
This release introduces major changes to the way Mixer is called and
run. Previously, mixer gained support for automatically building format
bumps, but was disabled by default (with --native=true always turned
on). The flag forces mixer to run natively on the system, and not
perform format bump builds automatically. With this release, the default
becomes --native=false, meaning all mixer 'build' commands will run in a
docker container. Running in a container ensures the proper version of
the tooling is run for specific build versions, because one version of
tooling cannot build for 2 different formats.

Mixer will automatically pull the appoproriate container that can create
builds for a given format, so the format bump process can truly be
automated and correct. It will still use a container for regular,
non-format bump builds for consistency.

Note that aside from the initial docker pull,
creating a mix will not be any slower than running natively, and allows
users to build versions that require tooling outside of their
host system version.

Another significant change involves the configuration for Mixer. The
builder.conf is now updated to be a stable, relatively unchanging
config to describe your workspace. The stateful items (versions, format,
etc) are moved into a mixer.state file which holds ephemeral values that
are changed build-to-build. This keeps all stateless and stateful items
centralized and follows a single format (TOML). The new format is used
by default, but can be overridden by setting --new-config=false during
the init phase. Both configs are versioned so mixer can easily detect
format changes and config errors.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-23 14:40:13 -07:00
Rodrigo Chiossi d2f562dae6 config: Add mixer.state file
The mixer.state file holds the temporary values used or produced between
mixes or mixes steps. The format variable was the only transient
variable in builder.conf so it was moved to this new state file.
This file should hold all transient values. All the temporary files
should be centralized on this new state file.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-07-20 15:39:27 -07:00
Tudor Marcu 9a57b01b86 Release v4.7.0
This release enables parallel manifest creation in parts of swupd during
build update.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-20 13:14:11 -07:00
Matthew Johnson cf96713bd0 builder: parallelize manifest compression step
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-07-18 12:36:32 -07:00
Tudor Marcu e4d4d3ba86 Release v4.6.7
This release updates mixer to build slim packs across minversions, reducing the
pack download size for clients and saving space on our infrastructure. Mixer
also properly avoids making a network connection except for commands that
absolutely need it.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-06 16:10:20 -07:00
Tudor Marcu c0e7a72b76 Do not hit the network for some commands
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-07-06 16:03:51 -07:00
Tudor Marcu 6614ab1ab2 Release v4.6.6
This release includes fixes to place the <bundle>-extra-files into a persistent
location, which will automatically inject listed files into a mix, reducing
manual intervention by mixer users when building a mix with unconventional
or files that are not part of any bundle by default.  Bsdiff error output
is more standard and consistent, displaying the proper delta information to
make debugging failing cases easier.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-29 16:30:46 -07:00
Tudor Marcu e8e81162b4 Fix linter errors
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-29 16:28:41 -07:00
Tudor Marcu 76d67785e9 Remove source RPMs before creating the repo
Mixer will not work with source RPMs added and crash looking for files
that will not actually be provided. This patch removes them as it parses
the RPM list so only valid, usable RPMs get added to the repo.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-25 12:32:47 -07:00
Rodrigo Chiossi 8e9a01ec27 build: add skip-fullfiles and skip-packs option
This patch adds the --skip-fullfiles options for the 'build' subcommand
of mixer. This command will prevent fullfiles from being generated
during 'build update'. Likewise, the --skip-packs option prevents zero
packs form being generated.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-21 10:48:38 -07:00
Rodrigo Chiossi 2cbe74c869 builder: Refactor BuildUpdate API
BuildUpdate API has become too convoluted, to the point where some of
its parameters are not even used anymore. This patch reorganize the
function API and simplifies parameter passing to underlying functions.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-21 10:48:38 -07:00
Rodrigo Chiossi fc39e15d2c format: revert rebase errors
Apparently there was an error during rebase of the format bump patch
that brought back BuildConf variable which is not supposed to exist
anymore. This reverts it back to the proper state.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-19 17:30:14 -07:00
Rodrigo Chiossi 13753373c1 docker: ignore unexported config fields
When using reflection to iterate the config fields, trying to iterate on
unexported fields will cause mixer to crash. Also, when checking for
docker mounts, there is no need to check any of the unexported fields.

This patch fix this crash by skipping the search on unexported fields.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-19 17:30:14 -07:00
Rodrigo Chiossi ee438cd25b format: Treat missing LAST_VER as error
The only use case where a missing LAST_VER is a valid use case is when
checking if a bump is needed since the user might be running the build
for the first time. In all other cases, the caller expects a valid
version to be returned is error is nil. This caused mixer to print some
cryptic errors if those other callers were used on a new workspace.

This patch changes the default behavior to always return an error if
LAST_VER is missing and let the caller decide using os.IsNotExist() api
if the error should be propagated or not.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-19 17:30:14 -07:00
Rodrigo Chiossi 1f9717b4fc format: Use SaveConfig instead of SetProperty
The SetProperty API is used to search for the property withing config,
set it and save the config. In this code, the property is set directly
just a few lines above, so saving is already enough to propagate it to
the config file.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-06-19 17:30:14 -07:00
Tudor Marcu 14a25d3380 Release v4.6.5
This release sets a timeout for delta creation time to 1 minute, in an effort
to skip deltas which typically end up being too large to use for packs anyway.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-13 00:00:13 +00:00
Tudor Marcu 1759dd9b7b Release v4.6.4
This release sets a timeout for delta creation time to 1 minute, in an effort
to skip deltas which typically end up being too large to use for packs anyway.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-12 23:55:07 +00:00
Tudor Marcu 0020262f2b Set timeout on bsdiff delta creation
Set timeout to 1 minute for bsdiff. The majority of all delta creations
take significantly less than 1 minute to run, which signifies that bsdiff
is working on a delta that may be very large, or very difficult to diff. In
all the cases where bsdiff took multiple minutes to finish, the delta ended
up not being used because it was larger than the compressed fullfile. This
attempts to skip those cases and improve delta creation time.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-12 16:51:51 -07:00
Tudor Marcu 38bbbce8b3 Release v4.6.3
This release fixes mixer to not exit when upstreamurl is not found, and
to attempt to use the given format in the builder.conf. For some cases,
the mixer user may in fact be "upstream" so it does not make sense to check
upstream format compatibility.
A new tool is available called swupd-inspector, which contains various
commands that help read data of a swupd repository: download the fullfile for
a specific file, see the Manifest for a specific version, see the differences
between two versions.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-11 22:37:11 +00:00
Tudor Marcu cf2fdb6560 Fix bug for user who don't have upstreamurl file
This is the case for when an OSV *is upstream* and does not have a set
upstreamurl. There is nothing to download and figure out the format range
for since they set the bounds manually, so don't crash on this error unless
it is running in a container non-natively.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-11 12:36:50 -07:00
Tudor Marcu 1e57943733 Release v4.6.2
This release further parallelizes the delta creation code to do some
more complex breakup of tasks. Typically users create multiple versions
back of deltas. While each version ran massively parallel delta jobs,
each version itself ran one after another synchronously. This began to
cause problems when certain files took several minutes to complete,
because the next version could not start until the previous finished,
compounding the runtime by the number of versions back * long file.
Now, the code check if it can run a thread for each version, and then
splits up threads within those version pools so when the large file is
hit, all versions run at the same time, capping it to 1 long file run.

Signed-off-by: Tudor  Marcu <tudor.marcu@intel.com>
2018-06-08 22:58:41 +00:00
Tudor Marcu 93aebf0ef7 Parallelize version back for deltas
Run each version back for delta packs in its own thread, and divide the total
number of CPUs available and use that in each version thread.  There are
cases where only a few files remain to delta, and they take multiple
minutes to finish. Each version runs synchronously with many threads, so
at the end of a version we have to wait for the long delta to finish before
running through another. version This changes it so by the end of the run -
all the large/slow files are building at the same time, capping it to just
one long file run, vs long run * number of versions back.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-08 15:32:41 -07:00
Tudor Marcu 0563df5326 Loop through bumps and hide commands for now
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells cebb0b1a81 Misc bug fixes
Fix a number of AFB bugs:

- Previous build's upstream format was being incorrectly looked up,
resulting in upstream format boundary crossing detection failing.

- PreRun check was incorrectly skipping format build commands, resulting
in "stage for mix" being run twice.

- Only the UInt32 upstream version was being modified, resulting in the
second half of 'mixer build upstream-format' being run in the wrong
container.

- The wrong format was being printed out for 'mixer versions' if
crossing an upstream format boundary.

Refactor Cobra command PreRun

Simplified the PreRun logic that happens before every command. This also
fixes an issue where format bump build commands could be run with
--native=false, when they need to be run natively.

Fix AFB mixversion and LAST_VER setting

1) Changes how the format bump builds set mixversion so that it no
longer skips a version number in some situations.

2) Updates the update/image/LAST_VER file after the +10 build back
to the +20 build value, so mixer is ready to do the next mix.

Refactor file download code

This patch refactors and consolidates the different file download code
scattered throughout helper.go and builder.go.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells cce1e82b41 Create SERVER_STATE_DIR with uid/gid of parent
This patch changes the way SERVER_STATE_DIR is created if it does not
already exist, in order to facilitate mounting the directory inside the
Docker container.

By default, SERVER_STATE_DIR in 'builder.conf' is set to PWD +
"/update", a path that typically does not already exist and is created
automaticallly the first time mixer builds bundles. Historically, 'mixer
build bundles' was run as root; now it is run as root within a Docker
container. In either case, this "update" directory ends up owned by
root.

For security reasons, mixer will not mount to the container any directory
to which the caller does not have read/write permissions. This means that
on subsequent calls, mixer refuses to mount the "update" directory it just
created, as it is owned by root.

This patch resolves this for most users by creating the SERVER_STATE_DIR
with the uid/gid of its closest existant ancester. In the default case,
this is the uid/gid of the PWD. Users with existing mixes will need to
manually chown the SERVER_STATE_DIR to a uid/gid they have read/write
permission to.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Tudor Marcu 201110598b Fix order of format bump builds and bug fixes
This patch includes the following changes:

Reorder which version builds first to simplify

The +20 build can be built fully at the beginning all the way though,
removing the need to swap tooling to build the +10 (just so things are
built in chronological order). The +10 build is created with the -
possibly - old tooling only after, and reduces the amount of
back-and-forth swapping of tooling.

Fix misc errors with formats and version blocks

The right format number needs to be passed into both functions, and we
*must* ignore the fact that the version and format are lower than the
previous build in the format bump case. It reduces complexity and tool
changes by building the +20 version all the way through first.

Two top level commands now exist for running format bumps:
- build upstream-format This command builds the necessary builds to
			cross a mix over a format bump.
- build format-bump This command builds a bump for downstream users.

Fix docker mount path lookup

This patch fixes a bug with the way mixer determined which fields in
'builder.conf' were mountable paths.

Previously, mixer treated every field in [Builder] and [Mixer] as paths
on the filesystem (or paths to files whose parent directories needed to
be mounted). Introducing the "DOCKER_IMAGE_PATH" field broke this
approach.

This patch introduces a new "mount" tag on the config struct fields that
indicates whether a config field represents a mountable path. This has
several benefits:
1) It allows us to know definitively which fields we should look at.
2) It allows us to look at the entire 'builder.conf', not just the
[Builder] and [Mixer] sections.
3) It removes the restriction that paths in 'builder.conf' be absolute.
This absolute check was mostly a sloppy way of checking if a field was
in fact a path.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells 6c51a98564 Check access perms before mount, add unit tests
This patch adds an access check on each directory in the config file
before mounting it to the container. This prevents the user from
accidentally (or surreptitiously) granting the container access to
directories they shouldn't.

The config parsing for directory extraction code is also refactored to
provide better results and more accurate error messages.

This patch also adds unit tests for directory access checks, directory extraction,
and mount path list reduction.

For these tests to not fail inside the Docker container on Travis, they
need to not be run as root. This patch thus also creates a non-root user
(but with wheelnopw membership), and runs as this user instead.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells 5bb0f6c298 Move stageMixForBump(), add UnstageMixFromBump()
This step cannot occur for every format bump build as it previously did,
as it is only valid for format bump builds for crossing an upstream
format boundary. If you are simply bumping your own mix format,
independent of upstream, this should not occur.

Moved the call to CheckFormatBumpNeeded, as this is the only place that
definitively knows this step needs to occur.

Adds an "UnstageMixFromBump" command that resets the "upstreamversion"
file back to the contents found in "upstreamversion.bump", if it exists.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells ac22c9c95a Default to --native = true
This commit temporarily sets the default value for --native to true,
making running inside a container an opt-in behavior. This will make the
testing and transition to containerized mixer easier. Eventually this
switch will be flipped back to false, making containerized the default
running mode.

To run in container, append '--native=false' to your command.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Kevin C. Wells effd61323d Dockerize mixer.
This patch Dockerizes mixer build commands. A new '--native' flag is added
that, if passed, will run mixer on the host system the way it always has.
This defaults to false.

For build commands, if '--native' is false, mixer now pulls an image file
published by upstream that contains the core Clear Linux OS and mixer
toolchain for the version of Clear Linux defined in the upstreamversion file,
which mixer than uses to build a Docker image. Mixer then re-runs the original
mixer build command within a container of that Docker image.

This ensures that you are always using a version of the mixer toolchain
compatible with the upstream version off of which you are building. This is
required for building across format boundaries. Additionally, mixer now
checks if a build crosses format boundaries, and instructs you how to
first perform a format-bump build.

Mixer attempts to re-use already downloaded or built Docker images to
minimize the performance impact of running inside a container. This eliminates
the time spent on re-building the container image across subsequent
runs. Mixer uses the latest-released version for a given format, however,
so image content will become stale regularly.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-06-07 17:13:47 -07:00
Tudor Marcu d4ded4e349 Add format bump support
This adds support for detecting if a format bump is needed, and the
supplementary functions to perform one. All of the build steps are done
for the user, and just need to be called in the correct order to
generate the two builds.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-07 17:13:47 -07:00
Tudor Marcu 4389c54cd5 Release v4.6.1
This release includes fixes for mixin, notably enabling new config for all
executions instead of per cmd basis, and enables users to name the bundle
they want the package added to instead of defaulting to the repo name.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-07 00:59:35 +00:00
Tudor Marcu da41f3a244 Release v4.6.0
This release adds bundle information files under /usr/share/clear/allbundles
to allow clients to perform future bundle-info operations. Write with 'pretty'
indented JSON so it is grep-able and human-readable in the mean-time.  Users
will have to install the os-core-update-index bundle to get this functionality.

The delta pack creation code has been re-written and parallelized to
greatly improve performance. All deltas are now created in parallel
using the full manifests, and then the packs are created in parallel by
just using the pre-created deltas from the delta/ folder, instead of
doing all the processing per bundle.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-01 19:48:21 +00:00
Tudor Marcu 6412c094c6 Update comments and thread error return
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-01 11:37:11 -07:00
Tudor Marcu c1912451f5 Update variable names to be more apparent
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-01 11:37:11 -07:00
Tudor Marcu 9b52c63854 Parallelize pack creation
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-01 11:37:11 -07:00
Tudor Marcu 0bfea1be3d Parallelize delta creation
Build all of the deltas first using the full manifest, and then add them
to the packs instead of finding and creating deltas synchronously on a
per-bundle-basis.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-06-01 11:37:11 -07:00
Matthew Johnson 58cda49ada os-core-update-index: add bundle metadata files
Add bundle information files under /usr/share/clear/allbundles to allow
clients to perform future bundle-info operations. Write with 'pretty'
indented JSON so it is grep-able and human-readable in the mean-time.
Users will have to install the os-core-update-index bundle to get this
functionality.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-01 10:07:11 -07:00
Matthew Johnson 0d9f5ace84 Report repo name title not repo key name
List the repo title (which is not upper cased) instead of the key 'name'
in the section body. This is important because repo set-url and repo add
operates on the section title not the key name.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-29 13:33:47 -07:00
Rodrigo Chiossi 265301fb30 builder: move file download to helpers
Download a file is a generic operation. This patch moves this
functionality from builder to helpers to allow it to be reused
by other packages.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-05-29 13:33:08 -07:00
Rodrigo Chiossi 24b9666852 config: Let config handle filename
Instead of relying on external sources to keep track of the active
config file, store it as a private variable inside MixConfig.

This change prevents inconsistencies regarding filename and also
simplifies the code since the caller doesn't need to initialize the path
or know the filename if it was not the one that initialized that config
object.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-05-29 13:33:08 -07:00
Rodrigo Chiossi 682f827a34 builder: rename bundle name variable
Throughout the code `b` is used as Builder object variable. This patch
renames its use in createDeltaPacks() to avoid confusion.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-05-29 13:33:08 -07:00
Rodrigo Chiossi b06fa293bf config: Add new functionality to LoadDefaults
This patch adds a couple new features for LoadDefaults().

First, it introduces LoadDefaultsForPath(), which allows the default
values to be set base on a given path instead of always assuming $PWD.

It also removes the restriction that only allowed defaults to be set
when --new-config set was declared. Removing this restriction ensures
that there are always sane parameters available, even if none exists
in the config file.

Lastly, it moves the check for local RPMs to LoadDefaults from
CreateDefaultConfig(). This prevents GetWd() to be called twice and also
allows LOCAL_REPO_DIR and LOCAL_RPM_DIR to be set in the same call.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-05-29 13:33:08 -07:00
Rodrigo Chiossi 90c874af2e config: separate config into its own package
This patch moves config out of the builder package into its own package.
This change is required to reuse MixConfig inside swupd package. Builder
package includes Swupd package, so keeping config there would cause a
cyclic dependency.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-05-29 13:33:08 -07:00
Kevin C. Wells 32ef7422b8 Mixer init always add defaults, unless new flag
Previously 'mixer init' would add four default bundles to your
mixbundles list, unless it already existed. This resulted in confusing
behavior. Some users resorted to creating an empty mixbundles list
before running 'mixer init' in order to avoid these bundles. Others had
a mixbundles list already, but expected the bundles to be added anyway.

This patch changes the behavior to *always* add the four default
bundles, even if the mixbundles list already exists, unless a new
'--no-default-bundles' flag is passed. This does not affect the behavior
of '--all-local' or '--all-upstream'.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-05-29 12:40:37 -07:00
Tudor Marcu e0d0107e75 Release v4.5.3
This release fixes the check for changed includes, and fixes 'mixin' to
support local content properly.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-05-24 06:23:25 +00:00
Tudor Marcu 7e5442b293 Release v4.5.2
This release introduces a new mixer “config set” command to set properties
in the builder.conf, fixes for delta creation, mixin to read correct
upstream versions, and documentation for adding custom content from a build
root without building RPMs.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-05-18 19:07:36 +00:00
Kevin C. Wells 2cd5811ba9 Report config name for missing config values.
Previously, when a "required" config value was missing, the config
object's variable name was reported, rather than the name actually used
in the builder.conf file itself.

This resulted in the following output, for example:
ERROR: Missing required field in config file: ServerStateDir
rather than
ERROR: Missing required field in config file: SERVER_STATE_DIR

This patch falls back to the variable name if a config field does not
have a "toml" name defined.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-05-17 13:43:23 -07:00