From c554c86a6ae091b15f41b97b682f574477d4bdd4 Mon Sep 17 00:00:00 2001 From: Charadon Date: Sat, 16 Jul 2022 21:53:48 -0400 Subject: Removed chroot support as that's out of scope of the project --- .gitignore | 3 +++ README | 1 - build.sh | 10 +++++++++- config.sh | 26 +++++++++++++++----------- dscip | 4 +++- post.sh | 20 +++++++++++++++++++- pre.sh | 13 ++++++++++++- 7 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 .gitignore mode change 100644 => 100755 config.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e42cb10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +LOCK +test/ +LAST_COMMIT diff --git a/README b/README index a9d2454..e0e48f9 100644 --- a/README +++ b/README @@ -27,6 +27,5 @@ How To Use: it. ================================================================================ To Do: - - Add chroot capabilities. - Better daemon-mode capabilities. - Better how-to instructions... diff --git a/build.sh b/build.sh index 044a189..b520046 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,12 @@ #!/bin/sh +set -eu + # Insert build commands in here. # -gmake -j4 +# If you're feeling particular paranoid, you can make it chroot here. # + +./configure +make -j4 +make DESTDIR=app install + +exit 0 diff --git a/config.sh b/config.sh old mode 100644 new mode 100755 index 321235b..b564913 --- a/config.sh +++ b/config.sh @@ -1,24 +1,28 @@ +#!/bin/sh # Variables that control the program. # # GIT Repo # -DSCIP_GITREPO="https://www.example.com/example/example.git" +export DSCIP_GITREPO="https://www.example.com/example/example.git" # GIT MODE: # # pull: Doesn't delete previous clone and just pulls changes. # # clone: Deletes previous clone, and creates a fresh clone. # -DSCIP_GITMODE="clone" +export DSCIP_GITMODE="clone" # Branch to check # -DSCIP_BRANCH="master" +export DSCIP_BRANCH="master" +# The directory where all the scripts are. By default tries to detect where # +# automatically. # WORKING_DIRECTORY="$(pwd -P)" +export WORKING_DIRECTORY # Commands to run before building. # -DSCIP_PRE_CMD="$WORKING_DIRECTORY/pre.sh" +export DSCIP_PRE_CMD="$WORKING_DIRECTORY/pre.sh" # Commands to run to build program. # -DSCIP_BUILD_CMD="$WORKING_DIRECTORY/build.sh" +export DSCIP_BUILD_CMD="$WORKING_DIRECTORY/build.sh" # Commands to run after building is done. # -DSCIP_POST_CMD="$WORKING_DIRECTORY/post.sh" +export DSCIP_POST_CMD="$WORKING_DIRECTORY/post.sh" # Daemon mode options # -DSCIP_DAEMON="false" # If daemon mode should be enabled or not. # -DSCIP_DAEMON_FORK="true" # If the daemon should run in the background. # -DSCIP_SLEEP="60" # How many seconds before the daemon re-runs itself. # +export DSCIP_DAEMON="false" # If daemon mode should be enabled or not. # +export DSCIP_DAEMON_FORK="true" # If the daemon should run in the background. # +export DSCIP_SLEEP="60" # How many seconds before the daemon re-runs itself. # # etc # -DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even # +export DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even # # if upstream has not updated. # -DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.log" # Output to file, default is stdout. +export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is stdout. diff --git a/dscip b/dscip index fb09c62..64b3833 100755 --- a/dscip +++ b/dscip @@ -16,7 +16,7 @@ # limitations under the License. # ################################################################################ -set -e +set -eu cd "$(dirname "$0")" . "$(pwd -P)/config.sh" @@ -101,10 +101,12 @@ run () { # Loads last commit hash if it exists. # if [ -f "$WORKING_DIRECTORY/LAST_COMMIT" ]; then LAST_COMMIT="$(cat "$WORKING_DIRECTORY/LAST_COMMIT")" + export LAST_COMMIT fi # Loads current commit hash # CURRENT_COMMIT=$(git ls-remote "$DSCIP_GITREPO" | awk "/refs\/(heads|tags)\/$DSCIP_BRANCH/{print \$1}") + export CURRENT_COMMIT # If LAST_COMMIT doesn't exist, that means it's a first run and we can go ahead and build. # # Or skip the commit check if DSCIP_DISREGARD_COMMIT_CHECK is set to true. diff --git a/post.sh b/post.sh index 1d048f9..93b324e 100755 --- a/post.sh +++ b/post.sh @@ -1,5 +1,23 @@ #!/bin/sh -# Execute commands after building. Like pushing to an FTP server. # +set -eu + +# Execute commands after building. Like pushing to an FTP server. # +# Example below. # + +# TAR up the program. # +bsdtar -a -cf program-$CURRENT_COMMIT.tar.gz app/ + +# Send the artifacts to an FTP server. # +ftp -in <