temp/alpine-baselayout: fork from alpine's /usr-merge branch

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/85504

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6754
[ci:skip-build]: already built successfully in CI
This commit is contained in:
Pablo Correa Gómez 2025-04-03 23:33:23 +02:00
parent 3695b0bf4f
commit 2a9d4da33a
No known key found for this signature in database
GPG key ID: 7A342565FF635F79
15 changed files with 626 additions and 0 deletions

View file

@ -0,0 +1,3 @@
export CHARSET=${CHARSET:-UTF-8}
export LANG=${LANG:-C.UTF-8}
export LC_COLLATE=${LC_COLLATE:-C}

View file

@ -0,0 +1,293 @@
# Forked from Alpine to get the usr-merge going
# Maintainer: Pablo Correa Gomez <pabloyoyoista@postmarketos.org>
pkgname=alpine-baselayout
pkgver=99993.7.0
_pkgver=3.7.0
pkgrel=0
pkgdesc="Alpine base dir structure and init scripts"
url="https://git.alpinelinux.org/cgit/aports/tree/main/alpine-baselayout"
arch="noarch"
license="GPL-2.0-only"
pkggroups="shadow"
replaces_priority=1000
options="!fhs !check keepdirs"
depends="$pkgname-data=$pkgver-r$pkgrel"
subpackages="$pkgname-data $pkgname-core"
install="$pkgname.pre-install $pkgname.pre-upgrade $pkgname.post-upgrade
$pkgname.post-install"
_nbver=6.4
source="crontab
color_prompt.sh.disabled
20locale.sh
aliases.conf
blacklist.conf
i386.conf
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
}
data() {
replaces="alpine-baselayout"
depends=
amove etc/fstab
amove etc/group
amove etc/hostname
amove etc/hosts
amove etc/inittab
amove etc/nsswitch.conf
amove etc/modules
amove etc/mtab
amove etc/passwd
amove etc/profile
amove etc/protocols
amove etc/services
amove etc/shadow
amove etc/shells
amove etc/sysctl.conf
}
core() {
pkgdesc="Minimal structure that foundational packages can depend on"
depends=""
replaces="alpine-baselayout"
mkdir -p "$subpkgdir"
cd "$subpkgdir"
install -m 0755 -d usr/bin usr/lib usr/sbin
ln -s usr/bin "$subpkgdir"/bin
ln -s usr/lib "$subpkgdir"/lib
ln -s usr/sbin "$subpkgdir"/sbin
}
package() {
mkdir -p "$pkgdir"
cd "$pkgdir"
install -m 0755 -d \
dev \
dev/pts \
dev/shm \
etc \
etc/crontabs \
etc/modprobe.d \
etc/modules-load.d \
etc/network \
etc/network/if-down.d \
etc/network/if-post-down.d \
etc/network/if-pre-up.d \
etc/network/if-up.d \
etc/opt \
etc/periodic \
etc/periodic/15min \
etc/periodic/daily \
etc/periodic/hourly \
etc/periodic/monthly \
etc/periodic/weekly \
etc/profile.d \
etc/sysctl.d \
home \
lib \
lib/firmware \
lib/modules-load.d \
lib/sysctl.d \
media \
media/cdrom \
media/floppy \
media/usb \
mnt \
proc \
opt \
run \
run/lock \
sbin \
srv \
sys \
usr \
usr/bin \
usr/lib \
usr/lib/firmware \
usr/lib/modules-load.d \
usr/lib/sysctl.d \
usr/local \
usr/local/bin \
usr/local/lib \
usr/local/share \
usr/sbin \
usr/share \
usr/share/man \
usr/share/misc \
var \
var/cache \
var/cache/misc \
var/lib \
var/lib/misc \
var/local \
var/log \
var/opt \
var/spool \
var/spool/cron \
var/mail
ln -s ../run var/run
ln -s ../run/lock var/lock
install -d -m 0555 var/empty
install -d -m 0700 "$pkgdir"/root
install -d -m 1777 "$pkgdir"/tmp "$pkgdir"/var/tmp
install -m600 "$srcdir"/crontab "$pkgdir"/etc/crontabs/root
install -m644 \
"$srcdir"/color_prompt.sh.disabled \
"$srcdir"/20locale.sh \
"$pkgdir"/etc/profile.d/
install -m644 \
"$srcdir"/aliases.conf \
"$srcdir"/blacklist.conf \
"$srcdir"/i386.conf \
"$pkgdir"/etc/modprobe.d/
echo "localhost" > "$pkgdir"/etc/hostname
cat > "$pkgdir"/etc/hosts <<-EOF
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
EOF
cat > "$pkgdir"/etc/modules <<-EOF
af_packet
ipv6
EOF
cat > "$pkgdir"/etc/shells <<-EOF
# valid login shells
/bin/sh
/bin/ash
EOF
cat > "$pkgdir"/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 <https://wiki.alpinelinux.org/>.
You can setup the system with the command: setup-alpine
You may change this message by editing /etc/motd.
EOF
cat > "$pkgdir"/etc/sysctl.conf <<-EOF
# content of this file will override /etc/sysctl.d/*
EOF
cat > "$pkgdir"/usr/lib/sysctl.d/00-alpine.conf <<-EOF
# Prevents SYN DOS attacks. Applies to ipv6 as well, despite name.
net.ipv4.tcp_syncookies = 1
# Prevents ip spoofing.
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
# Only groups within this id range can use ping.
net.ipv4.ping_group_range=999 59999
# Redirects can potentially be used to maliciously alter hosts
# routing tables.
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 1
net.ipv6.conf.all.accept_redirects = 0
# The source routing feature includes some known vulnerabilities.
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
# See RFC 1337
net.ipv4.tcp_rfc1337 = 1
## Enable IPv6 Privacy Extensions (see RFC4941 and RFC3041)
net.ipv6.conf.default.use_tempaddr = 2
net.ipv6.conf.all.use_tempaddr = 2
# Restarts computer after 120 seconds after kernel panic
kernel.panic = 120
# Users should not be able to create soft or hard links to files
# which they do not own. This mitigates several privilege
# escalation vulnerabilities.
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
# Disable unprivileged use of the bpf(2) syscall.
# Allowing unprivileged use of the bpf(2) syscall may allow a
# malicious user to compromise the machine.
kernel.unprivileged_bpf_disabled = 1
EOF
cat > "$pkgdir"/etc/fstab <<-EOF
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0
/dev/usbdisk /media/usb vfat noauto,ro 0 0
EOF
cat > "$pkgdir"/etc/profile.d/README <<-EOF
This directory should contain shell scripts configuring system-wide
environment on users' shells.
Files with the .sh extension found in this directory are evaluated by
Bourne-compatible shells (like ash, bash or zsh) when started as a
login shell.
EOF
cat > "$pkgdir"/etc/nsswitch.conf <<-EOF
# musl itself does not support NSS, however some third-party DNS
# implementations use the nsswitch.conf file to determine what
# policy to follow.
# Editing this file is not recommended.
hosts: files dns
EOF
install -m644 \
"$srcdir"/group \
"$srcdir"/passwd \
"$srcdir"/inittab \
"$srcdir"/profile \
"$srcdir"/protocols \
"$srcdir"/services \
"$pkgdir"/etc/
install -m640 -g shadow "$builddir"/shadow \
"$pkgdir"/etc/
# symlinks
ln -s ../../../etc/crontabs "$pkgdir"/var/spool/cron/crontabs
ln -s ../proc/mounts "$pkgdir"/etc/mtab
ln -s ../mail "$pkgdir"/var/spool/mail
}
sha512sums="
6e169c0975a1ad1ad871a863e8ee83f053de9ad0b58d94952efa4c28a8c221445d9e9732ad8b52832a50919c2f39aa965a929b3d5b3f9e62f169e2b2e0813d82 crontab
558071efdce2fe92afe4277006235b1a6368b070337c7567e5632a1a3fe531f87ca692eb36f3dda498d4d29d1f834fc8f7139f2985669ae3400b6d103d6f4c5e color_prompt.sh.disabled
03361d912cf29c127608697ee14bfa5972f82a5c475e653378ca5f7670cbd8183efc7c8c339ff046ff6537944fe00c4a732bb6b552aecaecd1214ed3e11bdf90 20locale.sh
bfe947bdd69e7d93b32c8cb4e2cabe5717cb6c1e1f49a74015ac2cfb13e96d1f12c4be23ae93a1d61aaa3760d33a032fa9bd99f227fb21223a76b5f5908acc65 aliases.conf
0a1e1afa580751e80bf26057b65fadffe269c0552e7a1903de498f94973ba3da8453b51f25e649968ca5f4841266f5ccf951700fa28465a8614b83d07344de60 blacklist.conf
49109d434b577563849c43dd8141961ca798dada74d4d3f49003dac1911f522c43438b8241fa254e4faacdd90058f4d39a7d69b1f493f6d57422c1f706547c95 i386.conf
b5eb01165c714861e860f17c0156911ff882a9010306b7fc4cdb22251acf8b1c91a3fa1d44cc41cb3d9b50892e2f98f43da57b002c5c33200c1bf49c3d2d587d group
37d7b8348e604b12c055d9d7e79afb568ededea7153ff552c9f383cffd537d9c78cfd9facd612d2a6753fc626ff608a6d22d62637585a33166aa28f59fabed22 inittab
f0d12f365839e7e262ec91e151119de7f2f253e9d0443157de4d52e183f421fbbb9eb0a83b9267a9ee850bebe41bff3c3cef553f9bda6e70d59a754a955be57d passwd
4eb857ed59c2edb257636d2bf196989e514a273e9701e9f076c9ae8c1589b4898269180569960acf072c0981ec7ea54014fd230f014401d6bb92314285d1e6aa profile
3a00083bcdf5a9e884c9d07877d52311e3d99e79cbee656e236ba06e08ba0dddb7ba76494fdc9dd1a826c48e197a790a69e6bb458e9df64832d6b5e904e9fd15 protocols-6.4
47b0f3ee73af2d259bd206a026204be0ea25531a895a0b035a904b38fe5407bc3dd2beab7f8fcb3d760587e6159702ebdb9cbc4f508942befdf7f10c10c87888 services-6.4
"

