add emk - everest build system

This commit is contained in:
lw-everestlinux 2022-11-26 17:13:19 -05:00
parent c3f4f3d81c
commit 27db74632d
8 changed files with 346 additions and 99 deletions

5
src/emk/README Normal file
View File

@ -0,0 +1,5 @@
+---------------------------------------+
| emk - simple and concise build system |
+---------------------------------------+

55
src/emk/emk Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
# emk - simple and concise build system
# Copyright (C) 2022 Everest Linux Developers
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#. /etc/emk.conf
case $1 in
-h|--help)
printf "emk - simple and concise build system\n"
printf "usage: emk [help] [-h/--help] [-v/--version]\n"
printf "\n"
printf "emk {help} show available tasks from emkfile\n"
printf "emk {-h/--help} show this mesage and exit\n"
printf "emk {-v/--version} show the version and exit\n"
printf "\n"
printf "This program is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
exit 0
;;
-v|--version)
printf "${blue}emk v1.0.0${reset}\n"
exit 0
;;
help)
./emkfile showhelp
if [ "$?" != "0" ]; then
printf "emk ${red}ERR${reset} | failed to get help from emkfile.\n"
exit 1
fi
esac
# Check for root
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "emk ${yellow}WARN${reset} | not running emk as root\n"
printf "emk ${yellow}WARN${reset} | THIS MAY PRODUCE UNEXPECTED RESULTS\n"
printf "emk ${yellow}WARN${reset} | however, this is NOT an error\n"
printf "emk ${yellow}WARN${reset} | and should not be treated as such.\n"
else
printf "emk ${blue}INFO${reset} | running emk as root\n"
fi
./emkfile $2

111
src/emk/emkfile.template Normal file
View File

@ -0,0 +1,111 @@
#!/bin/sh
# emk - everest make - clear and concise build system
# for Everest Linux - build script template
# Output should follow this general format:
# emk INFO | output here
# emk WARN | output here
# emk ERR | output here
# Colored output should be impletemted where possible.
# In /etc/emk.conf, colors are defined by variable, ex:
# ${red} for errors
# ${yellow} for warnings
# ${blue} for general info
# ${reset} for removing colors
# Define working directory and source directory
# WORKING_DIR should not be changed.
# SRC_DIR should be changed to a directory which contains all
# source files and subdirectories
WORKING_DIR=$(pwd)
SRC_DIR=$(pwd)/../src # from working dir, go back and go into src
# Parse a local file containing settings for the installation
printf "emk ${blue}INFO${reset} | parsing install.conf\n"
. ${WORKING_DIR}/install.conf
if [ "$?" != 0 ]; then
printf "emk ${red}ERR${reset} | install.conf not found\n"
exit 1
fi
# Define functions for different tasks
### NECESSARY FUNCTIONS ################################################################
### default function ###
# $ emk make
# If package needs to be compiled from source code,
# put needed commands here, else leave output as is
compile_pkg() {
printf "emk ${yellow}WARN${reset} | no jobs to be done for task ''\n"
exit 0
}
### install function ###
# $ emk install
# This should be used to install binaries just compiled by emk,
# or prebuilt binaries
install_pkg() {
printf "emk ${yellow}WARN${reset} | no jobs to be done for task 'install'\n"
exit 0
}
### OPTIONAL FUNCTIONS #################################################################
### clean function ###
# $ emk clean
# Clean all files generated by other commands
clean_pkg() {
printf "emk ${yellow}WARN${reset} | no jobs to be done for task 'clean'\n"
exit 0
}
### distclean function ###
# $ emk distclean
# Clean all files not included in the source
# There are multiple ways of doing this -- experiment
# and see which works the best for you
distclean_pkg() {
printf "emk ${yellow}WARN${reset} | no jobs to be done for task 'distclean'\n"
exit 0
}
### custom functions ###
# Add any desired custom functions
# customfunc_pkg() {}
########################################################################################
# Command line flags
# These should not be modified unless adding support for custom funtions
case $1 in
help) # Put a list of all available tasks here
#printf "make - compile program\n"
#printf "install - install program\n"
#printf "clean - clean all files generated by make\n"
#printf "distclean - clean all files not in the source tree\n"
#exit 0
;;
make)
compile_pkg "$@"
exit 0
;;
install)
install_pkg "$@"
exit 0
;;
clean)
clean_pkg "$@"
exit 0
;;
distclean)
distclean_pkg "$@"
exit 0
;;
*)
printf "emk ${red}ERR${reset} | no such task exists\n"
exit 1
;;
esac

View File

