summaryrefslogtreecommitdiffstats
path: root/testing/cfengine/alpinelinux.patch
blob: 40c95aa412dcce34e0e3a90449442a4d7842cdcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
diff --git a/masterfiles/libraries/cfengine_stdlib.cf b/masterfiles/libraries/cfengine_stdlib.cf
index 13d554f..24529e8 100644
--- a/masterfiles/libraries/cfengine_stdlib.cf
+++ b/masterfiles/libraries/cfengine_stdlib.cf
@@ -2047,6 +2047,31 @@ package_update_command => "/usr/bin/pacman -S --noconfirm --noprogressbar --need
 
 ##
 
+body package_method alpinelinux
+{
+ package_changes => "individual";
+
+ package_list_command => "/sbin/apk info -v";
+
+ # Remember to escape special characters like |
+
+ package_list_name_regex    => "([^\s]+)-.*";
+ package_list_version_regex => "[^\s]+-([^\s]+).*";
+
+ package_name_regex    => "([^\s]+)-.*";
+ package_version_regex => "[^\s]+-([^\s]+).*";
+
+ package_installed_regex => ".*";
+
+ package_name_convention => "$(name)-$(version)";
+
+
+ package_add_command => "/sbin/apk add";
+ package_delete_command => "/sbin/apk del";
+}
+
+##
+
  # Single bundle for all the similar managers simplifies promises
 
 body package_method generic
@@ -2186,6 +2211,18 @@ archlinux::
  package_add_command => "/usr/bin/pacman -S --noconfirm --noprogressbar --needed";
  package_delete_command => "/usr/bin/pacman -Rs --noconfirm";
  package_update_command => "/usr/bin/pacman -S --noconfirm --noprogressbar --needed";
+
+alpinelinux::
+ package_changes => "individual";
+ package_list_command => "/sbin/apk info -v";
+ package_list_name_regex    => "([^\s]+)-.*";
+ package_list_version_regex => "[^\s]+-([^\s]+).*";
+ package_name_regex    => "([^\s]+)-.*";
+ package_version_regex => "[^\s]+-([^\s]+).*";
+ package_installed_regex => ".*";
+ package_name_convention => "$(name)-$(version)";
+ package_add_command => "/sbin/apk add";
+ package_delete_command => "/sbin/apk del";
 }
 
 ##
diff --git a/src/sysinfo.c b/src/sysinfo.c
index 557f449..56046ba 100644
--- a/src/sysinfo.c
+++ b/src/sysinfo.c
@@ -819,6 +819,12 @@ void OSClasses(void)
         SetFlavour("UnitedLinux");
     }
 
+    if (cfstat("/etc/alpine-release", &statbuf) != -1)
+    {
+        CfOut(cf_verbose, "", "This appears to be an AlpineLinux system.\n");
+        SetFlavour("alpinelinux");
+    }
+
     if (cfstat("/etc/gentoo-release", &statbuf) != -1)
     {
         CfOut(cf_verbose, "", "This appears to be a gentoo system.\n");