View file

@ -0,0 +1,57 @@
# Aliases to tell insmod/modprobe which modules to use
# Uncomment the network protocols you don't want loaded:
# alias net-pf-1 off # Unix
# alias net-pf-2 off # IPv4
# alias net-pf-3 off # Amateur Radio AX.25
# alias net-pf-4 off # IPX
# alias net-pf-5 off # DDP / appletalk
# alias net-pf-6 off # Amateur Radio NET/ROM
# alias net-pf-9 off # X.25
# alias net-pf-10 off # IPv6
# alias net-pf-11 off # ROSE / Amateur Radio X.25 PLP
# alias net-pf-19 off # Acorn Econet
alias char-major-10-175 agpgart
alias char-major-10-200 tun
alias char-major-81 bttv
alias char-major-108 ppp_generic
alias /dev/ppp ppp_generic
alias tty-ldisc-3 ppp_async
alias tty-ldisc-14 ppp_synctty
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate
# Crypto modules (see http://www.kerneli.org/)
alias loop-xfer-gen-0 loop_gen
alias loop-xfer-3 loop_fish2
alias loop-xfer-gen-10 loop_gen
alias cipher-2 des
alias cipher-3 fish2
alias cipher-4 blowfish
alias cipher-6 idea
alias cipher-7 serp6f
alias cipher-8 mars6
alias cipher-11 rc62
alias cipher-15 dfc2
alias cipher-16 rijndael
alias cipher-17 rc5
# Support for i2c and lm_sensors
alias char-major-89 i2c-dev
# xfrm
alias xfrm-type-2-4 xfrm4_tunnel
alias xfrm-type-2-50 esp4
alias xfrm-type-2-51 ah4
alias xfrm-type-2-108 ipcomp
alias xfrm-type-10-41 xfrm6_tunnel
alias xfrm-type-10-50 esp6
alias xfrm-type-10-51 ah6
alias xfrm-type-10-108 ipcomp6
alias sha1 sha1-generic
# change to aes-i586 to boost performance
alias aes aes-generic

