54 Commits

Author SHA1 Message Date
Patrick McCarty e78ef77e06 Release v3.2.1
This release fixes a sorting issue with bundle manifests: they should be
version sorted, not filename sorted.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.2.1
2016-04-05 23:51:22 -07:00
Patrick McCarty a329cc93a9 Fix sorting issue with bundle manifests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 23:50:42 -07:00
Patrick McCarty bd002877c1 Release v3.2.0
This release adds support for a bundle includes feature, which allows
bundles that "include" other bundles to depend on each other. This
change reduces duplication of files in manifests and improves build
times for larger bundle sets that contain many includes.

The two other functional changes are:

- The --format option to swupd_create_update is now mandatory.
- The value passed to --format must now be a positive integer.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.2.0
2016-04-05 21:44:00 -07:00
Patrick McCarty cb2706fb72 Move removal of old deleted files to a new function
Since removing of all of the matching deleted files between a build with
an older manifest format and current needs to happen *after*
match_manifests() finishes accounting for new and deleted entries in the
manifests, simply move the logic into a separate function to be called
after match_manifests().

Because one or more file deletions should trigger a fresh bundle manifest
creation, account for the return value of this new function in addition
to the result of manifest pruning and whether any bundle includes were
changed. Since "os-core" is treated specially, and it's expected to
contain changed files for every build, only the non-"os-core" bundle
manifests need the trigger.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 21:03:23 -07:00
Patrick McCarty 383ab112db Properly initialize format for new manifests
For the new full manifest and new bundle manifests, the format member
was not being initialized.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 16:29:29 -07:00
Patrick McCarty af7767a768 Add required -F option to basic_creator.sh
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 19:01:54 -07:00
Patrick McCarty b954d924f4 Update functional test suite for recent changes
For swupd_create_update, the required -F option needed to be added for
several tests, and the option parsing order changed.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 18:57:22 -07:00
Patrick McCarty e0049de3dc Fix remaining issues with handling the format number
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 18:48:42 -07:00
Patrick McCarty 2a9af990d6 Fix error in the previous rebase
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 14:23:05 -07:00
Patrick McCarty 90c976fdaf Require the -F option for swupd_create_update
To decrease chances of specifying an incorrect format number, since the
default is a hardcoded value "3", always require the user to pass the -F
option to swupd_create_update.

In the future, it would be nice to read the default value from a config
file, with the -F option overriding the value.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 14:18:15 -07:00
Tim Pepper 3b43313c9e Compare current format versus prior format in manifest match
To better support a workflow for incrementing the format on the command
line, it's useful to have the format be an integer instead of a string.
When reading a manifest (ie: old manifest) we can read that into struct
manifest.  Then when building a new manifest we can compare against the
prior manifest's format.  If the format incremented, we can prune files
previously marked as deleted in the old manifest so they no longer
appear in the new manifest.

This is beneficial because a file that has a version number in its name
will repeatedly be deleted and replaced by a new similar file.  Over
time this leads to manifests getting bigger and bigger because they
retain the entire history of all file names which ever existed, even if
a huge number of them are and have been for a long time marked as
deleted.

Signed-off-by: Tim Pepper <timothy.c.pepper@linux.intel.com>
2016-04-04 14:18:10 -07:00
William Douglas 3d8b81fbcd Fix missing closing comment 2016-03-31 18:50:42 +00:00
William Douglas 9b05b06a9b Fix manifests not detecting include changes
When deciding if a new manifest should be generated for a new version,
the included manifests were not being used to detect a manifest
change. This caused manifests that had new includes: lines in the new
version to not be generated resulting in files from the included
manifest to be missed when adding/updating that bundle.

The fix was to compare includes: lines from the current and previous
manifest versions for differences and generate new manifests when that
was the case. In order to compare manifests duplicate includes: lines
are not allowed and previously os-core could be added multiple times to
a manifest because it was always added. This change also added detection
for os-core before automatically adding it to a bundle.
2016-03-31 18:45:33 +00:00
Patrick McCarty 1cd3cdb96f Update gitignore 2016-03-30 13:08:48 -07:00
William Douglas 9c920d65e8 Don't bump versions for deleted files
In Manifest.full, previously a file being deleted from a bundle caused
the version of the file in Manifest.full to increase incorrectly.
2016-03-29 20:06:57 +00:00
William Douglas 825dc6c75f Add functional tests to validate includes work
Check that os-core is subtracked correctly and that $bundle-includes
files are correctly subtracked as well. Also include testing for new
bundles being subtracked.
2016-03-24 21:17:56 +00:00
William Douglas 4fb32c570f Replace explicit os-core subtraction
Now that much of the includes plumbing present on the output/subtract
side, make sure all non os-core manifests explicitly include os-core,
and then use the new extra semantics of subtract_manifests() to subtract
all included bundles, not just os-core.
2016-03-24 21:17:56 +00:00
William Douglas 79e8a12b75 Populate the manifest->includes list
Using the $bundle-includes files for building submanifests from
directories and previous manifest files includes: sections, create the
manifest->includes list as the names of submanifests included in the
submanifest being instantiated.

