diff options
author | Charadon <dev@iotib.net> | 2022-07-16 21:53:48 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-07-16 21:53:48 -0400 |
commit | c554c86a6ae091b15f41b97b682f574477d4bdd4 (patch) | |
tree | 0c7fdf6dd3ce7649cc08b256ea275e2db1117652 | |
parent | c9a15281b7328742a59c46eb3171754ce9e30bff (diff) | |
download | dscip-c554c86a6ae091b15f41b97b682f574477d4bdd4.tar.gz |
Removed chroot support as that's out of scope of the project
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | build.sh | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | config.sh | 26 | ||||
-rwxr-xr-x | dscip | 4 | ||||
-rwxr-xr-x | post.sh | 20 | ||||
-rwxr-xr-x | pre.sh | 13 |
7 files changed, 61 insertions, 16 deletions
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 index 321235b..b564913 100644..100755 --- 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 <<EOF +open 192.168.255.255 +user username p@ssw0rd +mkdir $CURRENT_COMMIT +cd $CURRENT_COMMIT +put program-$CURRENT_COMMIT.tar.gz program-$CURRENT_COMMIT.tar.gz +put $WORKING_DIRECTORY/output.txt $CURRENT_COMMIT-output.txt +close +bye +EOF exit 0 diff --git a/pre.sh b/pre.sh index 0d614ed..824ea8c 100755 --- a/pre.sh +++ b/pre.sh @@ -1,5 +1,16 @@ #!/bin/sh +set -eu -# Execute commands before building. # +# Execute commands before building. # +# Below is an example. # + +# Build user implied to have sudo access to apt update and upgrade # +sudo apt update +sudo apt upgrade + +# Including assets with game code is usually a bad idea, so we grab the assets # +# from a mirror. # +wget https://www.example.com/project/game_assets.zip +unzip game_assets.zip exit 0 |