Add project build and test process of ParchLinux WSL

This commit is contained in:
Amir Husayn Panahifar 2025-05-03 19:58:47 +03:30
parent e4186f4c3b
commit 669b428504
12 changed files with 253 additions and 0 deletions

13
Makefile Normal file
View file

@ -0,0 +1,13 @@
WORKDIR=$(shell pwd)/workdir
IMAGE_VERSION ?= $(shell date +"%Y.%m.%d")
.PHONY: build test clean
build:
scripts/build-image.sh $(WORKDIR) $(IMAGE_VERSION)
test:
scripts/test-image.sh $(WORKDIR) $(IMAGE_VERSION)
clean:
rm -rf $(WORKDIR)

10
rootfs/etc/locale.conf Normal file
View file

@ -0,0 +1,10 @@
LANG=C.UTF-8
LC_ADDRESS=fa_IR
LC_IDENTIFICATION=fa_IR
LC_MEASUREMENT=fa_IR
LC_MONETARY=fa_IR
LC_NAME=fa_IR
LC_NUMERIC=fa_IR
LC_PAPER=fa_IR
LC_TELEPHONE=fa_IR
LC_TIME=fa_IR

109
rootfs/etc/pacman.conf Normal file
View file

@ -0,0 +1,109 @@
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /
#DBPath = /var/lib/pacman/
#CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = auto
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
ILoveCandy
Color
#NoProgressBar
CheckSpace
VerbosePkgLists
ParallelDownloads = 3
DownloadUser = alpm
#DisableSandbox
DisableDownloadTimeout
ILoveCandy
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
#[core-testing]
#Include = /etc/pacman.d/mirrorlist
[core]
Include = /etc/pacman.d/mirrorlist
#[extra-testing]
#Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.
#[multilib-testing]
#Include = /etc/pacman.d/mirrorlist
[multilib]
Include = /etc/pacman.d/mirrorlist
[ppr]
SigLevel = Optional TrustAll
Include = /etc/pacman.d/parch-mirrors
[pcp]
SigLevel = Optional TrustAll
Include = /etc/pacman.d/parch-mirrors
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

View file

@ -0,0 +1,3 @@
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://mirror.leaseweb.net/archlinux/$repo/os/$arch

View file

@ -0,0 +1 @@
Server = https://mirror.parchlinux.com/repos/$repo/$arch

View file

@ -0,0 +1,6 @@
[oobe]
command = /usr/lib/wsl/first-setup.sh
defaultName = parchlinux
[shortcut]
icon = /usr/lib/wsl/parchlinux.ico

2
rootfs/etc/wsl.conf Normal file
View file

@ -0,0 +1,2 @@
[boot]
systemd=true

View file

View file

@ -0,0 +1,17 @@
#!/bin/bash
# Show some documentation
cat <<EOF
Welcome to the Parch Linux WSL image!
This image is maintained at <https://git.parchlinux.com/parchlinux/parchlinux-wsl>.
Please, report bugs at <https://git.parchlinux.org/parchlinux/parchlinux-wsl/-/issues>.
Note that WSL 1 is not supported.
For more information about this WSL image and its usage (including "tips and tricks" and troubleshooting steps), see the related Arch Wiki page at <https://wiki.parchlinux.com/title/Install_Parch_Linux_on_WSL>.
While images are built regularly, it is strongly recommended running "pacman -Syu" right after the first launch due to the rolling release nature of Parch Linux.
EOF
echo -e "\nGenerating pacman keys..." && pacman-key --init 2> /dev/null && echo "Done"

