730 Commits
Author SHA1 Message Date
Otavio Pontes 5bb4ef2337 swupd.bash: Make swupd.bash POSIX compliant
Bash autocomplete scripts should be POSIX compliant, so fixing that and
adding a test to validate this.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-19 13:47:49 -07:00
Castulo Martinez 8e4c017365 Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
Otavio Pontes d5d3c599d2 Revert "Moving downloaded manifests to their own directory"
This reverts commit 336fee7a9d.
2020-05-15 08:18:37 -07:00
Otavio Pontes 24ecf6c913 delta: Improve message on delta errors
Print a more useful error when we fail to locate a file to apply a
delta. Add a suggestion for the user to run `swupd repair` and make
it clear that the problem is in their system and not in the update
content.

Fixes #1425

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 13:41:59 -07:00
Castulo Martinez 336fee7a9d Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -07:00
Otavio Pontes 5ff46653cf actions: Create another job to check for API changes
Create another github job to check if the API has been changed in this
PR, so it will be easier to notice that a broken test is just an API
broken test

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 10:45:46 -07:00
Otavio Pontes 7263b2d774 verify: Don't apply heuristic to os-install
Don't run heuristics for os-install or repair --quick.
On os-install we want all files to be always installed. On repair --quick
we don't process any do_not_update files

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-13 08:24:37 -07:00
Otavio Pontes e1fd274599 Fixing multiple unsigned to signed int conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 9fd1632ef0 int: Add functions to safely convert signed ints to unsigned
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 5f67a46354 string: Add function to convert from string to unsigned ints
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 07fb739c10 test: Add test to make sure we won't forget '\n' on log messages
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:09 -07:00
Otavio Pontes 6613fc5ffa heuristics: Add test to validate heuristics
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Castulo Martinez bca38243d8 3rd-party: add bundle-remove --orphans flag
Implementing the --orphans option to remove bundles no longer required
by tracked bundles from 3rd-party repositories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Castulo Martinez 4d0a6d29a1 Implement bundle-remove --orphans flag
This commit implements the --orphan flag for bundle-remove which can be
used to remove bundles that are no longer required by tracked bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Otavio Pontes 8d7a7dad6e Organizing src/ directories in categories
src/
    src/3rd-party/ # Everything that is 3rd-party related
    src/cmds/ # All sub-commands from swupd (except 3rd-party ones)
    src/lib/ # Modules that implement functions not dependent on swupd
               behavior (i.e. system interations, logging)
    src/swupd_lib/ # Modules that implement functions dependent on swupd
                     behavior (i.e. hash calculation, signature verification,
                     manifest/bundle handlers)
2020-05-07 14:31:27 -07:00
Otavio Pontes fc1f874c89 macros: Create wrapper for malloc and calloc functions
Use always calloc to allocate memory and abort on errors

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-06 09:54:24 -07:00
Otavio Pontes 076aeff0d0 target_root: Use run_commmand to execute tar|tar command
Porting code to better way on interacting with system commands using the
run_command function. As run_command don't support multi-thread for
performance reasons, we are now using a file instead of a pipe. As tar|tar
is now a fallback, this won't have any performance impacts on any case
where with no problems and errors.

Fixes #640 and #671

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 12:22:48 -07:00
Otavio Pontes 04eacb16be verifytime: Making verifytime completely independent again
We have added more dependencies in verifytime, but this was harder to
keep as it looks like, so making it completely independent from swupd
libs.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 12:14:54 -07:00
Castulo Martinez 0b47050848 3rd-party: add --orphans flag for bundle-list
Implementing the --orphans flag for 3rd-party bundle-list.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Castulo Martinez 4cd51ca5d8 Add --orphans flag to bundle-list
Adding the --orphans flag to bundle-list which shows those bundles that
are installed ut no longer required by any tracked bundle.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Otavio Pontes d29865f8a9 swupd.bash: Fixing tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 09:09:53 -07:00
Otavio Pontes 3f87d09f2b Updating copyright headers of files changed on 2020
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-01 14:00:11 -07:00
Castulo Martinez 86ef6bfde5 Testlib: Fixing functions that use a test ID
Instead of relying on all tests of the same group to exist in the same
directory, testlib should assume those tests could be scattered across
multiple directories.

Closes #1485

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-01 13:02:21 -07:00
Castulo Martinez 67dd98a5f1 Test: Use global_setup for bundle-list tests
Use global_setup in all bundle-list tests so we can only generate the
test environment once and use it for multiple tests. The one exception
is if we need to modify the env for a specific test.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-30 14:01:16 -07:00
Otavio Pontes d2c053cdb3 test: Create test to validate if we can repair files that have type change
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 12:26:29 -07:00
Otavio Pontes 4436d33e43 target_root: Handle invalid directory or missing directory the same way
We don't need to handle directory missing or invalid differently, because
the staging function removes it if necessary, so making the if simple.

