This repository has been archived by the owner on Jul 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
556c873
commit ef07f60
Showing
2 changed files
with
70 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Name: Filebot Compiler | ||
# Description: Compile latest commit Filebot project (by rednoah) | ||
# Author: Ivan Alejandro Marugan ([email protected]) | ||
|
||
################################################################### | ||
# Name: Filebot Compiler # | ||
# Description: Compile latest commit Filebot project (by rednoah) # | ||
# Author: Ivan Alejandro Marugan ([email protected]) # | ||
# Version: 1.0.0 # | ||
################################################################### | ||
set -e -u | ||
|
||
|
||
# COLOR MESSAGES | ||
OK=$(tput setaf 2) | ||
WARN=$(tput setaf 3) | ||
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") | ||
|
||
|