Skip to content

Commit

Permalink
Merge pull request #1 from endlessm/T14332
Browse files Browse the repository at this point in the history
T14332
  • Loading branch information
Roddy Shuler committed Feb 3, 2017
2 parents 6096f14 + 8195878 commit e920bc6
Show file tree
Hide file tree
Showing 20 changed files with 539 additions and 543 deletions.
33 changes: 28 additions & 5 deletions apply_extra
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
#!/bin/sh

mkdir flash-player
tar zxf flash-player.tar.gz -C flash-player
# Install Firefox binaries

mkdir -p lib/mozilla/plugins
cp flash-player/libflashplayer.so lib/mozilla/plugins
# Extracts into the 'firefox' folder
tar xjf firefox.tar.bz2
rm firefox.tar.bz2

rm -rf flash-player flash-player.tar.gz
FIREFOX_DIR=$(pwd)/firefox

# Install languages

# Retrieve the extension id for an addon from its install.rdf
# This function is taken from http://kb.mozillazine.org/Determine_extension_ID
get_extension_id() {
unzip -qc $1 install.rdf | xmlstarlet sel \
-N rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# \
-N em=http://www.mozilla.org/2004/em-rdf# \
-t -v \
"//rdf:Description[@about='urn:mozilla:install-manifest']/@em:id"
}

EXTENSIONS_DIR=${FIREFOX_DIR}/distribution/extensions
mkdir -p ${EXTENSIONS_DIR}
for addon in $(ls *.xpi); do
mv "${addon}" "${EXTENSIONS_DIR}/$(get_extension_id ${addon}).xpi"
done

# Override preferences
PREFERENCES_DIR=${FIREFOX_DIR}/browser/defaults/preferences
mkdir -p ${PREFERENCES_DIR}
ln -s /app/cache/mozilla/endless-default-prefs.js ${PREFERENCES_DIR}
8 changes: 8 additions & 0 deletions binarydeb-Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all:
true

