From aff29ea948e6ab5d332e3fe646fa11ec38107c6d Mon Sep 17 00:00:00 2001 From: Alex Denes Date: Sun, 18 Jul 2021 21:50:08 +0000 Subject: [PATCH] Initial commit --- base/alpine-base/APKBUILD | 51 +++++++++ base/alpine-baselayout/APKBUILD | 104 ++++++++++++++++++ .../alpine-baselayout.post-install | 4 + .../alpine-baselayout.post-upgrade | 1 + .../alpine-baselayout.pre-install | 5 + .../alpine-baselayout.pre-upgrade | 1 + base/alpine-baselayout/group | 3 + base/alpine-baselayout/inittab | 23 ++++ base/alpine-baselayout/passwd | 2 + base/alpine-baselayout/profile | 23 ++++ 10 files changed, 217 insertions(+) create mode 100644 base/alpine-base/APKBUILD create mode 100644 base/alpine-baselayout/APKBUILD create mode 100644 base/alpine-baselayout/alpine-baselayout.post-install create mode 120000 base/alpine-baselayout/alpine-baselayout.post-upgrade create mode 100644 base/alpine-baselayout/alpine-baselayout.pre-install create mode 120000 base/alpine-baselayout/alpine-baselayout.pre-upgrade create mode 100644 base/alpine-baselayout/group create mode 100644 base/alpine-baselayout/inittab create mode 100644 base/alpine-baselayout/passwd create mode 100644 base/alpine-baselayout/profile diff --git a/base/alpine-base/APKBUILD b/base/alpine-base/APKBUILD new file mode 100644 index 0000000..262448d --- /dev/null +++ b/base/alpine-base/APKBUILD @@ -0,0 +1,51 @@ +# Contributor: Natanael Copa +# Contributor: Alex Denes +# Maintainer: Natanael Copa +pkgname=alpine-base +pkgver=3.14.0 +pkgrel=0 +pkgdesc="Meta package for minimal alpine base" +url="https://alpinelinux.org" +arch="noarch" +license="MIT" +options="!check" +depends=" + alpine-baselayout + apk-tools + alpine-keys + busybox + busybox-initscripts + openrc + musl +" + +package() { + mkdir -p "$pkgdir"/etc + # create /etc/alpine-release + echo $pkgver > "$pkgdir"/etc/alpine-release + local _ver="$(echo "$pkgver" | grep -E -o '^[0-9]+\.[0-9]+')" + local _rel="v$_ver" + case "$pkgver" in + *_alpha*|*_beta*|*_pre*) + _ver="$pkgver (edge)" + _rel="edge" + ;; + esac + + # create /etc/issue + cat >"$pkgdir"/etc/issue<"$pkgdir"/etc/os-release< +# Contributor: Alex Denes +# Maintainer: Natanael Copa +pkgname=alpine-baselayout +pkgver=3.2.0 +pkgrel=18 +pkgdesc="Alpine base dir structure and init scripts" +url="https://git.alpinelinux.org/cgit/aports/tree/main/alpine-baselayout" +arch="all" +license="GPL-2.0-only" +options="!check" +install=" + $pkgname.pre-install + $pkgname.pre-upgrade + $pkgname.post-upgrade + $pkgname.post-install +" +_nbver=6.3 +source=" + group + inittab + passwd + profile + protocols-$_nbver::https://salsa.debian.org/md/netbase/-/raw/v$_nbver/etc/protocols + services-$_nbver::https://salsa.debian.org/md/netbase/-/raw/v$_nbver/etc/services +" +builddir="$srcdir/build" + +prepare() { + default_prepare + mkdir -p "$builddir" + mv "$srcdir"/protocols-$_nbver "$srcdir"/protocols + mv "$srcdir"/services-$_nbver "$srcdir"/services +} + +build() { + # generate shadow + awk -F: '{ + pw = ":!:" + if ($1 == "root") { pw = "::" } + print($1 pw ":0:::::") + }' "$srcdir"/passwd > shadow +} + +package() { + mkdir -p "$pkgdir" + cd "$pkgdir" + + install -m 0755 -d \ + etc \ + var \ + mnt \ + proc \ + run \ + sys + + install -d -m 0700 root + install -d -m 1777 tmp + + ln -s /run var/run + ln -s /tmp var/tmp + + echo "localhost" > etc/hostname + cat > etc/hosts <<-EOF + 127.0.0.1 localhost localhost.localdomain + ::1 localhost localhost.localdomain + EOF + cat > etc/shells <<-EOF + # valid login shells + /bin/sh + /bin/ash + EOF + cat > etc/motd <<-EOF + Welcome to Alpine! + + The Alpine Wiki contains a large amount of how-to guides and general + information about administrating Alpine systems. + See . + EOF + + install -m644 \ + "$srcdir"/group \ + "$srcdir"/passwd \ + "$srcdir"/inittab \ + "$srcdir"/profile \ + "$srcdir"/protocols \ + "$srcdir"/services \ + etc/ + + install -m640 "$builddir"/shadow \ + etc/ + + # symlinks + ln -s /proc/mounts etc/mtab +} + +sha512sums=" +356ec457ad1f1866e268a04d32e4952bca19977ff3017e912c62a30c4681ea1281390b06b2d009d17665c1ffae591506580a084ef9ef1ec273a00b6d60dbf15a group +fdab6f8fec2a556ab817d90a73635a927ea04dbc4e0470ed59ee6a62c87393f9534c9b746b09a776d938c25b8af9c9fb1686578e24f8307d1d074921ade1bdc7 inittab +f6fe247889a9c09a1c6ac6b1f5baae9ecc9f6300594428dc04dd8e7543c06b4774f57cf034e970a913faf7bbf0aff28b170e5c6425ab04b380b34a3b80a3b529 passwd +2e0c19c08bc161278db950ca66c138091724a134ccbaa655cb7efa933f32ce28cfc006a563d0c150646c8ac7b6c84ab03f0958fd1a55c17e7d3f91c9ff0c1e94 profile +eadc83e47fcc354ab83fd109bee452bda170886fb684e67faf615930c11480919505f4af60c685b124efc54af0ded9522663132f911eac6622144f8b4c8be695 protocols-6.3 +47b0f3ee73af2d259bd206a026204be0ea25531a895a0b035a904b38fe5407bc3dd2beab7f8fcb3d760587e6159702ebdb9cbc4f508942befdf7f10c10c87888 services-6.3 +" diff --git a/base/alpine-baselayout/alpine-baselayout.post-install b/base/alpine-baselayout/alpine-baselayout.post-install new file mode 100644 index 0000000..207e43c --- /dev/null +++ b/base/alpine-baselayout/alpine-baselayout.post-install @@ -0,0 +1,4 @@ +#!/bin/sh + +# force /etc/shadow to be owned by root and not be world readable +chown root:shadow /etc/shadow diff --git a/base/alpine-baselayout/alpine-baselayout.post-upgrade b/base/alpine-baselayout/alpine-baselayout.post-upgrade new file mode 120000 index 0000000..0e73fc0 --- /dev/null +++ b/base/alpine-baselayout/alpine-baselayout.post-upgrade @@ -0,0 +1 @@ +alpine-baselayout.post-install \ No newline at end of file diff --git a/base/alpine-baselayout/alpine-baselayout.pre-install b/base/alpine-baselayout/alpine-baselayout.pre-install new file mode 100644 index 0000000..fc0d0b9 --- /dev/null +++ b/base/alpine-baselayout/alpine-baselayout.pre-install @@ -0,0 +1,5 @@ +#!/bin/sh + +addgroup -S -g 42 shadow 2>/dev/null + +exit 0 diff --git a/base/alpine-baselayout/alpine-baselayout.pre-upgrade b/base/alpine-baselayout/alpine-baselayout.pre-upgrade new file mode 120000 index 0000000..6153084 --- /dev/null +++ b/base/alpine-baselayout/alpine-baselayout.pre-upgrade @@ -0,0 +1 @@ +alpine-baselayout.pre-install \ No newline at end of file diff --git a/base/alpine-baselayout/group b/base/alpine-baselayout/group new file mode 100644 index 0000000..a16b903 --- /dev/null +++ b/base/alpine-baselayout/group @@ -0,0 +1,3 @@ +root:x:0:root +nogroup:x:65533: +nobody:x:65534: diff --git a/base/alpine-baselayout/inittab b/base/alpine-baselayout/inittab new file mode 100644 index 0000000..960aa40 --- /dev/null +++ b/base/alpine-baselayout/inittab @@ -0,0 +1,23 @@ +# /etc/inittab + +::sysinit:/sbin/openrc sysinit +::sysinit:/sbin/openrc boot +::wait:/sbin/openrc default + +# Set up a couple of getty's +tty1::respawn:/sbin/getty 38400 tty1 +tty2::respawn:/sbin/getty 38400 tty2 +tty3::respawn:/sbin/getty 38400 tty3 +tty4::respawn:/sbin/getty 38400 tty4 +tty5::respawn:/sbin/getty 38400 tty5 +tty6::respawn:/sbin/getty 38400 tty6 + +# Put a getty on the serial port +#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 + +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/sbin/openrc shutdown + diff --git a/base/alpine-baselayout/passwd b/base/alpine-baselayout/passwd new file mode 100644 index 0000000..cdec8ed --- /dev/null +++ b/base/alpine-baselayout/passwd @@ -0,0 +1,2 @@ +root:x:0:0:root:/root:/bin/ash +nobody:x:65534:65534:nobody:/:/sbin/nologin diff --git a/base/alpine-baselayout/profile b/base/alpine-baselayout/profile new file mode 100644 index 0000000..1b9c31c --- /dev/null +++ b/base/alpine-baselayout/profile @@ -0,0 +1,23 @@ +# Append "$1" to $PATH when not already in. +# Copied from Arch Linux, see #12803 for details. +append_path () { + case ":$PATH:" in + *:"$1":*) + ;; + *) + PATH="${PATH:+$PATH:}$1" + ;; + esac +} + +append_path "/usr/local/sbin" +append_path "/usr/local/bin" +append_path "/usr/sbin" +append_path "/usr/bin" +append_path "/sbin" +append_path "/bin" +unset -f append_path + +export PATH +export PAGER=less +umask 022