Skip to content

Commit e122384

Browse files
authored
Merge pull request #2762 from OSInside/add_alpine_support
Add support for Alpine
2 parents 1994c71 + 5018b58 commit e122384

File tree

16 files changed

+728
-10
lines changed

16 files changed

+728
-10
lines changed

build-tests.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ARGUMENT_LIST=(
2020
"test-dir:"
2121
"test-name:"
2222
"box-name:"
23+
"vm"
2324
)
2425

2526
function usage() {
@@ -30,6 +31,8 @@ function usage() {
3031
echo " some test name, e.g. test-image-disk"
3132
echo " --box-name <name>"
3233
echo " name of the box to use for the build, default: universal"
34+
echo " --vm"
35+
echo " build in a virtual machine instead of a container"
3336
}
3437

3538
if ! opts=$(getopt \
@@ -61,6 +64,11 @@ while [[ $# -gt 0 ]]; do
6164
shift 2
6265
;;
6366

67+
--vm)
68+
argVM=1
69+
shift
70+
;;
71+
6472
*)
6573
break
6674
;;
@@ -107,15 +115,18 @@ function create_build_commands() {
107115
build_command="kiwi-ng --debug"
108116
has_profiles=false
109117
repo_options=$(create_repo_list "${build_dir}")
118+
box_options="system boxbuild --box ${boxname}"
119+
if [ ! "${argVM}" = 1 ];then
120+
box_options="${box_options} --container"
121+
fi
110122
for profile in $(
111123
xmllint --xpath "//image/profiles/profile/@name" \
112124
"${image}/appliance.kiwi" 2>/dev/null | cut -f2 -d\"
113125
);do
114126
has_profiles=true
115127
target_dir="build_results/${base_image}/${profile}"
116128
build_command="${build_command} --profile ${profile}"
117-
build_command="${build_command} system boxbuild"
118-
build_command="${build_command} --box ${boxname} --container --"
129+
build_command="${build_command} ${box_options} --"
119130
build_command="${build_command} --description $image"
120131
build_command="${build_command} ${repo_options}"
121132
build_command="${build_command} --target-dir ${target_dir}"
@@ -126,8 +137,7 @@ function create_build_commands() {
126137
done
127138
if [ "${has_profiles}" = "false" ];then
128139
target_dir="build_results/${base_image}"
129-
build_command="${build_command} system boxbuild"
130-
build_command="${build_command} --box ${boxname} --container --"
140+
build_command="${build_command} ${box_options} --"
131141
build_command="${build_command} --description $image"
132142
build_command="${build_command} ${repo_options}"
133143
build_command="${build_command} --target-dir ${target_dir}"

build-tests/x86/alpine/.repos

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/,apk
2+
https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/,apk
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<image schemaversion="7.5" name="kiwi-test-image-disk">
4+
<description type="system">
5+
<author>Marcus Schaefer</author>
6+
<contact>[email protected]</contact>
7+
<specification>Alpine Appliance</specification>
8+
</description>
9+
<preferences>
10+
<version>3.21.0</version>
11+
<packagemanager>apk</packagemanager>
12+
</preferences>
13+
<preferences>
14+
<type image="oem" filesystem="ext4" kernelcmdline="console=ttyS0" firmware="efi" eficsm="false" format="qcow2">
15+
<oemconfig>
16+
<oem-resize>false</oem-resize>
17+
</oemconfig>
18+
<bootloader name="grub2" console="serial" timeout="10"/>
19+
</type>
20+
</preferences>
21+
<users>
22+
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root" groups="root"/>
23+
</users>
24+
<!-- first repository is also used for bootstrap -->
25+
<repository type="apk">
26+
<source path="https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/"/>
27+
</repository>
28+
<repository type="apk">
29+
<source path="https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/"/>
30+
</repository>
31+
<packages type="image">
32+
<package name="shadow"/>
33+
<package name="dracut"/>
34+
<package name="fts"/>
35+
<package name="linux-edge"/>
36+
<package name="linux-firmware"/>
37+
<package name="grub"/>
38+
<package name="grub-efi"/>
39+
</packages>
40+
<packages type="bootstrap">
41+
<package name="alpine-base"/>
42+
</packages>
43+
</image>

kiwi/defaults.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,17 @@ def get_bls_loader_entries_dir() -> str:
20912091
"""
20922092
return '/boot/loader/entries'
20932093

2094+
@staticmethod
2095+
def get_apk_repo_config() -> str:
2096+
"""
2097+
Repository file for apk
2098+
2099+
:return: file path name
2100+
2101+
:rtype: str
2102+
"""
2103+
return '/etc/apk/repositories'
2104+
20942105
def get(self, key):
20952106
"""
20962107
Implements get method for profile elements

kiwi/package_manager/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def new(
5959
'dnf4': ['dnf4', 'Dnf4'],
6060
'microdnf': ['microdnf', 'MicroDnf'],
6161
'pacman': ['pacman', 'Pacman'],
62-
'apt': ['apt', 'Apt']
62+
'apt': ['apt', 'Apt'],
63+
'apk': ['apk', 'Apk']
6364
}
6465
try:
6566
(module_namespace, module_name) = name_map[package_manager_name]

0 commit comments

Comments
 (0)