626 Commits
Author SHA1 Message Date
Tudor Marcu 97cbbfd480 Release v5.3.0
This release includes the following updates:
- Revert bundles:Update os-release file with mix info
- Add minversion header to MoM
    When the minVersion argument is provided to createManifests
    populate a header in the MoM with this version. If no flag is
    provided and the previous MoM had a minversion set populate the
    new MoM with this version.

    Write the minversion to the manifest header when the minversion
    != 0.  Since we only set minversion for the MoM the minversion
    will only be written to the MoM and not to bundle manifests.
- Fix warnings message in checkNotContains() for helpers_test
- Update comment parsing for package files to ignore # and trim
  white space

Critical Updates:
----------------
* New format bump process script (afb.sh) and test added to describe
the new format bump flow that should be followed. It outlines a much
simpler way to do bumps, and does not require moving back and forth
between formats or tooling.

* Do not update deletes over minversions
    Minversions should not update deleted files to the minversion as
    this may cause swupd to attempt to delete content twice. This
    exacerbates issues where a directory (/usr/local/bin) was
    mistakenly deleted in a version because it was mistakenly added
    earlier. Updating the delete to the minversion then causes the
    directory to be deleted off the client system again.

* Enable backwards compatible build update
    This commit enables mixer to write different manifest formats
    based on the configured format value. When introducing a
    breaking change to a manifest it will be registered with
    the format it requires. Existing template is registered to
    everything through format25 to remain compatible with Clear
    Linux OS format. Everything above the current format gets the
    new template, in this case with the minversion added to the MoM.

    This means that format bumps do not need two different versions
    of mixer installed since it will always know how to build the
    correct format based on the configured value.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.3.0
2018-10-15 11:26:07 -07:00
Matthew Johnson e861b81812 swupd: add copyright headers to all source files
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-11 15:46:00 -07:00
Matthew Johnson 47438addf3 AFB: Add bat test for simplified format bump approach
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 11:40:40 -07:00
Matthew Johnson 76c5afe0f4 AFB: remove references to using old versions of mixer
Going forward mixer will remain backwards compatible with its older
formats.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 11:40:40 -07:00
Matthew Johnson f127a74bf5 AFB: add header describing format bumps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 11:40:40 -07:00
Matthew Johnson 5469f13322 AFB: Add afb.sh script to outline format bump steps
This script is intended as a reference and architecture document for a
new format bump flow. This format bump flow is much simpler than the
original/current flow which requires jumping back and forth between the
+20 and +10 builds to create the updates.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 11:40:40 -07:00
Matthew Johnson a32934f042 swupd: do not update delete versions over minversions
Fixes #455
Minversions should not update deleted files to the minversion as this
may cause swupd to attempt to delete content twice. This exacerbates
issues where a directory (/usr/local/bin) was mistakenly deleted in a
version because it was mistakenly added earlier. Updating the delete to
the minversion then causes the directory to be deleted off the client
system again.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 10:42:41 -07:00
Matthew Johnson 14af7f89e7 swupd: test that minversions do not change delete versions
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-09 10:42:41 -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
Matthew Johnson ca530f863b swupd: add format25to26 test
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-05 11:23:12 -07:00
Matthew Johnson 21ad8c2644 swupd: enable backwards-compatible build update
This commit enables mixer to write different manifest formats based on
the configured format value. When introducing a breaking change to a
manifest it will be registered with the format it requires. Existing
template is registered to everything through format25 to remain
compatible with Clear Linux OS format. Everything above the current
format gets the new template, in this case with the minversion added to
the MoM.

This means that format bumps do not need two different versions of mixer
installed since it will always know how to build the correct format
based on the configured value.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-05 11:23:12 -07:00
Matthew Johnson 032702b2c8 swupd: add tests for minversion header in the MoM
The minversion header should only show up in the MoM and should carry
forward to the next version's MoM if the --min-version flag is not
supplied on the commandline. The minversion header should not be
displayed if the minversion is 0.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-05 11:23:12 -07:00
Matthew Johnson e7bd030a48 swupd: add minversion header to MoM
An upcoming improvement to swupd-client requires the minversion header
to exist in the MoM in order to determine the strategy with which to
update files in the update.

