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