wire-build.sh: Added option to clone repo

This commit is contained in:
mollusk 2017-08-30 10:08:29 -07:00
parent 5dd7a9134e
commit e46c75ccd9

View File

@ -1,9 +1,11 @@
#!/bin/bash
APP="wire-desktop"
NPM_DIR="/usr/bin/npm"
BIN_DIR="/home/${USER}/wire-packages"
PACKAGE_DEFAULT_DIR="$(pwd)/wrap/dist"
SUPER_USER_CMD="sudo"
REPO_URL="https://github.com/wireapp/${APP}.git"
# Colors
RED='\033[0;31m'
@ -25,6 +27,15 @@ if [[ $EUID -eq 0 ]]; then
exit 1
fi
check_repo(){
if [ ! -d ${APP} ];then
git clone ${REPO_URL}
elif [ -d .git ];then
printf "\n${LRED}This is already a Git repository!${NC}\n"
fi
}
check_sudo(){
if [ ! -f /usr/bin/sudo ];then
SUPER_USER_CMD="su -c"
@ -38,7 +49,7 @@ apt_install(){
}
dnf_install(){
local PACKAGES='rpm-build rpmdevtools make nodejs npm git'
local PACKAGES='rpm-build rpmdevtools make nodejs npm nss libXScrnSaver git'
printf "${LCYAN}Fetching dependencies${NC}\n\n"
${SUPER_USER_CMD} dnf install ${PACKAGES}
@ -89,7 +100,7 @@ build_deb(){
npm install
npm update
npm install grunt
${SUPER_USER_CMD} grunt 'clean:linux' 'update-keys' 'release-prod'
${SUPER_USER_CMD} grunt 'clean:linux' 'update-keys' 'release-prod' 'bundle'
${SUPER_USER_CMD} grunt --arch=${ARCH} --target=${TARGET} 'electronbuilder:linux_other'
${SUPER_USER_CMD} mv -v ${PACKAGE_DEFAULT_DIR}/*.${TARGET} ${BIN_DIR}
}
@ -103,9 +114,9 @@ build_rpm(){
npm install
npm update
npm install grunt
${SUPER_USER_CMD} grunt 'clean:linux' 'update-keys' 'release-prod'
${SUPER_USER_CMD} grunt --arch=${ARCH} --target=${TARGET} 'electronbuilder:linux_other'
${SUPER_USER_CMD} mv -v ${PACKAGE_DEFAULT_DIR}/*.${TARGET} ${BIN_DIR}
grunt 'clean:linux' 'update-keys' 'release-prod'
grunt --arch=${ARCH} --target=${TARGET} 'electronbuilder:linux_other'
mv -v ${PACKAGE_DEFAULT_DIR}/*.${TARGET} ${BIN_DIR}
}
git_pull(){
@ -132,13 +143,17 @@ main(){
rpm | -r) check_deps && git_pull && build_rpm
;;
clone | -c) check_repo
;;
*)
printf "\n\n"
printf "Usage: $0 [-a/all | -d/deb | -r/rpm ]\n\n"
printf " -a | all build all package formats\n"
printf " -d | deb build only DEB package format\n"
printf " -r | rpm build only RPM package format\n\n"
printf " -r | rpm build only RPM package format\n"
printf " -c | clone clone 'wire-desktop' from Github\n\n"
;;
esac