@ -34,13 +34,13 @@ startsv() {
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue}starting service ${2}...${reset}\n"
${SRV_DIR}/${2}/${RUN}
printf "${blue}starting service $2...${reset}\n"
${SRV_DIR}/$2/${RUN}
if [ "$?" != "0" ]; then
printf "${red}service ${2} could not start${reset}\n"
printf "${red}service $2 could not start${reset}\n"
exit 1
fi
printf "${green}service ${2} started successfully${reset}\n"
printf "${green}service $2 started successfully${reset}\n"
exit 0
}
@ -49,13 +49,13 @@ stopsv() {
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue}stopping service ${2}...${reset}\n"
${SRV_DIR}/${2}/${STOP}
printf "${blue}stopping service $2...${reset}\n"
${SRV_DIR}/$2/${STOP}
if [ "$?" != "0" ]; then
printf "${red}service ${2} could not stop${reset}\n"
printf "${red}service $2 could not stop${reset}\n"
exit 1
fi
printf "${green}service ${2} stopped successfully${reset}\n"
printf "${green}service $2 stopped successfully${reset}\n"
exit 0
}
@ -64,13 +64,13 @@ restartsv() {
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue}restarting service ${2}...${reset}\n"
${SRV_DIR}/${2}/${STOP} && ${SRV_DIR}/${2}/${RUN}
printf "${blue}restarting service $2...${reset}\n"
${SRV_DIR}/$2/${STOP} && ${SRV_DIR}/$2/${RUN}
if [ "$?" != "0" ]; then
printf "${red}service ${2} could not restart${reset}\n"
printf "${red}service $2 could not restart${reset}\n"
exit 1
fi
printf "${green}service ${2} restarted successfully${reset}\n"
printf "${green}service $2 restarted successfully${reset}\n"
exit 0
}
@ -87,12 +87,15 @@ case $1 in
printver "$@"
;;
start)
preload
startsv "$@"
;;
stop)
preload
stopsv "$@"
;;
restartsv)
preload
restartsv "$@"
;;
*)

View File

@ -1,31 +0,0 @@
#!/bin/sh
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
printf "must be run as root\n"
exit 1
fi
WORKING_DIR=$(pwd)
printf "parsing install.conf\n"
source $WORKING_DIR/install.conf
if [ "$?" != 0 ]; then
printf "install.conf not found\n"
exit 1
fi
printf "installing executable\n"
mv $WORKING_DIR/gpc $PREFIX/bin
if [ "$?" != 0 ]; then
mv $WORKING_DIR/gpc $PREFIX
printf "directory $PREFIX/bin does not exist, moving to $PREFIX instead\n"
fi
printf "installing configuration files\n"
mv $WORKING_DIR/gpc.conf $CONFDIR
if [ "$?" != 0 ]; then
printf "$CONFDIR does not exist\n"
printf "this can be corrected by running:\n"
printf "# mkdir -pv $CONFDIR\n"
exit 1
fi
printf "finished installation\n"
exit 0

6
src/gpc/build.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
if [[ $(/usr/bin/id -u) != "0" ]]; then
printf "build script must be run as root\n"
exit 1
fi

View File