When the minVersion argument is provided to createManifests populate a
header in the MoM with this version. If no flag is provided and the
previous MoM had a minversion set populate the new MoM with this
version.

Write the minversion to the manifest header when the minversion != 0.
Since we only set minversion for the MoM the minversion will only be
written to the MoM and not to bundle manifests.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-05 11:23:12 -07:00
Otavio Pontes dd49c0cf53 helpers_test: Fix checkNotContains warning message
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-05 10:56:51 -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
Tudor Marcu 0cfd9ca596 Release v5.2.2
This release fixes a couple bugs that block the format bump process:

1) Don't add deleted bundles to MoM
When a bundle gets deleted, its entry still exists in the previous
MoM but it shouldn't exist in the new MoM. Since the deleted bundle
will not exist in the bundle list anymore, it must be also verified
to determined if an missing entry should be propagated to the new MoM.

2) Skip format bump check if running offline.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.2.2
2018-09-27 20:25:11 -07:00
Rodrigo Chiossi 6ac0e79e51 cmd: Skip format bump check if running offline
Format bump check requires fetching format for current upstream which
cannot be done if there is no network available. If `--offline` flag is
provided, this check must be skipped.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-28 01:49:29 +02:00
Rodrigo Chiossi 5115c71bc4 swupd: Don't add deleted bundles to MoM
When a bundle gets deleted, its entry still exists in the previous MoM
but it shouldn't exist in the new MoM. Since the deleted bundle will not
exist in the bundle list anymore, it must be also verified to determined
if an missing entry should be propagated to the new MoM.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-28 01:49:16 +02:00
Rodrigo Chiossi 48e7608937 Release v5.2.1
Bug fixes:

- Do not user container for `build image`.
The build image command cannot run in a container because there are no
loopback devices to mount in a container environment. This change
forces mixer to run in native mode when build image is called.

- Revert download timeout to default values.
The timeout for downloads was causing mixer to fail in slow networks
because it was too short. This fix reverts the value back to default.

- Properly handle upstream URL with subpath.
Mixer were unable to properly handle downloads when the upstream URL
included subpaths since the subpath was discarded. This fix changes the
internal algorithm to preserve the subpath.

- Enforce --Offline flag.
During mixer initialization, some commands relied on a separate check to
determine if an online check was required. This check ignored the value
of the --offline check, causing some scenarios where mixer would try to
connect even when the flag was set. This fix gives priority to the flag
to make sure it is always respected when set.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
v5.2.1
2018-09-21 14:35:44 -07:00
Rodrigo Chiossi 6e40a3ca1a cmd: Respect --offline flag for network check
There are a couple mixer commands that don't require network and thus
skip any network check. This behavior is also intended when the
--offline flag is used, but the flag is never checked in that scenario.

This patch unifies builder.Offline (which is set by --offline) and
networkCheck variable to make sure the network check is also skipped if
--offline flag is used.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-21 23:17:14 +02: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
Rodrigo Chiossi 20cacb9757 Revert "helpers: Reduce download timeout"
This reverts commit 9cf854d8d6.

The reduction to the timeout has caused failures for users on slow
networks, so this must be reverted to the default values.

The reduction to the timeout was added to improve user experience when
connection failed due to a proxy error. It would take mixer too long to
fail and the error message didn't indicate what the problem could be.

The error is now properly indicated, so even if it takes a while for the
error to occur the first time, the user should be able to identify the
problem on the spot.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-20 21:35:39 +02:00
Tudor Marcu 1f7b1d0520 Do not use container for build image
The build image command cannot run in a container because there are no
loopback devices to mount in a container environment. Force running with
native if build image is called.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-09-18 17:32:53 +02:00
Rodrigo Chiossi 51c3bdb79d Release v5.2.0
- Update os-release file with mix info
- Add automatic conversion to mix config
- Remove redundant parsing of config

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
v5.2.0
2018-09-07 15:35:17 -07: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 d62f007c25 battest: Add tests for config conversions
These automated tests will check if conversion between multiple older
versions to the current version is working properly.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-08 00:11:44 +02:00
Rodrigo Chiossi 09973d7752 config: Remove old config
With the automatic conversion on load time, mixer ill always use the new
config format. Even if the mix is initialized with the legacy config, it
will be converted right away. As such, there is no need to allow the
creation of legacy configs anymore nor to check if it is being used.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-08 00:11:44 +02:00
Rodrigo Chiossi 7f1e3f33a3 config: Add automatic conversion
This patch introduces automatic conversion of config files to the latest
format. This will seamlessly transition all users to the latest format
without the need for manually converting the config with the `mixer
config convert` command.

