Skip to content

Commit fa1bb40

Browse files
committed
Adjusted package_module and paths for termux platform
Packages promises only possibly supported back to 3.15.1 due to need for interpreter attribute on package_module body and no earlier version available for termux. Paths added to support the interpreter path for packages. Also several convenience paths added both for termux and generic unix: - paths.tmp_path, paths.bin_path, paths.var_path, paths.etc_path Ticket: CFE-3288 Changelog: Title
1 parent 6b55f14 commit fa1bb40

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

lib/packages.cf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,20 @@ bundle common package_module_knowledge
3232
windows::
3333
"platform_default" string => "msiexec";
3434
@endif
35+
36+
termux::
37+
"platform_default" string => "apt_get";
3538
}
3639

3740
body package_module apt_get
3841
{
3942
query_installed_ifelapsed => "$(def.package_module_query_installed_ifelapsed)";
4043
query_updates_ifelapsed => "$(def.package_module_query_updates_ifelapsed)";
4144
#default_options => {};
45+
@if minimum_version(3.12.2)
46+
termux::
47+
interpreter => "$(paths.bin_path)/python";
48+
@endif
4249
}
4350

4451
body package_module zypper

lib/paths.cf

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Paths bundle (used by other bodies)
22

33
bundle common paths
4-
# @brief Defines an array `path` with common paths to standard binaries,
5-
# and classes for defined and existing paths.
4+
# @brief Defines an array `path` with common paths to standard binaries and
5+
# directories as well as classes for defined and existing paths.
66
#
77
# If the current platform knows that binary XYZ should be present,
88
# `_stdlib_has_path_XYZ` is defined. Furthermore, if XYZ is actually present
@@ -25,6 +25,22 @@ bundle common paths
2525
# comment => "Alternate array reference style";
2626
# }
2727
# ```
28+
#
29+
# Additionally several path entries are present to aid in policy sharing between
30+
# unix systems and Android Termux environments.
31+
#
32+
# **Example:**
33+
#
34+
# ```cf3
35+
# bundle agent track_sshd_config
36+
# {
37+
# files:
38+
# "$(paths.etc_path)/sshd/sshd_config"
39+
# changes => detect_all_change;
40+
# }
41+
# ```
42+
#
43+
# In case of termux, `paths.etc_path` will be `/data/data/com.termux/files/usr/etc`.
2844
{
2945
vars:
3046

@@ -570,6 +586,32 @@ bundle common paths
570586

571587
"path[shadow]" string => "/etc/security/passwd";
572588

589+
termux::
590+
"path[tar]" string => "/usr/bin/tar";
591+
"path[true]" string => "/usr/bin/true";
592+
"path[false]" string => "/usr/bin/false";
593+
"path[cat]" string => "/usr/bin/cat";
594+
"path[sysctl]" string => "/usr/bin/sysctl";
595+
"path[env]" string => "/usr/bin/env";
596+
597+
# now, mangle the values by prepending the TERMUX_PREFIX
598+
"files_path" string => "/data/data/com.termux/files";
599+
"etc_path" string => "$(files_path)/usr/etc";
600+
"tmp_path" string => "$(files_path)/usr/tmp";
601+
"bin_path" string => "$(files_path)/usr/bin";
602+
"var_path" string => "$(files_path)/usr/var";
603+
"tmp_paths" slist => getindices("path");
604+
"tmp_path[$(tmp_paths)]" string => "$(files_path)$(path[$(tmp_paths)])";
605+
"path[$(tmp_paths)]" string => "$(tmp_path[$(tmp_paths)])";
606+
607+
!(termux|windows)::
608+
# reasonable defaults for unix systems to allow for writing
609+
# more portable paths between termux and other systems
610+
"etc_path" string => "/etc";
611+
"tmp_path" string => "/tmp";
612+
"bin_path" string => "/bin";
613+
"var_path" string => "/var";
614+
573615
any::
574616

575617
"all_paths" slist => getindices("path");

promises.cf.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ body common control
107107
package_inventory => { $(package_module_knowledge.platform_default) };
108108
package_module => $(package_module_knowledge.platform_default);
109109
@endif
110+
termux::
111+
package_module => $(package_module_knowledge.platform_default);
110112

111113
any::
112114
ignore_missing_bundles => "$(def.control_common_ignore_missing_bundles)";

0 commit comments

Comments
 (0)