Skip to content

Commit 25d60fd

Browse files
committed
Added Alpine Linux bootstrap
1 parent 3c4e365 commit 25d60fd

File tree

7 files changed

+119
-22
lines changed

7 files changed

+119
-22
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Linux Deploy Component
2+
# (c) Anton Skshidlevsky <meefik@gmail.com>, GPLv3
3+
4+
NAME="alpine"
5+
DESC="Bootstrap for Alpine Linux"
6+
DEPENDS="bootstrap"

include/bootstrap/alpine/deploy.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
# Linux Deploy Component
3+
# (c) Anton Skshidlevsky <meefik@gmail.com>, GPLv3
4+
5+
[ -n "${SUITE}" ] || SUITE="latest-stable"
6+
7+
if [ -z "${ARCH}" ]
8+
then
9+
case "$(get_platform)" in
10+
x86) ARCH="x86" ;;
11+
x86_64) ARCH="x86_64" ;;
12+
arm) ARCH="armhf" ;;
13+
arm_64) ARCH="aarch64" ;;
14+
esac
15+
fi
16+
17+
[ -n "${SOURCE_PATH}" ] || SOURCE_PATH="http://dl-cdn.alpinelinux.org/alpine/"
18+
19+
apk_install()
20+
{
21+
local packages="$@"
22+
[ -n "${packages}" ] || return 1
23+
(set -e
24+
chroot_exec -u root apk update || true
25+
chroot_exec -u root apk add ${packages}
26+
exit 0)
27+
return $?
28+
}
29+
30+
do_install()
31+
{
32+
is_archive "${SOURCE_PATH}" && return 0
33+
34+
msg ":: Installing ${COMPONENT} ... "
35+
36+
local repo_url="${SOURCE_PATH%/}/${SUITE}"
37+
38+
msg "URL: ${repo_url}"
39+
40+
msg -n "Retrieving rootfs archive ... "
41+
local rootfs_name=$(wget -q -O - "${repo_url}/releases/${ARCH}/latest-releases.yaml" | grep "file: alpine-minirootfs" | awk '{print $2}')
42+
wget -q -O - "${repo_url}/releases/${ARCH}/${rootfs_name}" | tar xz -C "${CHROOT_DIR}"
43+
is_ok "fail" "done" || return 1
44+
45+
component_exec core/emulator core/mnt core/net
46+
47+
msg "Installing extra packages: "
48+
apk_install shadow sudo tzdata
49+
is_ok || return 1
50+
51+
return 0
52+
}
53+
54+
do_help()
55+
{
56+
cat <<EOF
57+
--arch="${ARCH}"
58+
Architecture of Linux distribution, supported "aarch64", "armhf", "x86" and "x86_64".
59+
60+
--suite="${SUITE}"
61+
Version of Linux distribution, supported version "latest-stable", "edge".
62+
63+
--source-path="${SOURCE_PATH}"
64+
Installation source, can specify address of the repository or path to the rootfs archive.
65+
66+
EOF
67+
}

