From ef07f60773b060673a70beec6274d8112edcc78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Alejandro=20Marug=C3=A1n?= Date: Fri, 16 Feb 2018 13:48:26 +0100 Subject: [PATCH] New version compile with Java9 --- README.md | 26 ++++++++++---- filebot-compiler.sh | 82 ++++++++++++++++++++++++++++----------------- 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 6147c1c..6ed7073 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # Filebot Compiler -Filebot Compiler is a simply script to compiler the latest version of [Filebot](https://github.com/filebot/) (by @rednoah). +Filebot Compiler is a simply script to compiler the latest version of [Filebot](https://github.com/filebot/) (by [@rednoah](https://github.com/rednoah)). + +'''Version''': 1.0.0 ## Content The script installs all requirements (packages, dirs, compile-software, downloads latest repos...) to compile automatically the latest commit. ### Script Steps 1. Install Packages (root privileges) -2. Download Repos +2. Download and Update Repos 3. Install Dependencies -4. Compile +4. Compile Filebot ## Execute ``` @@ -21,16 +23,26 @@ chmod +x filebot-compiler.sh ./filebot-compiler.sh ``` -### Checked in this platforms: -* Debian GNU/Linux 9.2 (stretch) +### Checked in this platforms +* Debian GNU/Linux 9.X (stretch) * Ubuntu 16.04 +## Dependences +* jq: parser json +* git: tool to download the repository +* curl: to check the new commit +* apache-ant: tool to compile Filebot +* dirmngr: takes care of accessing the OpenPGP keyservers +* oracle-java: libraries to compile Filebot (by [webupd8team-java](http://www.webupd8.org)) +* openjfx: libraries to compile Filebot +* apache-ivy: to download the dependencies of Filebot build + ## TODO - [ ] Menu - [ ] Trace log ## Other information -If you wan't to compile, you can download in my website: [https://filebot.ialejandro.rocks](https://filebot.ialejandro.rocks). The latest version will automatically appear. +If you wan't to compile, you can download in my website: [https://filebot.ialejandro.rocks](https://filebot.ialejandro.rocks) ('''ONLY WORKS WITH JAVA9'''). The latest version will automatically appear. ## Contributing -I would be happy to upgrade the code. You are free to collaborate and upgrade everything. Thanks @sbr481 for you help. +I would be happy to upgrade the code, you are free to collaborate and improve my code. Thanks [@sbr481](https://github.com/sbr481) for you help. diff --git a/filebot-compiler.sh b/filebot-compiler.sh index 7d5e8b9..fe96e79 100755 --- a/filebot-compiler.sh +++ b/filebot-compiler.sh @@ -1,12 +1,12 @@ #!/bin/bash - -# Name: Filebot Compiler -# Description: Compile latest commit Filebot project (by rednoah) -# Author: Ivan Alejandro Marugan (hello@ialejandro.rocks) - +################################################################### +# Name: Filebot Compiler # +# Description: Compile latest commit Filebot project (by rednoah) # +# Author: Ivan Alejandro Marugan (hello@ialejandro.rocks) # +# Version: 1.0.0 # +################################################################### set -e -u - # COLOR MESSAGES OK=$(tput setaf 2) WARN=$(tput setaf 3) @@ -14,20 +14,27 @@ ERR=$(tput setaf 1) NC=$(tput sgr0) # VARS -LOGDIR="${HOME}/build_log_filebot" -LOGFILE="${LOGDIR}/filebot_$(date +%d_%m_%Y).log" +WORKDIR="${HOME}" +LOGDIR="${WORKDIR}/logs" +LOGFILE="${LOGDIR}/filebot_$(date +%Y%m%d).log" # PARAMS APACHE_IVY_FILE="http://ant.apache.org/ivy/history/latest-milestone/samples/build.xml" -APACHE_IVY_SOURCE="${HOME}/apache-ivy" -FILEBOT_CONFIG="${HOME}/.filebot" -FILEBOT_SOURCE="${HOME}/filebot" +APACHE_IVY_SOURCE="${WORKDIR}/apache-ivy" +FILEBOT_CONFIG="${WORKDIR}/.filebot" +FILEBOT_SOURCE="${WORKDIR}/filebot" FILEBOT_API="https://api.github.com/repos/filebot/filebot" FILEBOT_REPO="https://github.com/filebot/filebot.git" SLF4J_API_VERSION="1.7.9" +JAVA_VERSION="8" # Dirs and persistence commits create_dirs() { + # Work dir + if [[ ! -d "${WORKDIR}" ]]; then + mkdir -p "${WORKDIR}" + fi + # Config dir if [[ ! -d "${FILEBOT_CONFIG}" ]]; then mkdir -p "${FILEBOT_CONFIG}" @@ -46,34 +53,47 @@ create_dirs() { # Packages necessary to compile install_packages() { - PACKAGES="jq git curl ant" + PACKAGES="jq git curl ant dirmngr" # USER WITH PRIVILEGES if [[ ${EUID} != 0 ]]; then echo "[${WARN}WARNING${NC}] You need root privileges to update and install packages: ${PACKAGES}. Enter you password to continue:" fi # Update repositories - su - root -c "apt-get -q=2 update" + apt-get -q=2 update # Packages for SOFT in $PACKAGES; do EXISTS=$(which ${SOFT} >/dev/null; echo $?) if [[ ${EXISTS} != 0 ]]; then echo "[${WARN}WARNING${NC}] ${SOFT} isn't installed. Installing..." - su - root -c "apt-get -qq install ${SOFT}" &>/dev/null + apt-get -qq install ${SOFT} &>/dev/null else echo "[${OK}OK${NC}] ${SOFT} installed." fi done - # Java packages (OpenJDK and OpenJFX) - #EXISTS=$(dpkg -l | grep openjdk-8-jdk >/dev/null; echo $?) - #if [[ ${EXISTS} != 0 ]]; then - # echo "[${WARN}WARNING${NC}] open-jdk and openjfx aren't installed. Installing..." - # su - root -c "apt-get -qq install openjdk-8-jdk openjfx" &>/dev/null - #else - # echo "[${OK}OK${NC}] open-jdk and openjfx installed." - #fi + # Java packages (Oracle Java Webup8team) + EXISTS=$(dpkg -l | grep oracle-java${JAVA_VERSION}-installer >/dev/null; echo $?) + if [[ ${EXISTS} != 0 ]]; then + echo "[${WARN}WARNING${NC}] oracle-java${JAVA_VERSION} aren't installed. Installing..." + echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" > /etc/apt/sources.list.d/webupd8team-java.list + echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" >> /etc/apt/sources.list.d/webupd8team-java.list + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 + echo oracle-java${JAVA_VERSION}-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections + apt-get -qq install --allow-unauthenticated oracle-java${JAVA_VERSION}-installer oracle-java${JAVA_VERSION}-set-default &>/dev/null + else + echo "[${OK}OK${NC}] oracle-java${JAVA_VERSION} installed." + fi + + # OpenJFX + EXISTS=$(dpkg -l | grep openjfx >/dev/null; echo $?) + if [[ ${EXISTS} != 0 ]]; then + echo "[${WARN}WARNING${NC}] openjfx aren't installed. Installing..." + apt-get -qq install --no-install-recommends openjfx &>/dev/null + else + echo "[${OK}OK${NC}] openjfx installed." + fi # Apache Ivy EXISTS=$(ls /usr/share/ant/lib/ivy.jar &>/dev/null; echo $?) @@ -82,12 +102,12 @@ install_packages() { mkdir -p "${APACHE_IVY_SOURCE}" echo "[${OK}OK${NC}] Download new changes in Apache Ivy repository..." wget -qP "${APACHE_IVY_SOURCE}" "${APACHE_IVY_FILE}" - ant -S -buildfile "${APACHE_IVY_SOURCE}" + ant -S -d -v -buildfile "${APACHE_IVY_SOURCE}" -logfile ${LOGDIR}/apache-ant-copmpile-ivy-$(date +%Y%m%d).log mv "${APACHE_IVY_SOURCE}/ivy/ivy.jar" "/usr/share/ant/lib/" fi } -# Download filebot repository +# Download Filebot repository download() { # Download repo or new changes if [[ -d ${FILEBOT_SOURCE} ]]; then @@ -109,7 +129,7 @@ download() { install_dependencies() { echo "[${OK}OK${NC}] Downloads Filebot project dependencies..." # Download dependencies ivy.xml - ant -S -logfile ${LOGDIR}/apache_ant_$(date +%d_%m_%Y).log resolve -buildfile "${FILEBOT_SOURCE}" &>/dev/null + ant -S -v -d -logfile ${LOGDIR}/apache-ant-dependencies-$(date +%Y%m%d).log resolve -buildfile "${FILEBOT_SOURCE}" &>/dev/null # Download slf4j-api and move if [[ ! -f "${FILEBOT_SOURCE}/dist/lib/slf4j-api.jar" ]]; then @@ -129,17 +149,17 @@ compile() { echo "[${OK}OK${NC}] Compiling Filebot (${COMMIT})..." # Compile starts - ant -S -logfile ${LOGDIR}/apache_ant_$(date +%d_%m_%Y).log -buildfile "${FILEBOT_SOURCE}" &>/dev/null + ant -S -v -d -logfile ${LOGDIR}/apache-ant-compile-$(date +%Y%m%d).log -buildfile "${FILEBOT_SOURCE}" &>/dev/null # Check compile - if [[ -d ${HOME}/filebot ]]; then + if [[ -d ${WORKDIR}/filebot ]]; then cp ${FILEBOT_SOURCE}/dist/*.jar "${FILEBOT_SOURCE}/dist/Filebot.jar" VERSION=$(java -jar "${FILEBOT_SOURCE}/dist/Filebot.jar" -version | awk '{ print $2 }') - mv "${FILEBOT_SOURCE}/dist/Filebot.jar" "${HOME}/Filebot_${VERSION}_(${COMMIT}).jar" + mv "${FILEBOT_SOURCE}/dist/Filebot.jar" "${WORKDIR}/Filebot_${VERSION}_(${COMMIT}).jar" # Success and clean Apache Ant build ant clean -S -buildfile "${FILEBOT_SOURCE}" - summary "${HOME}/Filebot_${VERSION}_(${COMMIT}).jar" "${VERSION}" "${COMMIT}" + summary "${WORKDIR}/Filebot_${VERSION}_(${COMMIT}).jar" "${VERSION}" "${COMMIT}" else # Fail ant clean -S -buildfile "${FILEBOT_SOURCE}" @@ -150,7 +170,7 @@ compile() { # Summary summary() { echo "" - if [[ -f "${1}" ]]; then + if [[ -f ${1} ]]; then echo "- Compile: ${OK}Success!${NC}" echo "- Version: Filebot ${2} (${3})" echo "- File path: ${1}" @@ -167,10 +187,10 @@ remove_dirs() { } ###################### MAIN - install_packages create_dirs +# Check proyect NEW_REV=$(curl -s -H 'Accept: application/vnd.github.v3+json' ${FILEBOT_API}/commits | jq -r .[0].sha) LAST_REV=$(cat "${FILEBOT_CONFIG}/commits_versions")