Everything needed to build DivestOS, a more private and more secure aftermarket mobile operating system.
Go to file
steadfasterX 59d8f35761
make divest functions error aware
this commit adds (the currently non-existing) error handling when
using divest's functions and scripts.
all the magic here gets activated when `source ../../Scripts/init.sh`
gets executed which is already a mandatory step before starting any
of the divest functions.

when something fails during patching, resetting or building
each error will be catched + printed including an error code now.
last but not least the executed file and the line number causing that
failure will be shown, too.

as all divest functions get source'd and so not a single build
script gets executed all ERR's needs to be trapped to catch issues.
I am not aware of another way to handle that properly as sourcing
means we cannot track a script or smth while this approach here
just works.

Example for an error thrown in a function call:

> ERROR: $DOS_WORKSPACE_ROOT/Scripts/Common/Functions.sh -> verifyAllPlatformTags() ended with status >1< at line >49<

Final SUCCESS result message after using `patchWorkspace`:

> [FINAL RESULT] No error detected (please check the above output nevertheless!)

Final ERROR result message after using `patchWorkspace`:

> [FINAL RESULT] Serious error(s) found!!!
> Summary error code was: 126. Check & fix all error lines above

Some notes:

- when an error occurs the process continues until the end (like it is now)
  i.e. an error will not stop the current and following tasks
- when multiple errors occur the exit codes will be summed
- buildDevice: a (summed) end result gets printed (SUCCESS or ERROR) at the very end
- the trap used to catch any error will also be active for any command executed
  on the cli. that means: type "false" -> ENTER and you will get an error, too
  same for any script exectued after source init.sh
- when all goes well the trap will be resetted at the end but there are cases
  where this might not happen -> that is why `resetEnv` can be executed to
  reset the trap, i.e. all becomes as it was before sourcing init.sh
- `resetEnv` gets called automatically:
  - after a successful `patchWorkspace` run
  - whenever CTRL+C is used (during a running task or just on the cli)
  - a process get killed (SIGHUP, TERM)
- the whole implementation might not catch all errors though - it highly depends
  on how the function or the script/program called actually handles errors or better
  said: if they return a proper exit code on failures.
  For example some tools (like some git cmds) might print an error but don't return
  a non-zero exit code. This cannot be tracked other then with your eyes or these
  must be replaced by other methods returning a non-zero exit code on failures.

Signed-off-by: steadfasterX <steadfasterX@gmail.com>
2023-04-14 12:44:39 +00:00
Logs Updates, logging, and churn 2023-03-31 12:38:46 -04:00
Manifests More drops 2023-03-25 22:45:10 -04:00
Misc Fixes 2023-03-20 17:51:09 -04:00
Patches Updates, logging, and churn 2023-03-31 12:38:46 -04:00
PrebuiltApps@0022d96ba9 Drop devices working on 20.0 2023-03-25 17:04:25 -04:00
Scripts make divest functions error aware 2023-04-14 12:44:39 +00:00
.gitignore Update CVE patchers 2021-11-26 11:54:59 -05:00
.gitmodules Submodule updates 2019-03-20 22:43:38 -04:00
fix_permissions.sh Updates, logging, and churn 2023-03-31 12:38:46 -04:00
LICENSE Fix fix 2022-12-15 17:47:53 -05:00
LICENSE.Apache-2.0 Update license 2019-05-09 06:43:09 -04:00
LICENSE.GPL-3.0 Use clearer SPDX identifiers 2021-04-22 13:15:43 -04:00
LICENSE.Unsplash Minor changes 2019-09-05 04:23:28 -04:00
README.md Add a README 2022-07-28 19:21:31 -04:00
TODO Small tweaks 2021-12-31 21:39:04 -05:00

Banner

Please see the website for documentation