diff options
author | Sven Gothel <[email protected]> | 2022-05-23 06:21:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-23 06:21:28 +0200 |
commit | 99c14cacc4c82b156b8950f1c81514912befc5f4 (patch) | |
tree | a82878fed275bc84d3c17276f182cba588090aba /scripts | |
parent | d1076008b08e2522b6596567a86b36339a02717f (diff) |
Update build scripts, add cross building scripts
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-botan-cross.sh | 31 | ||||
-rwxr-xr-x | scripts/build-cross.sh | 31 | ||||
-rw-r--r-- | scripts/build.sh | 8 | ||||
-rwxr-xr-x | scripts/on_chroot.sh | 64 | ||||
-rwxr-xr-x | scripts/rebuild-cross.sh | 31 | ||||
-rw-r--r-- | scripts/rebuild.sh | 8 |
6 files changed, 169 insertions, 4 deletions
diff --git a/scripts/build-botan-cross.sh b/scripts/build-botan-cross.sh new file mode 100755 index 0000000..2c93fdb --- /dev/null +++ b/scripts/build-botan-cross.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# sudo mkdir -p /mnt/arm64 +# sudo mount /data/diskimages/RaspiArm64LightDev-1.2-rw-deb11-arm64-litexdev.root-ext4.img /mnt/arm64 +# scripts/build-cross.sh /mnt/arm64 +# +# sudo mkdir -p /mnt/arm32 +# sudo mount /data/diskimages/RaspiArm32LightDev-1.2-rw-deb10-armhf-litexdev.root-ext4.img /mnt/arm32 +# scripts/build-cross.sh /mnt/arm32 +# + +sdir=`dirname $(readlink -f $0)` +rootdir=`dirname $sdir` +parentdir=`dirname $rootdir` + +echo sdir ${sdir} +echo rootdir ${rootdir} +echo parentdir ${parentdir} + +export ROOTFS_DIR=$1 +shift 1 + +if [ -z "${ROOTFS_DIR}" ]; then + echo Usage "$0 <rootfs-dir>" + exit 1 +fi + +${sdir}/on_chroot.sh ${ROOTFS_DIR} << EOF + sh ${sdir}/build-botan.sh +EOF diff --git a/scripts/build-cross.sh b/scripts/build-cross.sh new file mode 100755 index 0000000..4632f4f --- /dev/null +++ b/scripts/build-cross.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# sudo mkdir -p /mnt/arm64 +# sudo mount /data/diskimages/RaspiArm64LightDev-1.2-rw-deb11-arm64-litexdev.root-ext4.img /mnt/arm64 +# scripts/build-cross.sh /mnt/arm64 +# +# sudo mkdir -p /mnt/arm32 +# sudo mount /data/diskimages/RaspiArm32LightDev-1.2-rw-deb10-armhf-litexdev.root-ext4.img /mnt/arm32 +# scripts/build-cross.sh /mnt/arm32 +# + +sdir=`dirname $(readlink -f $0)` +rootdir=`dirname $sdir` +parentdir=`dirname $rootdir` + +echo sdir ${sdir} +echo rootdir ${rootdir} +echo parentdir ${parentdir} + +export ROOTFS_DIR=$1 +shift 1 + +if [ -z "${ROOTFS_DIR}" ]; then + echo Usage "$0 <rootfs-dir>" + exit 1 +fi + +${sdir}/on_chroot.sh ${ROOTFS_DIR} << EOF + sh ${sdir}/build.sh +EOF diff --git a/scripts/build.sh b/scripts/build.sh index 3a6a6f0..4d8291f 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -6,10 +6,14 @@ bname=`basename $0 .sh` . $sdir/setup-machine-arch.sh -logfile=$bname-$archabi.log +logfile=$rootdir/$bname-$archabi.log rm -f $logfile -export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi +if [ -e /usr/lib/jvm/java-17-openjdk-$archabi ] ; then + export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$archabi +elif [ -e /usr/lib/jvm/java-11-openjdk-$archabi ] ; then + export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi +fi if [ ! -e $JAVA_HOME ] ; then echo $JAVA_HOME does not exist exit 1 diff --git a/scripts/on_chroot.sh b/scripts/on_chroot.sh new file mode 100755 index 0000000..ba662f7 --- /dev/null +++ b/scripts/on_chroot.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Example: +# +# 1) sudo mount /data/diskimages/rootfs-arm64.img /mnt/tst +# +# 2a) example invocation 1, multiline shell script +# on_chroot /mnt << EOF +# whoami +# EOF +# +# 2b) example invocation 2, one line command +# on_chroot /mnt -c "whoami" +# +# 2b) example invocation 3, interactive bash +# on_chroot /mnt -c "bash" +# +# 3) sudo ./imagetool.sh -u /mnt/tst +# + +sdir=`dirname $(readlink -f $0)` +rootdir=`dirname $sdir` +parentdir=`dirname $rootdir` + +echo sdir ${sdir} +echo rootdir ${rootdir} +echo parentdir ${parentdir} + +username=${USER} + +export ROOTFS_DIR=$1 +shift 1 + +if [ -z "${ROOTFS_DIR}" ]; then + echo Usage "$0 <rootfs-dir> commands..." + exit 1 +fi + +rootfs_parentdir="${ROOTFS_DIR}${parentdir}" +echo rootfs_parentdir ${rootfs_parentdir} + +if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/proc)"; then + sudo mount -t proc proc "${ROOTFS_DIR}/proc" +fi + +if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev)"; then + sudo mount --bind /dev "${ROOTFS_DIR}/dev" +fi + +if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev/pts)"; then + sudo mount --bind /dev/pts "${ROOTFS_DIR}/dev/pts" +fi + +if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/sys)"; then + sudo mount --bind /sys "${ROOTFS_DIR}/sys" +fi + +if ! mount | grep -q "${rootfs_parentdir}"; then + sudo mkdir -p "${rootfs_parentdir}" + sudo mount --bind ${parentdir} "${rootfs_parentdir}" +fi + +# sudo chroot ${ROOTFS_DIR}/ /bin/bash "$@" +sudo /sbin/capsh --user=$username --drop=cap_setfcap "--chroot=${ROOTFS_DIR}/" -- -e "$@" diff --git a/scripts/rebuild-cross.sh b/scripts/rebuild-cross.sh new file mode 100755 index 0000000..a28dbaa --- /dev/null +++ b/scripts/rebuild-cross.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# sudo mkdir -p /mnt/arm64 +# sudo mount /data/diskimages/RaspiArm64LightDev-1.2-rw-deb11-arm64-litexdev.root-ext4.img /mnt/arm64 +# scripts/build-cross.sh /mnt/arm64 +# +# sudo mkdir -p /mnt/arm32 +# sudo mount /data/diskimages/RaspiArm32LightDev-1.2-rw-deb10-armhf-litexdev.root-ext4.img /mnt/arm32 +# scripts/build-cross.sh /mnt/arm32 +# + +sdir=`dirname $(readlink -f $0)` +rootdir=`dirname $sdir` +parentdir=`dirname $rootdir` + +echo sdir ${sdir} +echo rootdir ${rootdir} +echo parentdir ${parentdir} + +export ROOTFS_DIR=$1 +shift 1 + +if [ -z "${ROOTFS_DIR}" ]; then + echo Usage "$0 <rootfs-dir>" + exit 1 +fi + +${sdir}/on_chroot.sh ${ROOTFS_DIR} << EOF + sh ${sdir}/rebuild.sh +EOF diff --git a/scripts/rebuild.sh b/scripts/rebuild.sh index 44e9f12..54c658c 100644 --- a/scripts/rebuild.sh +++ b/scripts/rebuild.sh @@ -6,10 +6,14 @@ bname=`basename $0 .sh` . $sdir/setup-machine-arch.sh -logfile=$bname-$archabi.log +logfile=$rootdir/$bname-$archabi.log rm -f $logfile -export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi +if [ -e /usr/lib/jvm/java-17-openjdk-$archabi ] ; then + export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$archabi +elif [ -e /usr/lib/jvm/java-11-openjdk-$archabi ] ; then + export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi +fi if [ ! -e $JAVA_HOME ] ; then echo $JAVA_HOME does not exist exit 1 |