Browse Source

[linux] add Desktop launch scripts

Former-commit-id: 57539ee9f0
master
R4SAS 3 years ago
parent
commit
a6f28e6fe0
  1. 61
      linux/build/build
  2. 14
      linux/build/scripts/execdesktop
  3. 289
      linux/build/scripts/start-i2pd-browser
  4. 34
      linux/build/scripts/start-i2pd-browser.desktop

61
linux/build/build

@ -77,53 +77,48 @@ fi @@ -77,53 +77,48 @@ fi
echo "Extracting archive, please wait..."
tar xfj $file
rm $file
mv $application ../app
mkdir ../data
mv $application ../browser
mkdir ../browser/data
# Deleting some not needed files
rm ../app/crashreporter*
rm ../app/minidump-analyzer
rm ../app/pingsender
rm ../app/precomplete
rm ../app/removed-files
rm ../app/update*
rm ../app/Throbber-small.gif
rm ../app/browser/crashreporter-override.ini
rm ../app/browser/features/formautofill@mozilla.org.xpi
rm ../app/browser/features/screenshots@mozilla.org.xpi
rm -r ../app/icons
rm ../browser/crashreporter*
rm ../browser/minidump-analyzer
rm ../browser/pingsender
rm ../browser/precomplete
rm ../browser/removed-files
rm ../browser/update*
rm ../browser/Throbber-small.gif
rm ../browser/browser/crashreporter-override.ini
rm ../browser/browser/features/formautofill@mozilla.org.xpi
rm ../browser/browser/features/screenshots@mozilla.org.xpi
rm -r ../browser/icons
# And edit some places
sed -i 's/Enabled=1/Enabled=0/g' ../app/application.ini
sed -i 's/ServerURL=.*/ServerURL=-/' ../app/application.ini
sed -i 's/Enabled=1/Enabled=0/g' ../browser/application.ini
sed -i 's/ServerURL=.*/ServerURL=-/' ../browser/application.ini
# Done!
echo "Downloading language packs..."
mkdir ../app/browser/extensions
curl -L -f -# -o ../app/browser/extensions/langpack-ru@firefox.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3605589/russian_ru_language_pack-78.0buildid20200708170202-fx.xpi
curl -L -f -# -o ../app/browser/extensions/ru@dictionaries.addons.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/1163927/russian_spellchecking_dictionary-0.4.5.1webext.xpi
curl -L -f -# -o ../app/browser/extensions/langpack-en-US@firefox.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3605503/english_us_language_pack-78.0buildid20200708170202-fx.xpi
curl -L -f -# -o ../app/browser/extensions/en-US@dictionaries.addons.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3658646/english_united_states_dictionary-78.0.xpi
mkdir ../browser/browser/extensions
curl -L -f -# -o ../browser/browser/extensions/langpack-ru@firefox.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3605589/russian_ru_language_pack-78.0buildid20200708170202-fx.xpi
curl -L -f -# -o ../browser/browser/extensions/ru@dictionaries.addons.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/1163927/russian_spellchecking_dictionary-0.4.5.1webext.xpi
curl -L -f -# -o ../browser/browser/extensions/langpack-en-US@firefox.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3605503/english_us_language_pack-78.0buildid20200708170202-fx.xpi
curl -L -f -# -o ../browser/browser/extensions/en-US@dictionaries.addons.mozilla.org.xpi https://addons.mozilla.org/firefox/downloads/file/3658646/english_united_states_dictionary-78.0.xpi
echo "Downloading NoScript extension..."
curl -L -f -# -o ../app/browser/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi https://addons.mozilla.org/firefox/downloads/file/3926354/noscript_security_suite-11.4.1-an+fx.xpi
curl -L -f -# -o ../browser/browser/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi https://addons.mozilla.org/firefox/downloads/file/3926354/noscript_security_suite-11.4.1-an+fx.xpi
echo "Adding standard configs..."
cp -r preferences/* ../app/
cp -r profile/* ../data/
cp -r preferences/* ../browser/
cp -r profile/* ../browser/data/
if [ "$language" = "ru" ]; then
cp -r profile-ru/* ../data/
cp -r profile-ru/* ../browser/data/
else
cp -r profile-en/* ../data/
cp -r profile-en/* ../browser/data/
fi
echo '#!/bin/sh' > "../${application}-portable"
echo 'dir=${0%/*}' >> "../${application}-portable"
echo 'if [ "$dir" = "$0" ]; then' >> "../${application}-portable"
echo ' dir="."' >> "../${application}-portable"
echo 'fi' >> "../${application}-portable"
echo 'cd "$dir/app"' >> "../${application}-portable"
echo './firefox -profile ../data -no-remote &' >> "../${application}-portable"
echo "Copying Desktop launch scripts..."
cp -r scripts/* ../browser/
cp scripts/start-i2pd-browser.desktop ../
chmod +x "../$application-portable"
echo ... finished

14
linux/build/scripts/execdesktop

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
#!/usr/bin/env bash
I2PDB_START_PROG="$(grep '^X-I2PdBrowser-ExecShell' $1 | tail -1 | sed 's/^X-I2PdBrowser-ExecShell=//' | sed 's/%.//')"
shift
if [ "$#" -ge 1 ]
then
echo "Launching '${I2PDB_START_PROG} $@'..."
else
echo "Launching '${I2PDB_START_PROG}'..."
fi
${I2PDB_START_PROG} "$@"

289
linux/build/scripts/start-i2pd-browser

@ -0,0 +1,289 @@ @@ -0,0 +1,289 @@
#!/usr/bin/env bash
#
# GNU/Linux does not really require something like RelativeLink.c
# However, we do want to have the same look and feel with similar features.
#
# Copyright 2017 The Tor Project. See LICENSE for licensing information.
complain_dialog_title="I2Pd Browser"
# Make sure this script wasn't started as 'sh start-i2pd-browser' or similar.
if [ "x$BASH" = "x" ]; then
echo "$complain_dialog_title should be started as './start-i2pd-browser'"
echo "Exiting." >&2
exit 1;
fi
# Do not (try to) connect to the session manager
unset SESSION_MANAGER
# Complain about an error, by any means necessary.
# Usage: complain message
# message must not begin with a dash.
complain () {
# Trim leading newlines, to avoid breaking formatting in some dialogs.
complain_message="`echo "$1" | sed '/./,$!d'`"
# If we're being run in debug/verbose mode, complain to stderr.
if [ "$show_output" -eq 1 ]; then
echo "$complain_message" >&2
return
fi
# Otherwise, we're being run by a GUI program of some sort;
# try to pop up a message in the GUI in the nicest way
# possible.
#
# In mksh, non-existent commands return 127; I'll assume all
# other shells set the same exit code if they can't run a
# command. (xmessage returns 1 if the user clicks the WM
# close button, so we do need to look at the exact exit code,
# not just assume the command failed to display a message if
# it returns non-zero.)
# First, try zenity.
zenity --error \
--title="$complain_dialog_title" \
--text="$complain_message"
if [ "$?" -ne 127 ]; then
return
fi
# Try kdialog.
kdialog --title "$complain_dialog_title" \
--error "$complain_message"
if [ "$?" -ne 127 ]; then
return
fi
# Try xmessage.
xmessage -title "$complain_dialog_title" \
-center \
-buttons OK \
-default OK \
-xrm '*message.scrollVertical: Never' \
"$complain_message"
if [ "$?" -ne 127 ]; then
return
fi
# Try gxmessage. This one isn't installed by default on
# Debian with the default GNOME installation, so it seems to
# be the least likely program to have available, but it might
# be used by one of the 'lightweight' Gtk-based desktop
# environments.
gxmessage -title "$complain_dialog_title" \
-center \
-buttons GTK_STOCK_OK \
-default OK \
"$complain_message"
if [ "$?" -ne 127 ]; then
return
fi
}
if [ "`id -u`" -eq 0 ]; then
complain "The I2Pd Browser Bundle should not be run as root. Exiting."
exit 1
fi
if test -r /proc/cpuinfo && ! grep -q '^flags\s*:.* sse2' /proc/cpuinfo; then
complain "I2Pd Browser requires a CPU with SSE2 support. Exiting."
exit 1
fi
tbb_usage () {
printf "\nI2Pd Browser Script Options\n"
printf " --verbose Display Firefox output in the terminal\n"
printf " --log [file] Record Firefox output in file (default: i2pd-browser.log)\n"
printf " --detach Detach from terminal and run I2Pd Browser in the background.\n"
printf " --register-app Register I2Pd Browser as a desktop app for this user\n"
printf " --unregister-app Unregister I2Pd Browser as a desktop app for this user\n"
}
log_output=0
show_output=0
detach=0
show_usage=0
register_desktop_app=0
logfile=/dev/null
while :
do
case "$1" in
--detach)
detach=1
shift
;;
-v | --verbose | -d | --debug)
show_output=1
verbose_arg="$2"
shift
;;
-h | "-?" | --help | -help)
show_usage=1
show_output=1
shift
;;
-l | --log)
if [ -z "$2" -o "${2:0:1}" == "-" ]; then
printf "Logging I2Pd Browser debug information to i2pd-browser.log\n"
logfile="../i2pd-browser.log"
elif [ "${2:0:1}" == "/" -o "${2:0:1}" == "~" ]; then
printf "Logging I2Pd Browser debug information to %s\n" "$2"
logfile="$2"
shift
else
printf "Logging I2Pd Browser debug information to %s\n" "$2"
logfile="../$2"
shift
fi
log_output=1
shift
;;
--register-app)
register_desktop_app=1
show_output=1
shift
;;
--unregister-app)
register_desktop_app=-1
show_output=1
shift
;;
*) # No more options
break
;;
esac
done
# We can't detach and show output at the same time..
if [ "$show_output" -eq 1 -a "$detach" -eq 1 ]; then
detach=0
fi
if [ "$show_output" -eq 0 ]; then
# If the user hasn't requested 'debug mode' or --help, close stdout and stderr,
# to keep Firefox and the stuff loaded by/for it (including the
# system's shared-library loader) from printing messages to
# $HOME/.xsession-errors or other files. (Users wouldn't have seen
# messages there anyway.)
exec > "$logfile"
exec 2> "$logfile"
fi
# If XAUTHORITY is unset, set it to its default value of $HOME/.Xauthority
# before we change HOME below. (See xauth(1) and #1945.) XDM and KDM rely
# on applications using this default value.
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=~/.Xauthority
export XAUTHORITY
fi
# If this script is being run through a symlink, we need to know where
# in the filesystem the script itself is, not where the symlink is.
myname="$0"
if [ -L "$myname" ]; then
# XXX readlink is not POSIX, but is present in GNU coreutils
# and on FreeBSD. Unfortunately, the -f option (which follows
# a whole chain of symlinks until it reaches a non-symlink
# path name) is a GNUism, so we have to have a fallback for
# FreeBSD. Fortunately, FreeBSD has realpath instead;
# unfortunately, that's also non-POSIX and is not present in
# GNU coreutils.
#
# If this launcher were a C program, we could just use the
# realpath function, which *is* POSIX. Too bad POSIX didn't
# make that function accessible to shell scripts.
# If realpath is available, use it; it Does The Right Thing.
possibly_my_real_name="`realpath "$myname" 2>/dev/null`"
if [ "$?" -eq 0 ]; then
myname="$possibly_my_real_name"
else
# realpath is not available; hopefully readlink -f works.
myname="`readlink -f "$myname" 2>/dev/null`"
if [ "$?" -ne 0 ]; then
# Ugh.
complain "start-i2pd-browser cannot be run using a symlink on this operating system."
fi
fi
fi
# Try to be agnostic to where we're being started from, chdir to where
# the script is.
mydir="`dirname "$myname"`"
test -d "$mydir" && cd "$mydir"
# If ${PWD} results in a zero length string, we can try something else...
if [ ! "${PWD}" ]; then
# "hacking around some braindamage"
PWD="`pwd`"
surveysays="This system has a messed up shell.\n"
fi
# This is a fix for an ibus issue on some Linux systems. See #9353 for more
# details. The symlink needs to be created before we change HOME.
if [ ! -d ".config/ibus" ]; then
mkdir -p .config/ibus
ln -nsf ~/.config/ibus/bus .config/ibus
fi
# Fix up .desktop Icon and Exec Paths, and update the .desktop file from the
# canonical version if it was changed by the updater.
cp start-i2pd-browser.desktop ../
sed -i -e "s,^Name=.*,Name=I2Pd Browser,g" ../start-i2pd-browser.desktop
sed -i -e "s,^Icon=.*,Icon=$PWD/browser/chrome/icons/default/default128.png,g" ../start-i2pd-browser.desktop
sed -i -e "s,^Exec=.*,Exec=sh -c '\"$PWD/start-i2pd-browser\" --detach || ([ ! -x \"$PWD/start-i2pd-browser\" ] \&\& \"\$(dirname \"\$*\")\"/Browser/start-i2pd-browser --detach)' dummy %k,g" ../start-i2pd-browser.desktop
if [ "$register_desktop_app" -eq 1 ]; then
mkdir -p "$HOME/.local/share/applications/"
cp ../start-i2pd-browser.desktop "$HOME/.local/share/applications/"
update-desktop-database "$HOME/.local/share/applications/"
printf "I2Pd Browser has been registered as a desktop app for this user in ~/.local/share/applications/\n"
exit 0
fi
if [ "$register_desktop_app" -eq -1 ]; then
if [ -e "$HOME/.local/share/applications/start-i2pd-browser.desktop" ]; then
rm -f "$HOME/.local/share/applications/start-i2pd-browser.desktop"
update-desktop-database "$HOME/.local/share/applications/"
printf "I2Pd Browser has been removed as a user desktop app (from ~/.local/share/applications/)\n"
else
printf "I2Pd Browser does not appear to be a desktop app (not present in ~/.local/share/applications/)\n"
fi
exit 0
fi
HOME="${PWD}"
export HOME
# Avoid overwriting user's dconf values. Fixes #27903.
export GSETTINGS_BACKEND=memory
cd "${HOME}"
# We pass all additional command-line arguments we get to Firefox.
#
# The --class parameter was added to fix bug 11102.
if [ "$show_usage" -eq 1 ]; then
# Display Firefox help, then our help
./firefox --class "I2Pd Browser" \
-profile data --help 2>/dev/null
tbb_usage
elif [ "$detach" -eq 1 ] ; then
./firefox --class "I2Pd Browser" \
-profile data "${@}" > "$logfile" 2>&1 </dev/null &
disown "$!"
elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
./firefox --class "I2Pd Browser" \
-profile data "${@}" 2>&1 </dev/null | \
tee "$logfile"
elif [ "$show_output" -eq 1 ]; then
./firefox --class "I2Pd Browser" \
-profile data "${@}" < /dev/null
else
./firefox --class "I2Pd Browser" \
-profile data "${@}" > "$logfile" 2>&1 </dev/null
fi
exit $?

34
linux/build/scripts/start-i2pd-browser.desktop

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
#!/usr/bin/env ./Browser/execdesktop
#
# This file is a self-modifying .desktop file that can be run from the shell.
# It preserves arguments and environment for the start-tor-browser script.
#
# Run './start-i2pd-browser.desktop --help' to display the full set of options.
#
# When invoked from the shell, this file must always be in a Tor Browser root
# directory. When run from the file manager or desktop GUI, it is relocatable.
#
# After first invocation, it will update itself with the absolute path to the
# current TBB location, to support relocation of this .desktop file for GUI
# invocation. You can also add Tor Browser to your desktop's application menu
# by running './start-i2pd-browser.desktop --register-app'
#
# If you use --register-app, and then relocate your TBB directory, Tor Browser
# will no longer launch from your desktop's app launcher/dock. However, if you
# re-run --register-app from inside that new directory, the script
# will correct the absolute paths and re-register itself.
#
# This file will also still function if the path changes when TBB is used as a
# portable app, so long as it is run directly from that new directory, either
# via the shell or via the file manager.
[Desktop Entry]
Type=Application
Name=I2Pd Browser Setup
GenericName=I2Pd Browser
Comment=I2Pd Browser for surfing I2P sites
Categories=Network;WebBrowser;Security;
Exec=sh -c '"$(dirname "$*")"/browser/start-i2pd-browser --detach || ([ ! -x "$(dirname "$*")"/browser/start-i2pd-browser ] && "$(dirname "$*")"/start-i2pd-browser --detach)' dummy %k
X-I2PdBrowser-ExecShell=./browser/start-i2pd-browser --detach
Icon=web-browser
StartupWMClass=I2Pd Browser
Loading…
Cancel
Save