From 79df7da6d854840c2069844370827a9b745364c0 Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 3 Sep 2024 23:22:12 -0300 Subject: [PATCH] add scripts for build --- .gitignore | 3 +++ gendisk.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ geninitrd.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100755 gendisk.sh create mode 100755 geninitrd.sh diff --git a/.gitignore b/.gitignore index 9bba5a87..d01eea1d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ tools/init/reboot tools/init/reboot.o tools/init/acpid tools/init/acpid.o +initrds +hdd.img +netdump.dat diff --git a/gendisk.sh b/gendisk.sh new file mode 100755 index 00000000..5f665ac3 --- /dev/null +++ b/gendisk.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash + +if [ $# != 3 ] +then + echo "usage: $0 size sysrootdir diskname" + exit 1 +fi + +if [ -z $2 ] +then + echo "please pass a non empty sysroot" + exit 1 +fi + +if [ -z $3 ] +then + echo "please pass a non empty disk name" + exit 1 +fi + +if [ -z "$(which fakeroot)" ] +then + echo "script requires fakeroot to run, please install it." + exit 1 +fi + + +PATH="/usr/sbin/:$PATH" fakeroot << EOF +# create image +truncate $3 -s $1 + +# chown to proper uids, keeping setuid bits +find $2/ ! -type l -perm -04000 -exec chown -h 0:0 {} + \ + -exec chmod u+s {} + +find $2/ ! -type l ! -perm -04000 -exec chown 0:0 -h {} + + +find $2/home/astral ! -type l -perm -04000 -exec chown -h 1000:1000 {} + \ + -exec chmod u+s {} + +find $2/home/astral ! -type l ! -perm -04000 -exec chown -h 1000:1000 {} + + +# create filesystem and copy files into image +mkfs.ext2 -O ^dir_index $3 -d $2 +EOF diff --git a/geninitrd.sh b/geninitrd.sh new file mode 100755 index 00000000..a55945e1 --- /dev/null +++ b/geninitrd.sh @@ -0,0 +1,40 @@ +#!/usr/bin/bash + +if [ $# != 2 ] +then + echo "usage: $0 sysrootdir initrdfullpath" + exit 1 +fi + +if [ -z $1 ] +then + echo "please pass a non empty sysroot" + exit 1 +fi + +if [ -z $2 ] +then + echo "please pass a non empty initrd full path" + exit 1 +fi + +if [ -z "$(which fakeroot)" ] +then + echo "script requires fakeroot to run, please install it." + exit 1 +fi + +fakeroot << EOF +# chown to proper uids, keeping setuid bits +find $1/ ! -type l -perm -04000 -exec chown -h 0:0 {} + \ + -exec chmod u+s {} + +find $1/ ! -type l ! -perm -04000 -exec chown 0:0 -h {} + + +find $1/home/astral ! -type l -perm -04000 -exec chown -h 1000:1000 {} + \ + -exec chmod u+s {} + +find $1/home/astral ! -type l ! -perm -04000 -exec chown -h 1000:1000 {} + + +# create initrd +cd $1 +tar --format=ustar -cf $2 * +EOF