219 Commits
Author SHA1 Message Date
Reagan Lopez f5e79c0d86 builder: Experimental bundles
From format 27 onwards, Mixer will recognize bundles with "[Status] : Experimental"
as experimental bundles and mark their status flag as "e" in the Manifest.MoM.

i.e. These bundles will include an "e" in the 2nd position of the manifest flags,
as shown here:

Me.. 4b91c3122e7e32f1e3edb597c6f89ff32cfffd977afb5e5 10 some-bundle

Fixes #497

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-12-20 17:06:42 +01:00
Tudor Marcu d1b80ca810 Fix formatting error
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-12-03 14:23:14 -08:00
Otavio Pontes 8a35392a76 Introducing the Iterative to-Manifest
When creating manifests for a new build, also create to-Manifests
for each bundle that has changes in this version.

The goal on publishing to-Manifests is to reduce the download size
on updates, according to what was discussed on
clearlinux/swupd-client#498

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-11-30 13:27:39 -08:00
Reagan Lopez 8297cfc991 bundles: Add valid bundles and skip invalid ones
`bundle add` will now add valid bundles and skip only the invalid ones,
thereby fixing issue #489.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-27 10:13:37 -08:00
Matthew Johnson a8aec55670 builder: improve isLocalBundle checks based on testing
Some testcases showed these checks were incomplete and not handling
corner cases. Improve the logic of these checks to comply with the new
tests.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-11-21 14:07:37 -08:00
Matthew Johnson 1d90131733 builder: read upstream-bundles from mix workspace
Instead of requiring upstream bundles be read from a child directory
under where mixer is currently run read them from underneath the mixer
workspace (builder.Config.Mixer.VersionPath) the same way local-bundles
is handled.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-11-21 14:07:37 -08:00
Matthew Johnson 3cd63f99ed Start to add bundle_control unit tests
Start to add some unit tests for the bundle_control file. There is much
work to still be done as far as testing goes for these methods.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-11-21 14:07:37 -08:00
Reagan Lopez a9b249da53 bundles: Change bundle edit to bundle create
With the removal of the editor feature in `bundle edit`,
the term `edit` is not relevant anymore. Hence, changing it to `create`.
In order to prevent breakage of existing use-cases,
`edit` is aliased to `create`and `--suppress-editor` is made hidden and deprecated.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-20 10:54:38 -08:00
Reagan Lopez 7b6d4c22b5 bundles: Remove editor option for bundle edit
`bundle edit` will no longer open the editor. It will just create new bundles or copy existing bundles.
This command will locate the bundle by first looking in local-bundles, and then in upstream-bundles.
If the bundle is only found upstream, the bundle file will be copied to the local-bundles directory.
If the bundle is not found anywhere, a blank template will be created with the correct name.

This commit also fixes issue #448 and increases test coverage for `bundle validate`.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-20 10:54:38 -08:00
Tudor Marcu 116c3ada8c builder: Only check online to update upstreamver
Updating mixver should not require a network connection, nor reach out
to the server to find out any more information than is needed.

Fixes #282

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-16 15:05:38 -08:00
Matthew Johnson b11de6f6e0 builder: do not create delta-packs over format bumps
Fixes #482
Since clients can't update over format bump boundaries anyways do not
attempt to create delta-packs covering that jump.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-11-14 15:44:25 -08:00
Reagan Lopez b45ec080aa bundles: Build image with default ister template
This commit fulfills enhancement #58. When building an image without providing a template,
if the default image template is not present in the mix directory, mixer will do the following:
 - Copy image template from ister template "/usr/share/defaults/ister/release-image-config.json".
 - Update image template with the bundle list from "mixbundles" file.
   In case the "mixbundles" file is empty or not present, use ister template as is.
 - Inform the user about the above steps.
 - Continue the existing build process.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-13 15:26:39 -08:00
