Skip to content
This repository has been archived by the owner on Jul 21, 2018. It is now read-only.

Commit

Permalink
New version compile with Java9
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Feb 16, 2018
1 parent 556c873 commit ef07f60
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 38 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
Expand All @@ -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.
82 changes: 51 additions & 31 deletions filebot-compiler.sh
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}"
Expand All @@ -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 $?)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}"
Expand All @@ -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}"
Expand All @@ -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")

Expand Down

0 comments on commit ef07f60

Please sign in to comment.