diff --git a/src/build.npm.sh b/src/build.npm.sh index dabb95e..c1d82ec 100755 --- a/src/build.npm.sh +++ b/src/build.npm.sh @@ -2,13 +2,15 @@ set -e +NODE_VERSION=$1 + apt-get update apt-get -qq -y --no-install-recommends install curl jq ca-certificates git g++ gcc make clang wget xz-utils python-is-python3 sudo python3-minimal python3-distutils mkdir build_node cd build_node/ || exit -wget https://nodejs.org/dist/v16.13.0/node-v16.13.0.tar.xz -tar xf node-v16.13.0.tar.xz -mv node-v16.13.0 node +wget https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION.tar.xz +tar xf node-$NODE_VERSION.tar.xz +mv node-$NODE_VERSION node cd node || exit ./configure make -j4 diff --git a/src/build.sh b/src/build.sh index 8cc0ff8..743246f 100755 --- a/src/build.sh +++ b/src/build.sh @@ -7,8 +7,7 @@ apt-get -y --no-install-recommends install git jq imagemagick curl build-essenti npm install yarn --global -git clone https://github.com/VSCodium/vscodium.git -cd vscodium/ || exit +cd "${1:-vscodium}" || exit sed '/create_appimage\.sh/d' -i build.sh diff --git a/src/getsauce.sh b/src/getsauce.sh new file mode 100755 index 0000000..dd334df --- /dev/null +++ b/src/getsauce.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +set -e + +if [ $# -eq 0 ]; then + echo "No arguments provided. Aborting..." + exit 1 +fi + +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "usage: ./getsauce.sh [-h] [mode [checkout]] + +Retrieves the source for you. + +Possible values for the arguments: + +mode git, github-tar +URL url of the repo +repoName name of the repo with user/org included (e.g. username/repo or organization/repo) +checkout tag, branch or complete hash of a commit + +Dependencies: curl jq ca-certificates git +" + exit 0 +fi + +if [ $# -lt 2 ]; then + echo "Arguments \"mode\" and \"URL/repoName\" not provided. Aborting..." + exit 1 +fi + + +GET_SRC_MODE=$1 +URL_REPONAME=$2 +[ ! -z ${3+x} ] && CHECKOUT=$3 +[ -z ${REPO_PATH+x} ] && REPO_PATH="project" +SRC_DIR_PATH="./" +TMP_DIR="tmp_extract" + +if [ $GET_SRC_MODE = "github-tar" ]; then + mkdir "${TMP_DIR}" + curl --silent --fail -L "https://api.github.com/repos/${URL_REPONAME}/tarball/${CHECKOUT}" -o - | tar xvz -f - -C "$SRC_DIR_PATH" || rm -rf "${TMP_DIR}" && exit 1 + mv "${TMP_DIR}"/* "${REPO_PATH}/" +elif [ $GET_SRC_MODE = "git" ]; then + TMP_POSITION="${PWD}" + git clone "${URL_REPONAME}" "${REPO_PATH}" + cd "${REPO_PATH}" + [ ! -z ${CHECKOUT+x} ] && git checkout "${CHECKOUT}" + cd "${TMP_POSITION}" +else + echo "Not valid mode" + exit 1 +fi diff --git a/src/main.sh b/src/main.sh index a66ef2a..8885068 100755 --- a/src/main.sh +++ b/src/main.sh @@ -2,12 +2,44 @@ set -e -echo "Building node..." -./build.npm.sh -#./install.npm.thirdparty.sh && sudo apt-get -qq -y --no-install-recommends install python-is-python3 +echo "Updating apt..." +apt-get -qq update + +echo "Installing get tools..." +apt-get -qq -y --no-install-recommends install curl jq ca-certificates git > /dev/null + +REPO_NAME="VSCodium/vscodium" +REPO_URL="https://github.com/${REPO_NAME}.git" + +if [ -z ${1+x} ]; then + echo "No release selected, selecting the latest..." + CHECKOUT="$(curl --silent --fail --show-error "https://api.github.com/repos/${REPO_NAME}/releases/latest" | jq -r .tag_name)" + echo "Latest release: ${CHECKOUT}" +else + CHECKOUT="${1}" + echo "Release selected: ${CHECKOUT}" +fi + +echo "Getting the source..." +REPO_PATH=vscodium ./getsauce.sh "git" \ + "${REPO_URL}" \ + "${CHECKOUT}" + +NODE_VERSION="$(cat project/.nvmrc)" + +echo "Checking if node is already installed..." +if command -v node; then + echo "Node already installed." + node --version +else + echo "Node not installed." + echo "Building node..." + ./build.npm.sh $NODE_VERSION + #./install.npm.thirdparty.sh && sudo apt-get -qq -y --no-install-recommends install python-is-python3 +fi echo "Building VSCodium..." -./build.sh +./build.sh "$REPO_PATH" echo "Package(s) deploy..." DIST_DIR="/srv/build/vscodium/vscode/.build/linux/deb/amd64/deb"