Fix #1509

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 12:26:29 -07:00
Otavio Pontes ce0943982a shellcheck: Error SC2119 doesn't apply to our use cases
Ignoring error SC2119 because they are false positives and I don't see cases
where that would return anything useful for us.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 08:50:48 -07:00
Otavio Pontes a3c1f97c57 shellcheck: Unify shellcheck script
Make sure shellcheck and shellcheck bats are using the same configuration to
run shellcheck

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 08:50:48 -07:00
Otavio Pontes 203b9e35ca macros: Create a wrapper for free()
On several points on swupd we need to free a pointer and then set it to
NULL. This is made in some areas using the free_and_clear_pointer(). But
most places free_and_clear_pointer() is used, this is not really necessary.

On the other hand it's hard to make sure that we are really setting to NULL
every pointer that we need, so we're adding a more conservative approach on
setting every pointer to NULL after free using a wrapper.

The greatest advantage of this wrapper over free_and_clear_pointer() is that
it's not type dependent and we don't need to call it with a pointer of a pointer,
so calls look more to calls to a standard free.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-29 10:20:50 -07:00
Otavio Pontes e15ee0a6d6 sys: Always prefer to use basename and dirname from sys.c
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-29 10:20:50 -07:00
Castulo Martinez 766be95913 Test: show_target shellcheck warning
The show_target function shows a warning that is not applicable so this
commit ignores that warning wherever show_target is used.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-29 09:04:13 -07:00
Castulo Martinez b58e6c20ca Fail to be compliant if --quiet tests change
We are aiming to provide a stable --quiet output, so forcing "make
compliant" to fail if there are changes in the test/functional/api
tests, which cover these scenarios will prevent us from unadvertedly
changing those tests.

Closes #1501

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 14:19:57 -07:00
Castulo Martinez e57b9e6948 Testlib: adding help with description for all funcs
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 8a6eb85efe Testlib: function to print help menus of commands
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 201950445a Reporting if a file was fixed or not with --quiet
When using --quiet, there was no way of knowing if a file had been
successfully repaired or not. This commit fixes that.

Closes #1504

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 09:13:45 -07:00
Castulo Martinez 8b9a2e8510 API: Do not validate error messages in API tests
The tests in test/functional/api are going to validate the --quiet
output is rarely changed, therefore only expected output should be
validated and not warnings or error messages.

Closes #1502

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-27 16:04:05 -07:00
Otavio Pontes 9a8d5a09e3 target_root: Reorganize function verify_fix_path()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-27 14:50:22 -07:00
Otavio Pontes 6346f75477 sys: sys_path_join was wrong for string "//"
When sys_path_join("//") was used, the result was "" instead of "/"

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-27 13:59:07 -07:00
Castulo Martinez 8ab83f8167 3rd-party: using "repository" for headers
Headers are printed at the beginning of the output for every repository
in operations that run in multipl repos. This header was using the word
"repo" but we are trying to use the whole "repository" word every time
we printed it to the user. This commit changes that.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 17:12:17 -07:00
Castulo Martinez 6766748b42 Check extra files even if no tracked files
When running a diagnose/repair, swupd creates a list of the files to be
verified, this list contains normally all the files from the manifests
from bundles installed in the system. When the --file flag is used, this
list contains only the file specified in the flag or the directory and
files included in that directory if a directory is specified. If nothing
trakced was found using the given path, then swupd was considering
nothing else needed to be done and was exiting. This commit changes this
behavior so if there are no tracked files, we still look for extra,
untracked files before exiting.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 09:32:28 -07:00
Castulo Martinez 5e3164523d Testlib: function to add os-core-update to an env
For some tests is useful to have a minimal version of the os-core-update
bundle since some system files are tracked there.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 09:32:28 -07:00
Castulo Martinez be0fa3c69f Bug_fix: don't consider partial match with --file
When running a diagnose/repair using the --file flag, swupd was
considering partial matches, for example "--file /ba" would match
"/bar", "/baz", "/bat", etc. This commit changes it so it only matches
full matches. Foe example: "/bar" will only match "/bar",
"/bar/file", but won't match "/barbar".

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 09:32:28 -07:00
Castulo Martinez 77b499cd0b Adding a --3rd-party flag to update
This commit adds a flag that can be used to update content from
3rd-party repositories after updating the regular content if
successfull.

Closes #1473

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 08:14:45 -07:00
Otavio Pontes cac56264d3 compliant: Start using clang-format-10 to check for style problems
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-23 12:07:51 -07:00
Otavio Pontes 73a6d0055c strings: Create safer wrapper to strcmp()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-23 08:55:45 -07:00
Otavio Pontes bbd7da491d strings: renaming functions to have a str_ prefix
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-23 08:55:45 -07:00
Castulo Martinez a7ed2cbce0 Bug_fix: In closing steps in multi-repo ops
Multi-repo operations can run in one or multiple repos, so that needs to
be taken in consideration when opening and closing progress steps.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-22 10:46:59 -07:00
Castulo Martinez 1a13a29e14 Updating list to run clr-boot-manager
This commit adds the following files to trigger the execution of
clr-boot-manager:
- /usr/bin/clr-boot-manager
- /usr/share/syslinux/ldlinux.c32

Closes #1415

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-22 09:37:59 -07:00
Otavio Pontes b7d9de6ae5 tests: Adding more attribute changes to test
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-21 11:33:41 -07:00
Castulo Martinez 1e3cb68979 API: output for mirror
This commit provides a minimal output to be displayed when the --quiet
flag is used for these commands:

- swupd mirror

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-20 10:52:14 -07:00