add tools

This commit is contained in:
Liam Waldron 2023-04-27 08:14:01 -04:00
parent de78cc1793
commit 6ddccbc833
5 changed files with 220 additions and 0 deletions

68
tools/bldr Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env /bin/sh
# bldr - build a binary package from an Everest package file
pkgs=("${@}")
usage() {
printf "${0} - Build a binary package from an Everest package file\n"
printf "usage: ${0} [-h] [-v] [-b] PACKAGE\n"
printf "\n"
printf "${0} {-h --help} Show this message\n"
printf "${0} {-v --version} Show the current version\n"
printf "${0} {-b --build} Build specified packages\n"
printf "\n"
printf "bldr is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
usage_small() {
printf "usage: ${0} [-h] [-v] [-b] PACKAGE\n"
}
check_if_input_is_blank() {
if [[ "${@}" == "" ]]; then
printf "No package(s) specified.\n"
exit 1
fi
}
get_pkg_sources() {
pkgs=("${@}")
for p in $pkgs; do
source ${p}
getsource
done
}
mkpkg() {
pkgs=("${@}")
for p in $pkgs; do
source ${p}
buildpkg
installpkg
done
}
case $1 in
-h|--help)
usage "$@"
exit 0
;;
-v|--version)
printf "bldr v1.0.0\n"
printf "everest-build-tools v1.0.0\n"
exit 0
;;
-b|--build)
shift
check_if_input_is_blank "$@"
get_pkg_sources "$@"
mkpkg "$@"
;;
*)
usage_small "$@"
exit 1
esac
usage_small "$@"
exit 1

View File

@ -0,0 +1,2 @@
VER=1.0.0
TARGET=x86-musl

12
tools/mkimg Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
RELEASE_FILE=$(pwd)/everest-distinfo
if [ -f ${RELEASE_FILE} ]; then
source ${RELEASE_FILE}
else
printf "${RELEASE_FILE} does not exist.\n"
exit 1
fi
tar Jcfv ${1}
mv ${1}.tar.xz everestlinux-${VER}-${TARGET}-img.tar.xz

80
tools/mkskel Executable file
View File

@ -0,0 +1,80 @@
#!/bin/sh
# mkskel - create a filesystem layout
# (C) 2023 Everest Linux
# See the GNU GPL Version 3 for copyright details
ROOT_DIR=${2}
mkdirs() {
mkdir -pv ${ROOT_DIR}/{dev,home,mnt,proc,run,srv,sys,boot,etc,lost+found}
mkdir -pv ${ROOT_DIR}/{opt,root,var,tmp,include,share}
mkdir -pv ${ROOT_DIR}/glacier
for DIR in bin lib sbin; do
mkdir -pv ${ROOT_DIR}/${DIR}
mkdir -pv ${ROOT_DIR}/usr/${DIR}
done
case $(uname -m) in
x86_64)
ln -sv ${ROOT_DIR}/lib ${ROOT_DIR}/lib64
ln -sv ${ROOT_DIR}/usr/lib ${ROOT_DIR}/usr/lib64
;;
esac
mkdir -pv ${ROOT_DIR}/rescue
mkdir -pv ${ROOT_DIR}/rescue/{dev,mnt,proc,run,etc,lost+found}
mkdir -pv ${ROOT_DIR}/rescue/{root,var,tmp}
for DIR in bin lib sbin; do
mkdir -pv ${ROOT_DIR}/rescue/${DIR}
done
case $(uname -m) in
x86_64)
ln -sv ${ROOT_DIR}/rescue/lib ${ROOT_DIR}/rescue/lib64
;;
esac
}
helpmsg() {
printf "usage: ${0} [-h] [-d] DIRECTORY\n"
}
helpmsg_big() {
printf "${0} - create a filesystem layout\n"
printf "usage: ${0} [-h] [-d] DIRECTORY\n"
printf "\n"
printf "${0} {-h} Show this message\n"
printf "${0} {-d DIRECTORY} Create a filesystem layout in DIRECTORY\n"
printf "\n"
printf "This program is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
case $1 in
-h)
helpmsg_big "$@"
exit 0
;;
-d)
if [ "${2}" == "" ]; then
printf "you must specify a directory\n"
exit 1
fi
mkdirs "$@"
exit 0
;;
-*)
helpmsg "$@"
exit 1
;;
*)
helpmsg "$@"
exit 1
esac
helpmsg "$@"
exit 1

58
tools/prep Executable file
View File

@ -0,0 +1,58 @@
#!/bin/sh
TARGET_DIR=${2}
usage() {
printf "${0} - prepare a directory for system image creation\n"
printf "usage: ${0} [-h] [-v] [-d] DIRECTORY\n"
printf "\n"
printf "${0} {-h --help} Show this message\n"
printf "${0} {-v --version} Show the version\n"
printf "${0} {-d --dir} Prepare a directory\n"
printf "\n"
printf "prep is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
usage_small () {
printf "usage: ${0} [-h] [-v] [-d] DIRECTORY\n"
}
check_for_root() {
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "${0} must be run as root\n"
exit 1
fi
}
change_ownership() {
chown -Rv root:root ${2}
chgrp -v 13 ${2}/var/log/lastlog
}
case ${1} in
-h|--help)
usage "$@"
exit 0
;;
-v|--version)
printf "prep v1.0.0\n"
printf "everest-build-tools v1.0.0\n"
exit 0
;;
-d|--dir)
check_for_root "$@"
if [[ "${2}" == "" ]]; then
printf "No directory specified\n"
exit 1
fi
change_ownership "$@"
;;
*)
usage_small "$@"
exit 1
esac
usage_small "$@"
exit 1