47
scripts/build-image.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
set -euo pipefail
declare -r WORKDIR="$1"
declare -r BUILDDIR="$WORKDIR/build"
declare -r OUTPUTDIR="$WORKDIR/output"
declare -r IMAGE_VERSION="$2"
mkdir -vp "$BUILDDIR/alpm-hooks/usr/share/libalpm/hooks"
find /usr/share/libalpm/hooks -exec ln -sf /dev/null "$BUILDDIR/alpm-hooks"{} \;
mkdir -vp "$BUILDDIR/var/lib/pacman/" "$OUTPUTDIR"
install -Dm 644 "/usr/share/devtools/pacman.conf.d/extra.conf" "$BUILDDIR/etc/pacman.conf"
sed 's/Include = /&rootfs/g' < "$BUILDDIR/etc/pacman.conf" > "$WORKDIR/pacman.conf"
cp --recursive --preserve=timestamps rootfs/* "$BUILDDIR/"
ln -sf /usr/lib/os-release "$BUILDDIR/etc/os-release"
fakechroot -- fakeroot -- \
pacman -Sy -r "$BUILDDIR" \
--noconfirm --dbpath "$BUILDDIR/var/lib/pacman" \
--config "$WORKDIR/pacman.conf" \
--noscriptlet \
--hookdir "$BUILDDIR/alpm-hooks/usr/share/libalpm/hooks/" base
fakechroot -- fakeroot -- chroot "$BUILDDIR" update-ca-trust
fakechroot -- fakeroot -- chroot "$BUILDDIR" pacman-key --init
fakechroot -- fakeroot -- chroot "$BUILDDIR" pacman-key --populate
fakechroot -- fakeroot -- chroot "$BUILDDIR" /usr/bin/systemd-sysusers --root "/"
fakechroot -- fakeroot -- chroot "$BUILDDIR" /usr/bin/systemctl mask systemd-firstboot
fakeroot -- \
tar \
--numeric-owner \
--xattrs \
--acls \
--exclude-from=scripts/exclude \
-C "$BUILDDIR" \
-c . \
-f "$OUTPUTDIR/parchlinux-$IMAGE_VERSION.tar"
cd "$OUTPUTDIR"
xz -T0 -9 "parchlinux-$IMAGE_VERSION.tar"
mv -v "parchlinux-$IMAGE_VERSION.tar.xz" "parchlinux-$IMAGE_VERSION.wsl"
sha256sum "parchlinux-$IMAGE_VERSION.wsl" > "parchlinux-$IMAGE_VERSION.wsl.SHA256"

16
scripts/exclude Normal file
View file

@ -0,0 +1,16 @@
./sys
./proc
./dev
./etc/hostname
./etc/machine-id
./etc/resolv.conf
./etc/pacman.d/gnupg/openpgp-revocs.d/*
./etc/pacman.d/gnupg/private-keys-v1.d/*
./etc/pacman.d/gnupg/pubring.gpg~
./etc/pacman.d/gnupg/S.*
./root/*
./tmp/*
./var/cache/pacman/pkg/*
./var/lib/pacman/sync/*
./var/tmp/*
./alpm-hooks

29
scripts/test-image.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
set -euo pipefail
declare -r WORKDIR="$1"
declare -r BUILDDIR="$WORKDIR/build"
declare -r OUTPUTDIR="$WORKDIR/output"
declare -r CLONEDIR="$WORKDIR/clone"
declare -r VENVDIR="$WORKDIR/venv"
declare -r IMAGE_VERSION="$2"
fakechroot -- fakeroot -- chroot "$BUILDDIR" test "$(wc -l /etc/group | awk '{print $1}')" -gt 10
fakechroot -- fakeroot -- chroot "$BUILDDIR" test "$(wc -l /etc/passwd | awk '{print $1}')" -gt 10
fakechroot -- fakeroot -- chroot "$BUILDDIR" pacman -Sy
fakechroot -- fakeroot -- chroot "$BUILDDIR" pacman -Qqk
fakechroot -- fakeroot -- chroot "$BUILDDIR" pacman -Syu --noconfirm podman grep
fakechroot -- fakeroot -- chroot "$BUILDDIR" podman -v
fakechroot -- fakeroot -- chroot "$BUILDDIR" id -u http
fakechroot -- fakeroot -- chroot "$BUILDDIR" locale | grep -q UTF-8
if [ -d "$CLONEDIR" ]; then
git -C "$CLONEDIR" pull https://github.com/microsoft/WSL.git
else
git clone https://github.com/microsoft/WSL.git "$CLONEDIR"
fi
python -m venv "$VENVDIR"
export PATH="$VENVDIR/bin:$PATH"
pip install -r "$CLONEDIR/distributions/requirements.txt"
python "$CLONEDIR/distributions/validate-modern.py" --tar "$OUTPUTDIR/parchlinux-$IMAGE_VERSION.wsl"