include/core/aid/deploy.sh

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,42 @@ do_configure()
66
{
77
msg ":: Configuring ${COMPONENT} ... "
88
# set min uid and gid
9-
sed -i 's|^[#]\?UID_MIN.*|UID_MIN 5000|' "${CHROOT_DIR}/etc/login.defs"
10-
sed -i 's|^[#]\?GID_MIN.*|GID_MIN 5000|' "${CHROOT_DIR}/etc/login.defs"
9+
local login_defs
10+
login_defs="${CHROOT_DIR}/etc/login.defs"
11+
if [ ! -e "${login_defs}" ]; then
12+
touch "${login_defs}"
13+
fi
14+
if ! $(grep -q '^ *UID_MIN' "${login_defs}"); then
15+
echo "UID_MIN 5000" >>"${login_defs}"
16+
sed -i 's|^[#]\?UID_MIN.*|UID_MIN 5000|' "${login_defs}"
17+
fi
18+
if ! $(grep -q '^ *GID_MIN' "${login_defs}"); then
19+
echo "GID_MIN 5000" >>"${login_defs}"
20+
sed -i 's|^[#]\?GID_MIN.*|GID_MIN 5000|' "${login_defs}"
21+
fi
1122
# add android groups
12-
local aid uid
13-
for aid in $(cat "${COMPONENT_DIR}/android_groups")
14-
do
15-
local xname=$(echo ${aid} | awk -F: '{print $1}')
16-
local xid=$(echo ${aid} | awk -F: '{print $2}')
17-
sed -i "s|^${xname}:.*|${xname}:x:${xid}:${USER_NAME}|" "${CHROOT_DIR}/etc/group"
18-
if ! $(grep -q "^${xname}:" "${CHROOT_DIR}/etc/group"); then
19-
echo "${xname}:x:${xid}:${USER_NAME}" >> "${CHROOT_DIR}/etc/group"
20-
fi
21-
if ! $(grep -q "^${xname}:" "${CHROOT_DIR}/etc/passwd"); then
22-
echo "${xname}:x:${xid}:${xid}::/:/bin/false" >> "${CHROOT_DIR}/etc/passwd"
23-
fi
24-
# add users to aid_inet group
25-
for uid in ${PRIVILEGED_USERS}
23+
if [ -n "${PRIVILEGED_USERS}" ]; then
24+
local aid uid
25+
for aid in $(cat "${COMPONENT_DIR}/android_groups")
2626
do
27-
if ! $(grep -q "^${xname}:.*${uid}" "${CHROOT_DIR}/etc/group"); then
28-
sed -i "s|^\(${xname}:.*\)|\1,${uid}|" "${CHROOT_DIR}/etc/group"
27+
local xname=$(echo ${aid} | awk -F: '{print $1}')
28+
local xid=$(echo ${aid} | awk -F: '{print $2}')
29+
sed -i "s|^${xname}:.*|${xname}:x:${xid}:${USER_NAME}|" "${CHROOT_DIR}/etc/group"
30+
if ! $(grep -q "^${xname}:" "${CHROOT_DIR}/etc/group"); then
31+
echo "${xname}:x:${xid}:${USER_NAME}" >> "${CHROOT_DIR}/etc/group"
2932
fi
33+
if ! $(grep -q "^${xname}:" "${CHROOT_DIR}/etc/passwd"); then
34+
echo "${xname}:x:${xid}:${xid}::/:/bin/false" >> "${CHROOT_DIR}/etc/passwd"
35+
fi
36+
# add users to aid_inet group
37+
for uid in ${PRIVILEGED_USERS}
38+
do
39+
if ! $(grep -q "^${xname}:.*${uid}" "${CHROOT_DIR}/etc/group"); then
40+
sed -i "s|^\(${xname}:.*\)|\1,${uid}|" "${CHROOT_DIR}/etc/group"
41+
fi
42+
done
3043
done
31-
done
44+
fi
3245
return 0
3346
}
3447

include/core/locale/deploy.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ do_configure()
2727
slackware)
2828
sed -i "s|^export LANG=.*|export LANG=${LOCALE}|g" "${CHROOT_DIR}/etc/profile.d/lang.sh"
2929
;;
30+
alpine)
31+
echo "LANG=${LOCALE}" > "${CHROOT_DIR}/etc/profile.d/lang.sh"
32+
;;
3033
esac
3134
return 0
3235
}
@@ -35,7 +38,7 @@ do_help()
3538
{
3639
cat <<EOF
3740
--locale="${LOCALE}"
38-
Localization, e.g. "ru_RU.UTF-8".
41+
Localization, e.g. "en_US.UTF-8".
3942
4043
EOF
4144
}

include/core/profile/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ do_configure()
1414
# user profile
1515
if [ "${USER_NAME}" != "root" ]; then
1616
chroot_exec -u root groupadd ${USER_NAME}
17-
chroot_exec -u root useradd -m -g ${USER_NAME} -s /bin/bash ${USER_NAME}
17+
chroot_exec -u root useradd -m -g ${USER_NAME} -s /bin/sh ${USER_NAME}
1818
chroot_exec -u root usermod -g ${USER_NAME} ${USER_NAME}
1919
fi
2020
# set password for user

include/desktop/dbus/deploy.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ do_install()
77
msg ":: Installing ${COMPONENT} ... "
88
local packages=""
99
case "${DISTRIB}:${ARCH}:${SUITE}" in
10-
debian:*|ubuntu:*|kalilinux:*)
10+
debian:*|ubuntu:*|kali:*)
1111
packages="dbus"
1212
apt_install ${packages}
1313
;;
@@ -27,6 +27,10 @@ do_install()
2727
packages="sys-apps/dbus"
2828
emerge_install ${packages}
2929
;;
30+
alpine:*)
31+
packages="dbus"
32+
apk_install ${packages}
33+
;;
3034
esac
3135
}
3236

include/extra/ssh/deploy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ do_install()
3434
packages="openssh"
3535
slackpkg_install ${packages}
3636
;;
37+
alpine:*)
38+
packages="openssh-server"
39+
apk_install ${packages}
40+
;;
3741
esac
3842
}
3943

0 commit comments

Comments
 (0)