@ -1,9 +1,6 @@
#!/bin/sh
# Glacier package checker
/etc/gpc.conf
source $(pwd)/gpc.conf #remove before release
INSCRIPT=INSTALL.sh
UPSCRIPT=UPDATE.sh
RMSCRIPT=REMOVE.sh
@ -12,60 +9,90 @@ PKGINFO=*-pkginfo.json
TIMESTAMP=*.ts.sh
case $1 in
check)
printf " Searching for package directory...\n"
if [ -d "$2" ]; then
printf "$green $2 exists.$reset\n"
else
printf "$red $2 does not exist.$reset\n"
exit 1
fi
check_dir() {
printf "Searching for package directory...\n"
if [ -d "$2" ]; then
printf "${green}$2 exists.${reset}\n"
else
printf "${red}$2 does not exist.${reset}\n"
exit 1
fi
cd $2
printf "Searching for instruction scripts...\n"
if [ -f $INSCRIPT -a -f $UPSCRIPT -a -f $RMSCRIPT ]; then
printf "${green}Instruction scripts exist.${reset}\n"
else
printf "${red}Instruction scripts do not exist.${reset}\n"
exit 1
fi
printf "Searching for miscellaneous files...\n"
if [ -f $PKGINFO -a -f $TIMESTAMP ]; then
printf "${green}$2-pkginfo.json and $2.ts.sh exist.${reset}\n"
else
printf "${red}$2-pkginfo.json and $2.ts.sh do not exist.${reset}\n"
exit 1
fi
}
mkpkg() {
printf "${blue} Making package...${reset}\n"
cd $2
printf " Searching for instruction scripts in package directory...\n"
if [ -f $INSCRIPT -a -f $UPSCRIPT -a -f $RMSCRIPT ]; then
printf "$green Instruction scripts exist.$reset\n"
else
printf "$red Instruction scripts do not exist.$reset\n"
exit 1
fi
tar -czvf $2.tar.gz *
printf "${blue}Generating package checksum...${reset}\n"
cd ..
sha256sum $2/$2.tar.gz >> $2.checksum
printf "${green}Finished making package${reset}\n"
exit 0
}
printf " Searching for miscellaneous files...\n"
if [ -f $PKGINFO -a -f $TIMESTAMP ]; then
printf "$green $2.pkginfo and $2.ts.sh exist.$reset\n"
else
printf "$red $2.pkginfo and $2.ts.sh do not exist.$reset\n"
exit 1
fi
;;
mkpkg)
printf "$blue Making package...$reset\n"
cd $2
tar -czvf $2.tar.gz *
printf "$blue Creating timestamp...$reset\n"
sha256sum $2.tar.gz >> $2.checksum
if [ "$?" != "0" ]; then
printf "$red Failed to make package.$reset\n"
exit 1
fi
printf "$green Finished making package$reset\n"
exit 0
;;
helpmsg() {
printf "gpc - test and create Glacier compatible packages\n"
printf "usage: gpc [check] [mkpkg] [-h/--help] [-v/--version] pkg-dir\n"
printf "\n"
printf "gpc {-h|--help} show this message and exit\n"
printf "gpc {-v|--version} show the version and exit\n"
printf "gpc {check} check a package directory for compliance\n"
printf "gpc {mkpkg} create a package from a directory\n"
printf "\n"
printf "This program is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
exit 0
}
helpmsg_small() {
printf "usage: gpc [check] [mkpkg] [-h/--help] [-v/--version] pkg-dir\n"
exit 1
}
printver() {
printf "gpc v2.0.0\n"
exit 0
}
preload() {
. /etc/gpc.conf
if [ "$?" != "0" ]; then
printf "error while parsing gpc config file\n"
exit 1
fi
}
case $1 in
-h|--help)
printf "gpc - test and create Glacier packages\n"
printf "\n"
printf "gpc {-h|--help} show this message and exit\n"
printf "gpc {-v|--version} show the version and exit\n"
printf "gpc {check} check a package for errors\n"
printf "gpc {mkpkg} create a package from a directory\n"
printf "\n"
printf "This program is licensed under the GNU GPL v3.0\n"
printf "You should have recieved a copy along with this program.\n"
printf "If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>\n"
exit 0
helpmsg "$@"
;;
-v|--version)
printf "gpc v1.0.0\n"
exit 0
printver "$@"
;;
check)
check_dir "$@"
;;
mkpkg)
mkpkg "$@"
;;
*)
helpmsg_small "$@"
;;
esac

71
src/gpc/gpc.old Executable file
View File

@ -0,0 +1,71 @@
#!/bin/sh
# Glacier package checker
/etc/gpc.conf
source $(pwd)/gpc.conf #remove before release
INSCRIPT=INSTALL.sh
UPSCRIPT=UPDATE.sh
RMSCRIPT=REMOVE.sh
PKGINFO=*-pkginfo.json
TIMESTAMP=*.ts.sh
case $1 in
check)
printf " Searching for package directory...\n"
if [ -d "$2" ]; then
printf "$green $2 exists.$reset\n"
else
printf "$red $2 does not exist.$reset\n"
exit 1
fi
cd $2
printf " Searching for instruction scripts in package directory...\n"
if [ -f $INSCRIPT -a -f $UPSCRIPT -a -f $RMSCRIPT ]; then
printf "$green Instruction scripts exist.$reset\n"
else
printf "$red Instruction scripts do not exist.$reset\n"
exit 1
fi
printf " Searching for miscellaneous files...\n"
if [ -f $PKGINFO -a -f $TIMESTAMP ]; then
printf "$green $2.pkginfo and $2.ts.sh exist.$reset\n"
else
printf "$red $2.pkginfo and $2.ts.sh do not exist.$reset\n"
exit 1
fi
;;
mkpkg)
printf "$blue Making package...$reset\n"
cd $2
tar -czvf $2.tar.gz *
printf "$blue Creating timestamp...$reset\n"
sha256sum $2.tar.gz >> $2.checksum
if [ "$?" != "0" ]; then
printf "$red Failed to make package.$reset\n"
exit 1
fi
printf "$green Finished making package$reset\n"
exit 0
;;
-h|--help)
printf "gpc - test and create Glacier packages\n"
printf "\n"
printf "gpc {-h|--help} show this message and exit\n"
printf "gpc {-v|--version} show the version and exit\n"
printf "gpc {check} check a package for errors\n"
printf "gpc {mkpkg} create a package from a directory\n"
printf "\n"
printf "This program is licensed under the GNU GPL v3.0\n"
printf "You should have recieved a copy along with this program.\n"
printf "If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>\n"
exit 0
;;
-v|--version)
printf "gpc v1.0.0\n"
exit 0
esac