Tudor Marcu f3e378381b Break up code and re-order logic better
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 12:18:22 -08:00
Tudor Marcu a9af245c72 Update format bump process
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 12:18:22 -08:00
Tudor Marcu 361d6964c3 metadata: Add useful update functions for bump
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 12:18:22 -08:00
Patrick McCarty 2660c1bdc7 Remove /etc/dnf tree in full chroot
DNF creates two additional state directories in the full chroot if they
missing: /etc/dnf/ and /etc/dnf/modules.d.

Update the DNF state path slice so that the /etc/dnf directory tree is
removed from the full chroot after full chroot creation. This avoids
adding those two directories to Manifest.full.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2018-11-13 12:08:45 -08:00
Tudor Marcu a7aec78ccf Create DNF conf as part of mixer init
One may wish to add or edit repos before building any mixes, but the DNF
(.yum-mix.conf) is not available until build-bundles is run.

Fixes #452

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 09:55:25 -08:00
Tudor Marcu 38f62395f7 Add builder test for DNF conf check
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 09:55:25 -08:00
Reagan Lopez ade5ff736d bundles: Ignore name validation for bundle list
Currently, as part of `bundle list`, all the bundle names are read
and validated. As a result, `bundle list` fails if an invalid
bundle exists even if it is not added to the mix. This commit removes
bundle name validation as part of `bundle list` thereby fixing #461.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-12 11:45:57 -08:00
Rodrigo Chiossi 22f3572d28 init: Always set localrpms
The existence of local repo and local rpms folder has no impact if they
are not used in the mix. This patch removes the `--local-rpms` flag for
`mixer init` and make it always true. This way both folders are always
created and configured in builder.conf during init.

This patch also update the test cases for config convert to address this
change since.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-10-26 19:41:39 +02:00
Matthew Johnson ef52b7339e builder: break functions out into smaller files
Fixes #391
This patch greatly improves code readability by breaking up the goliath
builder.go into several new files containing similar functionality. Now
builder.go only contains the top-level build functions, constructors,
and types.

This patch contains no code functionality changes, the code is simply
moved around.

The builder.go file has been split out as follows:
* builder.go: contains all the top-level commands accessible via the
  commandline, such as BuildBundles, BuildUpdate, BuildImage etc. along
  with the type and const definitions.
* bundle_control.go: contains the mixer bundle * top-level commands and
  all the helpers that are used only by this functionality.
* bundle_validate.go: contains the bundle validation functions.
* bundles.go: added getClosestAncestorOwner to this file as it was the
  only file using this function (plus one reference in builder.go by the
  top-level BuildBundles).
* deltapacks.go: contains the internal function createDeltaPacks used by
  exported function in builder.go.
* repo_control.go: contains the dnf configuration controlling functions
  such as AddRepo, SetURLRepo, etc. Ideally this will eventually be
  moved to the config package.
* helpers.go: contains generic helper functions used by several files in
  the builder package.
* init.go: contains the functions to initialize the mix via mixer
  init.
* metadata.go: contains various metadata getters and setters for reading
  and updating versions, formats, and metadata files.
* update.go: contains the internal functions used by mixer build update.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-23 13:32:05 -07:00
Matthew Johnson f176d40179 builder: improve error message when listing repos
Fixes #323
Provide a better error message when listing repositories. The error now
gives a hint to the user to initialize their workspace before running
the command.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-23 12:53:27 -07:00
Rodrigo Chiossi 70a3f68c58 global: Use log package for Warnings and Errors
This patch changes how Warnings and Error messages are printed
throughout the code to use the `log` package instead of `fmt`. This
allows for finer control over what is printed and where it is printed
to.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-10-23 10:04:52 -07:00
Rodrigo Chiossi fdb8288298 builder: Handle write error on Stopwatch buffer
Use the logger interface to write stopwatch output. With this change,
any error that occurs while trying to write the output is handled
internally by the log module.