View file

@ -0,0 +1,14 @@
#!/bin/sh
# update color_prompt.sh symlink (if exists) after we renamed color_prompt to
# color_prompt.sh.disabled.
case "$(readlink etc/profile.d/color_prompt.sh 2>/dev/null || true)" in
color_prompt) ln -sf color_prompt.sh.disabled etc/profile.d/color_prompt.sh;;
esac
# the /etc/group file is created after /etc/shadow. Needed to apply the group
# properly.
chown root:shadow etc/shadow
[ -e etc/shadow- ] && chown root:shadow etc/shadow-
exit 0

View file

@ -0,0 +1 @@
alpine-baselayout.post-install

View file

@ -0,0 +1,5 @@
#!/bin/sh
addgroup -S -g 42 shadow 2>/dev/null
exit 0

View file

@ -0,0 +1,41 @@
#!/bin/sh
# we need to have our modprobe.d files with .conf suffix
for i in etc/modprobe.d/*; do
# ignore files that does not exist (i.e if modprobe.d is empty)
[ -r "$i" ] || continue
# ignore files that have an extension
case "$i" in
*.*) continue;;
esac
# append extension
mv "$i" "$i".conf
done
# migrate /var/run directory to /run
if [ -d var/run ] && [ ! -L var/run ]; then
cp -a var/run/* run 2>/dev/null
rm -rf var/run
ln -s ../run var/run
fi
# migrate /var/lock directory to /run/lock
if [ -d var/lock ] && [ ! -L var/lock ]; then
mkdir -p run/lock/subsys
cp -a var/lock/* run/lock 2>/dev/null
rm -rf var/lock
ln -s ../run/lock var/lock
fi
# migrate /var/spool/mail directory to /var/mail
if [ -d var/spool/mail ] && [ ! -L var/spool/mail ]; then
mkdir -p var/mail
cp -a var/spool/mail/* var/mail/ 2>/dev/null
rm -rf var/spool/mail
ln -s ../mail var/spool/mail
fi
addgroup -S -g 42 shadow 2>/dev/null
exit 0

View file

@ -0,0 +1,84 @@
#
# Listing a module here prevents the hotplug scripts from loading it.
# Usually that'd be so that some other driver will bind it instead,
# no matter which driver happens to get probed first. Sometimes user
# mode tools can also control driver binding.
# tulip ... de4x5, xircom_tulip_cb, dmfe (...) handle same devices
blacklist de4x5
# At least 2.4.3 and later xircom_tulip doesn't have that conflict
# xircom_tulip_cb
blacklist dmfe
#evbug is a debug tool and should be loaded explicitly
blacklist evbug
# Alternate 8139 driver. Some 8139 cards need this specific driver,
# though...
# blacklist 8139cp
# Ethernet over IEEE1394 module. In too many cases this will load
# when there's no eth1394 device present (just an IEEE1394 port)
blacklist eth1394
# This module causes many Intel motherboards to crash and reboot.
blacklist i8xx-tco
# The kernel lists this as "experimental", but for now it's "broken"
blacklist via-ircc
# ALSA modules to support sound modems. These should be loaded manually
# if needed. For most people they just break sound support...
blacklist snd-atiixp-modem
blacklist snd-intel8x0m
blacklist snd-via82xx-modem
# we don't want use the pc speaker
blacklist snd-pcsp
# Alternative module to Orinoco Wireless Cards.
blacklist hostap
blacklist hostap_cs
# framebuffer drivers
blacklist aty128fb
blacklist atyfb
blacklist radeonfb
blacklist i810fb
blacklist cirrusfb
blacklist intelfb
blacklist kyrofb
blacklist i2c-matroxfb
blacklist hgafb
blacklist nvidiafb
blacklist rivafb
blacklist savagefb
blacklist sstfb
blacklist neofb
blacklist tridentfb
blacklist tdfxfb
blacklist viafb
blacklist virgefb
blacklist vga16fb
blacklist matroxfb_base
blacklist vt8623fb
# blacklist 1394 drivers
blacklist ohci1394
blacklist video1394
blacklist dv1394
# blacklist mISDN dirver by default as we prefer dahdi drivers
blacklist hfcmulti
blacklist hfcpci
blacklist hfcsusb
# blacklist C7 cpu freq. use acpi-cpufreq instead
blacklist e_powersaver
blacklist microcode
# needs init config, not compatible with acpid
# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12999
blacklist tiny_power_button

View file

@ -0,0 +1,17 @@
# Setup a red prompt for root and a green one for users.
# Symlink this file to color_prompt.sh to actually enable it.
_normal=$'\e[0m'
if [ "$USER" = root ]; then
_color=$'\e[1;31m'
_symbol='#'
else
_color=$'\e[1;32m'
_symbol='$'
fi
if [ -n "$ZSH_VERSION" ]; then
PS1="%{$_color%}%m [%{$_normal%}%~%{$_color%}]$_symbol %{$_normal%}"
else
PS1="\[$_color\]\h [\[$_normal\]\w\[$_color\]]$_symbol \[$_normal\]"
fi
unset _normal _color _symbol

View file

@ -0,0 +1,8 @@
# do daily/weekly/monthly maintenance
# min hour day month weekday command
*/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly

