summaryrefslogtreecommitdiff
path: root/psibuild
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2021-10-02 15:36:06 +0100
committerdavidovski <david@davidovski.xyz>2021-10-02 15:36:06 +0100
commitc4e0c314e6eac6964328c9c3daeaa232ea06e965 (patch)
tree3487ee837ea8927ceaf5c26fe54461422e01a21a /psibuild
parent5f7bf349b6280e52f6671e9fb02e0c530b167165 (diff)
rename
Diffstat (limited to 'psibuild')
-rwxr-xr-xpsibuild68
1 files changed, 68 insertions, 0 deletions
diff --git a/psibuild b/psibuild
new file mode 100755
index 0000000..567fd2b
--- /dev/null
+++ b/psibuild
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+usage () {
+ cat << EOF
+usage: $0 PSIBUILD
+EOF
+}
+
+BUILD_FILE=${@: -1}
+
+[[ $# = 0 ]] && usage && epsit 1
+[ -f "$FILE" ] && echo "$BUILD_FILE not found" && epsit 1
+
+source $BUILD_FILE
+
+PKG_NAME=$(basename $BUILD_FILE .psibuild)
+
+PSI_ROOT=$(pwd)
+PKGS_OUTPUT=$PSI_ROOT/psipkgs
+
+PKG_BUILD_DIR=$PSI_ROOT/tmp/$PKG_NAME
+PKG_DEST=$PKG_BUILD_DIR/package
+
+# make the directories
+mkdir -p $PKG_DEST
+cd $PKG_BUILD_DIR
+
+# fetch, build then package the package
+fetch
+build
+package
+
+
+# go back to root, make things easier
+cd $PSI_ROOT
+
+# bundle the package to a targz in the output dir
+mkdir -p $PKGS_OUTPUT
+
+PKG_FILE=$PKGS_OUTPUT/$PKG_NAME.psipkg
+
+tar -C $PKG_BUILD_DIR/package -czf $PKG_FILE ./
+
+# create info file
+PKG_INFO=$PKGS_OUTPUT/$PKG_NAME.psipkg.info
+
+echo "" > $PKG_INFO
+echo "NAME=$PKG_NAME" >> $PKG_INFO
+echo "PKG_FILE=$PKG_NAME.psipkg" >> $PKG_INFO
+echo "CHECKSUM=$(md5sum $PKG_FILE | awk '{ print $1 }')" >> $PKG_INFO
+echo "DATE=$(date)" >> $PKG_INFO
+echo "DEPS=(${DEPS[*]})" >> $PKG_INFO
+
+# sign the package
+PRIV_KEY=$PSI_ROOT/keychain/psi.pem
+PUB_KEY=$PSI_ROOT/keychain/psi.pub
+
+if [ -f "$PRIV_KEY" ]; then
+ echo "SIGNATURE=" >> $PKG_INFO
+ openssl dgst -sign $PRIV_KEY $PKG_FILE >> $PKG_INFO
+else
+ echo "SIGNATURE=">> $PKG_INFO
+ echo "unsigned">> $PKG_INFO
+ >&2 echo "WARNING! no private key: unsigned packages!"
+fi
+# clean up
+rm -rf $PKG_BUILD_DIR
+rmdir $PSI_ROOT/tmp