This patch also fix a bug where the line break was printed to STDOUT
instead of the stopwatch buffer.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-10-23 10:04:52 -07:00
Rodrigo Chiossi aa67fda737 build: Handle error on buffer write fail
When writing config files or buffers with configuration, mixer should
fail right away if an error occurs. This provides the user with better
errors since it prevents mixer from failing on config usage which
yields unrelated errors.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-10-23 10:04:52 -07:00
Caio Marcelo de Oliveira Filho b622ea9e4b builder: Use same commenting rules for package file and bundles
Make package file parsing ignore '#' and anything after that until the
end of the line.  Also trim spaces.  This makes the comment syntax the
same as bundle files.

At this point, one could consider trying to merge both parsing
functions, but given how simple the rules for this one are, kept them
separate.  We can revisit this later.
2018-10-08 16:46:17 -07:00
Rodrigo Chiossi 505c1012eb Revert "bundles:Update os-release file with mix info (#113)"
This reverts commit 302f03a70e.
2018-10-01 10:13:41 -07:00
Rodrigo Chiossi f697373abd builder: Fix URL build for base URL with subpath
When building the upstream URL, if the b.UpstreamURL was set do a url
with a subpath included, the subpath was being discarded by
URL.ResolveReference(). In order to preserve the subpath in the base,
the provided subpath must be manually added to the base URL object.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-21 23:15:55 +02:00
Reagan Lopez 302f03a70e bundles:Update os-release file with mix info (#113)
For a clear linux mix, the os-release file will be updated as follows:
- NAME="Clear Linux Mix"
  Eventually this value should be read from user input when #424 is implemented.
- ID=<based on above NAME field>
  E.g. ID=clear-linux-mix
- VERSION="<mix-ver> (<upstream-ver>)"
  E.g. VERSION="10 (24750)"
- PRETTY_NAME="<NAME> <mix-ver> (<upstream-ver)"
  E.g. PRETTY_NAME="Clear Linux Mix 10 (24750)"
- VERSION_ID=<mix-ver>
  E.g. VERSION_ID=10
- BUILD_ID=<upstream-ver>
  E.g. BUILD_ID=24750
- MIX_UPSTREAM_URL="<upstream-url>"
  This is a new field in os-release.
  E.g. MIX_UPSTREAM_URL="https://download.clearlinux.org"
2018-09-08 00:31:31 +02:00
Rodrigo Chiossi 41f60493bc bundles: Remove redundant parsing of config file.
All the values inside buildBundlesConfig are already parsed and
available in the code through builder.Config, so there is no need to
parse them again from the config file.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-08 00:10:23 +02:00
Rodrigo Chiossi bdb3a51794 bundles: Use --bundle-workers for manifest gen
When generating the manifest for bundles, use the user defined
--bundle-workers to determine the number of goroutines to use instead of
spawning one goroutine per bundle.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-08-31 14:36:06 -07:00
Tudor Marcu e61ff4e4bc Fix global --offline usage
When --offline is passed, any command executed should not reach over the
network. This introduces a tricky scenario when it is passed to a build
command with --native=false (default), because the command in the
container will be run with --offline, but the native mixer binary will
reach over the network to pull/update docker containers before executing
in them. This patch also makes that process offline only, attempting to
use a cached docker image so that it can run offline fully, but exits if
none exist.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-31 14:35:37 -07:00
Rodrigo Chiossi 0c9f0e3dd8 bundles: Enforce UTF-8 when running dnf
In some situations dnf may try to combine files from different
encodings. If the command is not running is a UTF-8 locale, this
combination will be missing a new line, causing and error.

An example of this occurrence is the command `dnf repoquery --quiet -l
systemd ca-certs-static ...` which combines a file list from systemd and
ca-certs-static

This patch enforces UTF-8 locale on every dnf execution.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-08-30 00:32:25 -07:00
Rodrigo Chiossi 07b3a3c182 builder: Improve download upstream error message
The error when mixer failed to download the upstream version was too
confusing since there were many layers of wrapped errors.
This patch removes the excessive wrapping and suggests a missing proxy
configuration to the user in case this error occurs.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-08-30 00:32:11 -07:00
Rodrigo Chiossi e78ab36e09 builder: No default bundles for offline init
When running 'mixer init' with the --offline flag, there is no upstream
to fetch the default bundles from, so the mix should be initialized
without the default bundles.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-08-30 00:31:45 -07:00
Matthew Johnson 3b812f7764 bundles: remove unneeded map assignment dance
We were assigning a map to a map to assign it to a string slice. Instead
just assign the map keys to the string slice directly.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-08-23 16:05:06 -07:00
Matthew Johnson 91434ca5fd bundles: Fix race condition on map.Range
When ranging over the syncmap to add packages to a bundle we were
mistakenly ranging over the entire set of bundles and adding all bundle
packages to the same bundle (nondeterministically, since we were doing
concurrent writes to a syncmap). In reality we just need to range over
the repoPkgMap itself and not load it from the syncmap at all. Do this
operation before even storing it.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-08-23 16:05:06 -07:00
Tudor Marcu 26fe8cec93 Force runc runtime in docker
The default runtime in upstream Clear will be set to the kata runtime,
which does not support host networking. This is needed for mixer, so we
must force --runtime=runc during all docker runs.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-21 02:01:54 -07:00
Matthew Johnson 3f03e34bb4 bundles: fix data race in building bundles
Two issues, first is resolved by renaming the error variable so a
goroutine isn't sharing err from outer scope with all other goroutines.

The second issue is resolved by using a sync.Map to safely read and
write to a map via the Range function.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-08-16 12:29:46 -07:00
Alex Jaramillo 03dc57ba32 Using ldflags for mixer version string
This change moves the setting of mixer version string from source code
to a variable defined during compilation. This approach is preferable
because:

1- builder.go does not need to change just to change version though
   functionally is the same.
2- simplifies logic in Makefile, no need to retrieve value from source.
2018-08-15 14:50:07 -07:00
Tudor Marcu 9d39305586 Release v5.1.0
This release adds more customizability of the DNF conf through the mixer
command line, adds a --clean option and does not wipe the outputdir by default
when re-running a 'build' command for the same build number, switches to zstd
compression for delta packs, and adds misc fixes to internal code structure.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-12 13:28:17 -07:00
Tudor Marcu d2e466446c Add excludepkgs option to repo command
This features may help users guarantee correctness of bundles built by mixer in
lieu of some shortcomings with dnf where dnf produces an unexpected dependency
solution. This mainly happens when a user is intending to fully substitute
a package from upstream's repo with one from their own. If anything is wrong
with the substitution, a feature like this would expose the issue early on.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-09 16:50:26 -07:00
Tudor Marcu 9024eb61fd Don't wipe output dirs on build bundles
By default, build bundles removes image/ver and www/ver, so that builds
of the same number start with a clean slate. There are specific use cases
where this is not desirable, and the statedir already has a version folder
populated/mounted which shouldn't be wiped. This allows mixer to write
the full chroot into an actual mounted file system for example that is
attached to update/image/VER/full.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-09 16:09:54 -07:00
Tudor Marcu 6be6db5f2c Fix divide by zero when no previous manifests
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-09 15:25:56 -07:00
Tudor Marcu 4b2e640ddc 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:57:39 -07:00
Rodrigo Chiossi 99eed0a84c docker: Pull image before running
If the docker image for a given format is updated, users with cached
version of the image may keep running in the older version.
This patch makes sure mixer tries to pull an updated version before
running. If the pull fails, mixer will print a warning instead of
failing to allow users with cached images to keep building offline.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-07-31 10:26:24 -07:00
Rodrigo Chiossi f403a7f200 docker: Fail on missing image name
If DOCKER_IMAGE_PATH is not set, the docker command will be malformed
and the user will receive a cryptic message.
This patch makes sure mixer fails early and provides the user an
informative error.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-07-31 10:26:24 -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