From 40ddc92c03e5fa0bdf9b082cf44aabd3116ba738 Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Tue, 7 Nov 2023 12:52:49 -0500 Subject: [PATCH] update 11/7/23 --- README | 2 +- tools/commit_msg | 1 - tools/epush | 22 ---- tools/project-init/everest-project-init | 134 ++++++++++++++++++++++++ tools/spi/spi | 14 +++ 5 files changed, 149 insertions(+), 24 deletions(-) delete mode 100644 tools/commit_msg delete mode 100755 tools/epush create mode 100755 tools/project-init/everest-project-init diff --git a/README b/README index cc444b7..eb7cd87 100644 --- a/README +++ b/README @@ -10,7 +10,7 @@ This repository contains scripts used to create Everest Linux images. mkskel - create an Everest Linux compliant filesystem skeleton bldr - build a binary package from an Everest package file -install - package agnostic installation script prep - prepare a directory for image creation mkimg - create an image spi - install a package to a directory +everest-project-init - initialize a project from a template diff --git a/tools/commit_msg b/tools/commit_msg deleted file mode 100644 index 45b983b..0000000 --- a/tools/commit_msg +++ /dev/null @@ -1 +0,0 @@ -hi diff --git a/tools/epush b/tools/epush deleted file mode 100755 index aad88a9..0000000 --- a/tools/epush +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Simple wrapper script around git to easily push an update - -COMMIT_MSG=${1} -BRANCH=$(git rev-parse --abbrev-ref HEAD) - -printf "Checking if Git repository is present...\n" - -git rev-parse --is-inside-work-tree -if [ "$?" != 0 ]; then - printf "Not a Git repository.\n" - exit 1 -fi - -if [ "${COMMIT_MSG}" = "" ]; then - printf "No commit message.\n" - exit 1 -fi - -git add * -git commit -m ${COMMIT_MSG} -git push origin ${BRANCH} diff --git a/tools/project-init/everest-project-init b/tools/project-init/everest-project-init new file mode 100755 index 0000000..faca1ad --- /dev/null +++ b/tools/project-init/everest-project-init @@ -0,0 +1,134 @@ +#!/bin/sh + +# everest-project-init - initialize a project +# +# Copyright (C) 2023 Everest Linux +# +# everest-project-init 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. +# +# everest-project-init 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 everest-project-init. If not, see . + +red="\033[1;31m" +green="\033[1;32m" +yellow="\033[1;33m" +blue="\033[1;34m" +reset="\033[m" +check="\xE2\x9C\x93" + +# +# PARAMETERS: +# "usage: ${0} [-h] [-v] [-i] [-l] DIR LANG \n" +# ^ ^______________^ ^ ^ +# 0 1 2 3 +# + +usage () { + printf "${0} - Initialize a project\n" + printf "usage: ${0} [-h] [-v] [-i] [-l] DIR LANG\n" + printf "\n" + printf "${0} {-h --help} Show this message\n" + printf "${0} {-v --version} Show the current version\n" + printf "${0} {-i --init} Initialize in DIR with template LANG\n" + printf "${0} {-l --list} List all supported language templates\n" + printf "\n" + printf "Ensure DIR is a complete directory path.\n" + printf "\n" + printf "everest-project-init is free software.\n" + printf "See the GNU GPL version 3 for details.\n" +} + +usage_small() { + printf "usage: ${0} [-h] [-v] [-i] [-l] DIR LANG\n" +} + +mkprojectdir() { + printf "${blue}[i]${reset} Creating project directory...\n" + mkdir ./${2} + printf "${green}[${check}]${reset} Directory created.\n" +} + +mkskel() { + printf "${blue}[i]${reset} Creating project directory skeleton...\n" + case ${3} in + "C") + mkdir ${2}/{src,include} + ;; + "Bash") + mkdir ${2}/{src,install,man} + mkdir ${2}/src/{bin,etc,man} + esac + printf "${green}[${check}]${reset} Project directory skeleton created.\n" +} + + +dload_license() { + LICENSE_URL="https://gnu.org/licenses/gpl-3.0.txt" + printf "${blue}[i]${reset} Using license 'GPL 3' for this project.\n" + printf "${blue}[i]${reset} Downloading license for project...\n" + curl ${LICENSE_URL} -o ${2}/LICENSE + printf "${green}[${check}]${reset} License downloaded.\n" +} + +mkheader() { + printf "${blue}[i]${reset} Generating file header...\n" + ROOT_URL="https://git.everestlinux.org/EverestLinux/project-init-file-headers/raw/branch/main" + case ${3} in + "C") + curl -O -J ${ROOT_URL}/template.c + if [ "$?" != 0 ]; then + printf "${red}[x]${reset} Curl exited with non-zero status.\n" + exit 1 + fi + ;; + "Bash") + curl -O -J ${ROOT_URL}/template.sh + if [ "$?" != 0 ]; then + printf "${red}[x]${reset} Curl exited with non-zero status.\n" + exit 1 + fi + ;; + esac + printf "${blue}[i]${reset} File header generated successfully.\n" +case $1 in + -h|--help) + usage "$@" + exit 0 + ;; + -v|--version) + printf "everest-project-init v0.1rc\n" + exit 0 + ;; + -i|--init) + mkprojectdir "$@" + mkskel "$@" + dload_license "$@" + mkheader "$@" + printf "${green}[${check}]${reset} Project generated successfully.\n" + exit 0 + ;; + -l|--list) + printf "Available templates:\n" + printf "C\n" + printf "Bash/POSIX sh\n" + ;; + -*|--*) + usage_small "$@" + exit 1 + ;; + *) + usage_small "$@" + exit 1 + ;; +esac + +usage_small "$@" +exit 1 diff --git a/tools/spi/spi b/tools/spi/spi index 41d8830..588d228 100755 --- a/tools/spi/spi +++ b/tools/spi/spi @@ -84,6 +84,20 @@ install_share() { fi } +install_extra() { + if [ -f "*" ]; then + printf "Extra files detected.\n" + for f in ${DIR}; do + read -p "$(printf "Install file '${f}'? ")" -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]]; then + cp ${f} ${TARGET} + elif [[ $REPLY =~ ^[Nn]$ ]]; then + printf "Skipping file '${f}'.\n" + fi + done + fi +} + case $1 in -h) usage "$@"