git » mk-builders.git » commit 5b68656

Lets make use of the arm64 packages, and script making of buildcore64

author Urja (ARMLFS builder)
2024-06-29 07:49:38 UTC
committer Urja (ARMLFS builder)
2024-06-29 07:49:38 UTC
parent 630cb7cebe5c54c3b647eea8b6d1308a5f06df7f

Lets make use of the arm64 packages, and script making of buildcore64

bc64-usr-a32/clang +17 -0
bc64-usr-a32/clang++ +27 -0
bc64-usr-a32/rustc +20 -0
build64-initial.sh +34 -0
build64-pacman.conf +80 -0
make-build64.sh +55 -0

diff --git a/bc64-usr-a32/clang b/bc64-usr-a32/clang
new file mode 100755
index 0000000..74e0d8c
--- /dev/null
+++ b/bc64-usr-a32/clang
@@ -0,0 +1,17 @@
+#!/bin/bash
+MCF="-march=armv7-a -mfloat-abi=hard -mfpu=neon"
+target="--target=armv7l-unknown-linux-gnueabihf"
+sysroot=/mnt/armlfs
+for arg; do
+	if [[ $arg = *-target* ]]; then
+		target=
+	fi
+	if [[ $arg = --target=aarch64* ]]; then
+		sysroot=/
+		MCF=
+	fi
+done
+exec /usr/bin/clang $target --sysroot=$sysroot $MCF \
+"$@"
+#-isystem $sysroot/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/12.3.0/include \
+
diff --git a/bc64-usr-a32/clang++ b/bc64-usr-a32/clang++
new file mode 100755
index 0000000..1472531
--- /dev/null
+++ b/bc64-usr-a32/clang++
@@ -0,0 +1,27 @@
+#!/bin/bash
+MCF="-march=armv7-a -mfloat-abi=hard -mfpu=neon"
+target="--target=armv7l-unknown-linux-gnueabihf"
+sysroot="--sysroot=/mnt/armlfs"
+CPPLIBS="-stdlib++-isystem /mnt/armlfs/usr/include/c++/12.3.0/armv7l-unknown-linux-gnueabihf \
+ -stdlib++-isystem /mnt/armlfs/usr/include/c++/12.3.0"
+
+arr=()
+for arg; do
+	if [[ $arg = *-target* ]]; then
+		target=
+	fi
+	if [[ $arg = --target=aarch64* ]]; then
+		sysroot=
+		MCF=
+		CPPLIBS=
+		continue
+	fi
+	if [ "$arg" == "--target=armv7-unknown-linux-gnueabihf" ]; then
+		arg="--target=armv7l-unknown-linux-gnueabihf"
+	fi
+	arr+=("$arg")
+done
+exec /usr/bin/clang++ $target $sysroot $MCF $CPPLIBS \
+"${arr[@]}"
+#-isystem $sysroot/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/12.3.0/include \
+
diff --git a/bc64-usr-a32/rustc b/bc64-usr-a32/rustc
new file mode 100755
index 0000000..c127493
--- /dev/null
+++ b/bc64-usr-a32/rustc
@@ -0,0 +1,20 @@
+#!/bin/bash
+target_next=
+sysroot=/usr
+for arg; do
+	if [ -n "$target_next" ]; then
+		if [[ $arg = armv7* ]]; then
+			sysroot=/mnt/armlfs/usr
+		fi
+		target_next=
+		continue
+	fi
+	if [ "$arg" = "--target" ]; then
+		target_next=1
+		continue
+	fi
+	if [[ $arg = --target=armv7* ]]; then
+		sysroot=/mnt/armlfs/usr
+	fi
+done
+exec /usr/bin/rustc --sysroot=$sysroot "$@"
diff --git a/build64-initial.sh b/build64-initial.sh
new file mode 100755
index 0000000..4b91cba
--- /dev/null
+++ b/build64-initial.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+ldconfig -r .
+echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
+echo "LANG=en_US.UTF-8" > /etc/locale.conf
+locale-gen
+export LANG="en_US.UTF-8"
+# install all the packages
+pacman -S --noconfirm base-devel nano which rust
+# remove sudo (and the base-devel meta, since it's what pulled sudo in...)
+pacman -R --noconfirm sudo base-devel
+echo checkitout
+bash
+
+systemctl preset-all
+systemd-sysusers
+setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx var/log/journal/ 2>/dev/null
+# enable some services by default, but don't track them
+systemctl enable \
+    getty@tty1.service \
+    remote-fs.target
+
+mkdir -m2755 var/log/journal/remote
+chgrp systemd-journal-remote var/log/journal/remote
+
+# Add the builder user
+useradd -U -G users,wheel -u 2000 -m builder
+
+# The root user could use the skel files, too.
+cp /etc/skel/.bash* /root/
+echo "export VISUAL=nano" >> /root/.bashrc
+
+# Null out the passwords
+passwd -d root
+passwd -d builder
diff --git a/build64-pacman.conf b/build64-pacman.conf
new file mode 100644
index 0000000..a45a666
--- /dev/null
+++ b/build64-pacman.conf
@@ -0,0 +1,80 @@
+#
+# /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    = /sources/arm64-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 = aarch64
+
+# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
+IgnorePkg   = linux-aarch64
+#IgnoreGroup =
+
+#NoUpgrade   =
+#NoExtract   =
+
+# Misc options
+#UseSyslog
+#Color
+#NoProgressBar
+CheckSpace
+#VerbosePkgLists
+#ParallelDownloads = 5
+
+# 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 = Never
+#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 ARM
+# packagers with `pacman-key --populate archlinuxarm`.
+
+#
+# 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.
+
+[arm64]
+Server = file:///sources/arm64-pkg
+
+# 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
diff --git a/make-build64.sh b/make-build64.sh
new file mode 100755
index 0000000..d4aecd1
--- /dev/null
+++ b/make-build64.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+BSN=buildcore64-v2
+BS=/$BSN
+if [ -d $BS ]; then
+	echo "Will delete $BS, enter to continue"
+	read dummy
+	# Shh, just in case
+	umount $BS/sources/arm64-pkg 2>/dev/null || true
+	umount $BS/dev 2>/dev/null || true
+	umount $BS/proc 2>/dev/null || true
+	umount $BS/sys 2>/dev/null || true
+	umount $BS/var/cache/pacman/pkg 2>/dev/null || true
+	umount $BS 2>/dev/null || true
+	rm -r $BS
+fi
+
+mkdir -p $BS
+
+# To allow pacman-in-chroot to believe that / is a mount point
+mount --bind $BS $BS
+
+mkdir -p $BS/var/lib/pacman
+pacman --config build64-pacman.conf -Sy -b $BS/var/lib/pacman -r $BS
+pacman --config build64-pacman.conf -S --noconfirm  --noscriptlet -b $BS/var/lib/pacman -r $BS base
+
+# Pacman/makepkg configuration and cd into target
+
+# ARM32 clang & rustc helper scripts
+cp -a bc64-usr-a32 $BS/usr/a32
+
+cp build64-pacman.conf $BS/etc/pacman.conf
+cp build64-initial.sh $BS/initial.sh
+cd $BS
+
+run_in_chroot() {
+mkdir -p sources/arm64-pkg
+mount --bind /sources/arm64-pkg sources/arm64-pkg
+mount -t proc proc proc
+mount -t sysfs sys sys
+mount --bind /dev dev
+mkdir -p var/cache/pacman/pkg
+mkdir -p /tmp/ds{cache,work}
+mount -t overlay -o lowerdir=/sources/arm64-pkg,upperdir=/tmp/dscache,workdir=/tmp/dswork overlay var/cache/pacman/pkg
+chmod +x ./$1
+chroot . ./$1
+umount sources/arm64-pkg proc sys dev var/cache/pacman/pkg
+rm ./$1
+return 0
+}
+run_in_chroot initial.sh
+
+cd -
+umount $BS
+echo Done.