View file

@ -0,0 +1,35 @@
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin
adm:x:4:root,daemon
tty:x:5:
disk:x:6:root
lp:x:7:lp
kmem:x:9:
wheel:x:10:root
floppy:x:11:root
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
cron:x:16:cron
audio:x:18:
cdrom:x:19:
dialout:x:20:root
ftp:x:21:
sshd:x:22:
input:x:23:
tape:x:26:root
video:x:27:root
netdev:x:28:
kvm:x:34:kvm
games:x:35:
shadow:x:42:
www-data:x:82:
users:x:100:games
ntp:x:123:
abuild:x:300:
utmp:x:406:
ping:x:999:
nogroup:x:65533:
nobody:x:65534:

View file

@ -0,0 +1,4 @@
alias parport_lowlevel parport_pc
alias char-major-10-144 nvram
alias binfmt-0064 binfmt_aout
alias char-major-10-135 rtc

View file

@ -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 115200 ttyS0 vt100
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/sbin/openrc shutdown

View file

@ -0,0 +1,17 @@
root:x:0:0:root:/root:/bin/sh
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin

View file

@ -0,0 +1,24 @@
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PAGER=less
umask 022
# use nicer PS1 for bash and busybox ash
if [ -n "$BASH_VERSION" -o "$BB_ASH_VERSION" ]; then
PS1='\h:\w\$ '
# use nicer PS1 for zsh
elif [ -n "$ZSH_VERSION" ]; then
PS1='%m:%~%# '
# set up fallback default PS1
else
: "${HOSTNAME:=$(hostname)}"
PS1='${HOSTNAME%%.*}:$PWD'
[ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ "
fi
for script in /etc/profile.d/*.sh ; do
if [ -r "$script" ] ; then
. "$script"
fi
done
unset script