This needs to then be processed into a list of pointers to the other
submanifests themselves once all other manifests have been
instantiated before use with functions that operate on the includes list
(subtract_manifest and write_manifest for now)..
2016-03-24 21:17:56 +00:00
William Douglas 9b8b1d5359 Make the subtract_manifests function include-aware
When subtracting a manifest from another, all the included manifests
also will need to be subtracted from the original. To do this build up a
unique list of all manifests included (directly or indirectly) from the
manifest being subtracted from.

With that in place, this gives an opportunity to provide the
functionality of subtracting all included manifests from the main
manifest by calling subtract_manifests(A, A);
2016-03-24 21:17:56 +00:00
William Douglas df7b2adc9d Print included bundles in the manifest header
If a bundle includes one or more other bundles, print out one or more
includes: lines as part of the header of the manifest file.

There will be as many includes: lines as included bundles (including
being omitted if a bundle does not include other bundles).
2016-03-24 21:17:56 +00:00
William Douglas 0dcad76694 Add field for expressing included bundles 2016-03-24 21:17:56 +00:00
William Douglas 24ef47f40c Fixups for clang-format v3.8.0 2016-03-24 21:17:56 +00:00
Patrick McCarty 0a41a7e2d5 basic creator: remove unneeded pushd/popd
Since full paths are used everywhere in this script, the pushd/popd
sequence is not needed.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-24 09:38:40 -07:00
Patrick McCarty 51c0bf2007 Release v3.1.2
This release enables logs for the three installed binaries and optimizes
swupd_make_pack performance by preferring to hardlink files to the pack
staging area whenever possible.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.1.2
2016-03-22 17:21:48 -07:00
Patrick McCarty f27d0cf03a Capture logs for every binary
To capture all information that is logged, change init_log() to make
every log file name unique, and add a call to swupd_make_fullfiles to
enable logging.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-22 17:04:17 -07:00
Arjan van de Ven 08fb540678 Speed up pack creation
A big chunk of time during pack creation is spent in untar'ing of
fullfiles tar files.  However, we also (most likely) have this exact
same content already in the image/ directory.

This patch makes the pack creator skip the untar if its possible to link
the file directly, and falls back to the existing behavior if the link
fails

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-22 13:04:45 -07:00
Patrick McCarty 2355295023 Release v3.1.1
This release fixes a bug in manifest subtraction logic that may result
in "partial" subtraction of one manifest from another. The fix now
ensures that a manifest can be fully subtracted.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.1.1
2016-03-18 11:33:21 -07:00
Patrick McCarty 1aed8c3d4d Fix manifest subtraction logic
In subtract_manifests(), if the two files under consideration have the
same filename but should not be subtracted, a file is skipped in the m2
manifest because there is no "continue" statement at the end of the
first "if" block.

This results in potentially many files not getting subtracted when they
ought to be.

To clarify the logic, avoid using "continue", since it is not needed.
Convert to using one "if" block instead.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-17 23:44:53 -07:00
Patrick McCarty fa124fb19e Release v3.1.0
This release adds support for bsdtar (compile-time option), enables
parallel building of delta packs with pack_maker.sh, adds an initial
functional test suite, and addresses a few bugs:

- Makes parallel pack generation more robust when building packs for
  multiple versions simultaneously.

- Fixes basic_creator.sh to work properly on first run.

- Removes an unneeded -a option passed to tar, and fixes tar argument
  ordering (files always after options).

- Makes hash calculation always account for xattrs, since swupd-client
  unconditionally accounts for them.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.1.0
2016-03-17 12:48:56 -07:00
Patrick McCarty 3d4e172c22 Update the gitignore
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-17 12:33:25 -07:00
Patrick McCarty 115a7f444e Add missing free() for a memory allocation
Even though swupd_make_pack will exit immediately in the event this
error occurs, calling free() here will be needed if the error handling
ever changes (e.g. returning from the function instead of exiting).

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-17 12:24:44 -07:00
Patrick McCarty 5ba47aa150 test: add basic checks to ensure packs have been created
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-17 12:22:33 -07:00
Patrick McCarty 4e6fb28d0a Improve parallel pack generation
Because pack generation is a time-consuming task, running this task in
parallel is preferable.