install:
ar x *.deb
tar xvf data.tar.*
mkdir -p /app/bin
install usr/bin/* /app/bin
2 changes: 2 additions & 0 deletions endless-default-prefs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Overridden preferences by Endless OS
pref("intl.locale.matchOS", true);
14 changes: 8 additions & 6 deletions firefox-Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# File is run at the end of the flatpak-build

all:
true

install:
echo Hi there!
# install apply_extra /app/bin
# install firefox.sh /app/bin/firefox
# cp /usr/bin/ar /app/bin
mkdir -p /app/bin
install apply_extra /app/bin
install firefox.sh /app/bin/firefox
install -m 755 firefox-plugins-installer /app/bin
mkdir -p /app/share/applications/
install -m 644 org.mozilla.Firefox.desktop /app/share/applications/
mkdir -p /app/cache/mozilla/
install -m 644 endless-default-prefs.js /app/cache/mozilla/
31 changes: 0 additions & 31 deletions firefox-extension-dir.patch

This file was deleted.

27 changes: 0 additions & 27 deletions firefox-makeinstall.patch

This file was deleted.

152 changes: 152 additions & 0 deletions firefox-plugins-installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/bin/bash -e
# firefox-plugins-installer - Download and install the JAVA and Flash plugins.
# Copyright (C) 2017 Endless Mobile, Inc.
#
# Authors:
# Joaquim Rocha <jrocha@endlessm.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

DEST_DIR=${XDG_DATA_HOME}/firefox-plugins
JAVA_DIR=${DEST_DIR}/java
FLASH_DIR=${DEST_DIR}/flash
PLUGINS_DIR=~/.mozilla/plugins
WGET_COMMAND="wget -c --tries=5"
CACHE_DIR=${XDG_CACHE_HOME}

exit_with_error() {
echo $1
exit 1
}

JAVA_BUILD=8u112-b15
JAVA_VERSION=`echo ${JAVA_BUILD} | cut -f 1 -d -`
JAVA_FILENAME=jre-${JAVA_VERSION}-linux-x64.tar.gz
JAVA_FILE_PATH=${CACHE_DIR}/${JAVA_FILENAME}
JAVA_URL_FILENAME=http://download.oracle.com/otn-pub/java/jdk/${JAVA_BUILD}/${JAVA_FILENAME}
JAVA_SHA256SUM=94053c6aa4d672b728c7788fb7d2676e5c6d7e7fcdbc1c86beaa796a083b4e5b
JAVA_LINK=${PLUGINS_DIR}/libnpjp2.so

# While the following would be a faster download of the current version,
# previous versions are often removed from the server, so it is safest
# for an automated script to use the stable version in the archive
# http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.643/install_flash_player_11_linux.x86_64.tar.gz
FLASH_VERSION=11.2.202.644
FLASH_SHA256SUM=aba0e2f5940fc2588357e93f7bad84a0db51792b2f2bd1d24be9ef491e87c041
FLASH_FILENAME=fp_${FLASH_VERSION}_archive.zip
FLASH_FILE_PATH=${CACHE_DIR}/${FLASH_FILENAME}
FLASH_URL_FILENAME=http://download.macromedia.com/pub/flashplayer/installers/archive/${FLASH_FILENAME}
FLASH_LINK=${PLUGINS_DIR}/libflashplayer.so

download_java() {
echo "Downloading ${JAVA_FILENAME}"
if ! ${WGET_COMMAND} --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JAVA_URL_FILENAME} -O "${JAVA_FILE_PATH}"; then
exit_with_error "Failed to download ${JAVA_URL_FILENAME}"
fi

echo "Verifying ${JAVA_FILE_PATH}"
echo "${JAVA_SHA256SUM} ${JAVA_FILE_PATH}" | sha256sum -c > /dev/null 2>&1 || \
{
exit_with_error "sha256sum mismatch ${JAVA_FILE_PATH}"
}
}

install_java() {
rm -rf ${JAVA_DIR}
mkdir -p ${JAVA_DIR}

echo "Installing ${JAVA_FILE_PATH}"
if ! tar -xf ${JAVA_FILE_PATH} -C ${JAVA_DIR} ; then
exit_with_error "Cannot unpack tar file ${JAVA_FILENAME}"
fi

# Remove downloaded file
rm ${JAVA_FILE_PATH}
}

download_flash() {
echo "Downloading ${FLASH_FILENAME}"
if ! ${WGET_COMMAND} "${FLASH_URL_FILENAME}" -O "${CACHE_DIR}/${FLASH_FILENAME}"; then
exit_with_error "Failed to download ${FLASH_URL_FILENAME}"
fi

echo "Verifying ${FLASH_FILE_PATH}"
echo "${FLASH_SHA256SUM} ${FLASH_FILE_PATH}" | sha256sum -c > /dev/null 2>&1 || \
{
exit_with_error "sha256sum mismatch ${FLASH_FILE_PATH}"
}
}

install_flash() {
rm -rf ${FLASH_DIR}
mkdir -p ${FLASH_DIR}

echo "Installing ${FLASH_FILE_PATH}"

pushd ${CACHE_DIR}
if ! unzip ${FLASH_FILE_PATH} ; then
exit_with_error "Cannot unpack zip file ${FLASH_FILENAME}"
fi
flash_inner_path=$(echo -n ${FLASH_VERSION} | sed -r "s/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9])/\1_\2_r\3_\4/")
flash_inner_file=$(echo -n ${FLASH_VERSION} | sed -r "s/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9])/\1_\2r\3_\4/")
if ! tar -xf ${flash_inner_path}_64bit/flashplayer${flash_inner_file}_linux.x86_64.tar.gz ; then
exit_with_error "Cannot unpack inner flash tar file"
fi
if ! install -m 644 libflashplayer.so ${FLASH_DIR} ; then
exit_with_error "Cannot install libflashplayer.so"
fi
popd

# Remove downloaded file
rm ${FLASH_FILE_PATH}
}

check_link() {
if [ -e $1 ]; then
return 0;
else
return 1;
fi
}

if ! check_link ${JAVA_LINK}; then
echo "JAVA is not correctly installed for Firefox"

java_plugin=`ls ${JAVA_DIR}/jre*/lib/amd64/libnpjp2.so 2>/dev/null` || echo ""
if [ ! -e "${java_plugin}" ]; then
download_java
install_java
fi
java_plugin=$(ls ${JAVA_DIR}/jre*/lib/amd64/libnpjp2.so)
echo "Creating the symlink for the JAVA: ${JAVA_LINK} -> ${java_plugin}"
mkdir -p ${PLUGINS_DIR}
ln -sf ${java_plugin} ${JAVA_LINK}
else
echo "Found JAVA plugin"
fi

if ! check_link ${FLASH_LINK}; then
echo "Flash is not correctly installed for Firefox"
if [ ! -e "${FLASH_DIR}/libflashplayer.so" ]; then
download_flash
install_flash
fi

echo "Creating the symlink for the Flash: ${FLASH_LINK} -> ${FLASH_DIR}/libflashplayer.so"
mkdir -p ${PLUGINS_DIR}
ln -sf ${FLASH_DIR}/libflashplayer.so ${FLASH_LINK}
else
echo "Found Flash plugin"
fi
20 changes: 6 additions & 14 deletions firefox.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#!/bin/sh

JRE_PLUGIN_FILENAME="libnpjp2.so"

mkdir -p $HOME/.mozilla/plugins
mkdir -p $HOME/.flatpak_extras/firefox

if [ ! -f $HOME/.mozilla/plugins/$JRE_PLUGIN_FILENAME ]; then
ff-oracle-jre-installer &
fi

export PATH="$HOME/.flatpak_extras/firefox/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/.flatpak_extras/firefox/lib/amd64:$HOME/.flatpak_extras/firefox/lib/amd64/jli:$LD_LIBRARY_PATH"
export JAVA_HOME="$Home/.flatpak_extras/firefox"

exec /app/bin/firefox $@
exec /app/extra/firefox/firefox-bin $@
# Launch the script that installs the plugins (if needed) in the background
# so it installs them while Firefox is already running, avoiding the user
# to wait
/app/bin/firefox-plugins-installer &
exec /app/extra/firefox/firefox-bin $@
Loading

0 comments on commit e920bc6

Please sign in to comment.