This patch also introduces the config_conver.go file, which centralizes
all conversion operations and also the parsing for the legacy config in
order to keep config.go clean and focused on current config features.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-09-08 00:11:44 +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
Tudor Marcu eaf869155c Release v5.1.4
This release fixes many bugs in the tooling:
- Fix double parsing of the config file
- Do not add default bundles when 'init' called with offline
- Reduce download timeout to 10 seconds instead of 30 on file download
- Improve download upstream error message
- Enforce UTF-8 locale when running DNF commands in mixer
- Ignore possible %ghost files in RPMs
- Fix global --offline usage to completely block all outbound network
  checks on all commands, even when running in container mode
- Fix error in concurrent manifest creation code to properly exit on
  first error hit
- Use --bundle-workers for manifest generation like other commands
- Fix to use passed in minversion for +10 format bump build

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.1.4
2018-08-31 17:24:10 -07:00
Tudor Marcu ef862760f1 Don't minver the +10 by default
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-08-31 14:36:40 -07: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
Rodrigo Chiossi 6ca4342f6b manifests: Exit on error
When there is an error in one of the worker goroutines, the error is
read but before it is returned, the variable is reused inside the
following for loop to check the error of addFilesFromChroot(). Since we
always have a "full" bundle, it is always overwritten.

Another issue is that the err variable was shared among the goroutines
and was set directly instead of through the error channel. This would
allow one routine to overwrite the error from another.

Lastly, there is a problem with the loop that feeds bundleChan with
data. The second select statement calls 'break' when an error is found,
but 'break' will exit the 'select' block, not the 'for' loop. In order to
stop the loop, we move the break to an if statement that checks for a
condition set on error. This change ensures that the worker goroutines
stop once an error is found.

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
Auke Kok d29cc44340 Ignore possible %ghost files in RPM files.
Due to the way that we use repoquery, we are returned files that
may be %ghost files in RPMs. These files may be missing and this
is legal and compliant.

While Clear Linux OS does not use %ghost files in any of the RPMs
created, there is nothing wrong with permitting other vendor RPM
files that may list %ghost files, and mixer should just ignore
these files.

This change does just that: If repoquery returns files that are
not existing in the fullimage, prints a warning and continues with
out dropping the manifest for that bundle.
2018-08-30 13:02:53 -07:00
Auke Kok 5d42cfdb14 gofmt -s this file. 2018-08-30 11:06:38 -07:00
Auke Kok cf271dd7b0 Missing argument to print. 2018-08-30 11:06:38 -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 9cf854d8d6 helpers: Reduce download timeout
Instead of the default 30 seconds timeout, use 10 seconds when trying to
download files.

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
Rodrigo Chiossi 2034c8dc82 cmd: Fix double config parsing
When running any 'mixer config' sub-command, the config will be parsed
in the command itself, so there is no need to pre-parse them in the pre
execution. Those commands also don't rely on network nor cause any
format conflict, so it is safe to skip all the remaining checks like it
is done for the 'init' command.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-08-30 00:31:31 -07:00
Tudor Marcu 5d9055ebab Release v5.1.3
This release fixes a race condition when ranging over a syncmap to
add packages to a bundle.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.1.3
2018-08-23 23:55:20 -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 04c713623a Release v5.1.2
This release fixes mixer to force the runc runtime on docker runs, which
supports host networking.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.1.2
2018-08-21 02:06:38 -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
Tudor Marcu 5225ad0da8 Release v5.1.1
This release fixes a data race which cause concurrent map read/writes
when resolving packages and bundles. Versioning is also moved into the
Makefile so it does not have to be updated in the source code anymore,
and added at compile time.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
v5.1.1
2018-08-16 23:33:13 -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