However, if we are generating two or more packs with the same "from"
version at the same time, the multiple jobs will use the same pack
staging directory, leading to corruption.

My solution for now is to use a staging dir with a name derived from
both "from" and "to" versions so that there are no collisions.

A long-term fix will be to implement some kind of locking mechanism to
prevent *identical* packs from being generated simultaneously, but for
now, using more unique staging directories will improve the situation.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-17 11:58:49 -07:00
Dmitry Rozhkov d6153973fe Add compatibility with libarchive's bsdtar command
Since GNU tar fails to extract files with xattrs preserved when
Integrity Measurement Architecture (IMA) is enabled some vendors
may choose to install libarchive-based tar (bsdtar) on their embedded
devices, so the swupd server needs to be able to create archives
in its format.

This patch adds one compile-time options --enable-bsdtar that is used
to enable/disable GNU tar specific options. Also it harmonizes
the command strings to be compatible with both GNU tar and bsdtar.
Particularly it
- changes --exclude pattern from '%s'/* to more explicit '%s/?*' because
  bsdtar's pattern matching is greedier than in tar: it uses tcsh's
  globbing where '*' can be anything including the null string and the
  original pattern would include the directory itself;
- OS file names are escaped with leading ./ to avoid collisions with
  file names starting with @ which has special meaning in bsdtar.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2016-03-09 13:13:02 +02:00
Patrick McCarty 5acb4c394c test: set latest.version to new value in the latest test
The latest.version file should generally be updated after the most
recent build completes, so bump it to 10 after the build completes for
version 10 in this test.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-08 22:37:56 -08:00
Patrick McCarty 6ba28bc7a9 Add a functional test that creates delta packs
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-08 22:23:59 -08:00
Patrick McCarty e653bdd50a Add initial functional test suite
The test suite uses BATS to emit TAP and the Automake TAP driver to
consume the output.

Most of the tests are basic, and full-run.bats creates a minimal update
using autogenerated chroot content.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-08 21:28:15 -08:00
Patrick McCarty 1cf0b2b316 Validate argument counts immediately after option parsing
Similar to how swupd_create_update handles argc/argv, swupd_make_pack
and swupd_make_fullfiles should validate the argument count before
checking for root privileges, etc.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-08 20:00:28 -08:00
Dmitry Rozhkov 71e2abe1af Always use xattrs when calculating file hashes
Currently swupd-client includes xattrs to hash sums of all files.
Therefore in order to avoid relaxing security and to prevent
`swupd verify` from reporting hash mismatches for updated files
it's better to include xattrs to hashes for all files.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2016-03-08 14:00:31 -08:00
Patrick McCarty 3044d8c51b Initial run of clang-format
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-03 08:39:11 -08:00
Patrick McCarty eef6afe2f1 Prepare for running clang-format
Some of the existing comments cause clang-format to reformat them
strangely, so modify them to something more expected by the tool.

Also, the tool may decide to "join" several lines of concatenated string
literals if a line begins with a macro string literal. That's not
wanted, so fix up that case too.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-03 08:39:11 -08:00
Patrick McCarty 71ced644d7 Add clang-format style file
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-03 08:39:11 -08:00
Patrick McCarty 1b4f0a7a3b Correctly set formatstaging/latest on first run
On first run, the formatstaging/latest does not exist, so make sure we
create it and initialize it properly.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 15:43:58 -08:00
Patrick McCarty d3004e6a9e Fix a shell syntax error
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 15:43:28 -08:00
Patrick McCarty 101c91c681 Read latest.version after creating groups.ini
The mk_groups_ini.sh script instantiates the latest.version file on
first run, so make sure we read contents after that point.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 15:42:12 -08:00
Patrick McCarty afa886e6a8 Fix error reporting for incorrect minversion
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 15:13:13 -08:00
Patrick McCarty 8911378049 Substitute correct values for installed server.ini
In case the user overrides UPDATEDIR in the environment, make sure the
installed server.ini reflects the overridden value.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 08:28:55 -08:00
Patrick McCarty f2330266b8 Build packs in parallel in pack_maker.sh
The necessary waits needed for the backgrounded processes is already
implemented, so simply throw swupd_make_pack processes into the
background for faster build times.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 08:20:09 -08:00
Patrick McCarty 27271d3d2b Use --statedir in the builder scripts
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 08:11:07 -08:00
Patrick McCarty 26892177e6 Align variable default values in builder scripts
Also, make some of the variables overridable in the environment.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-03-02 08:09:07 -08:00