[pipelight] use the most recent dependency-installer-script provided in upstream's scm copy the original depende

Björn Esser besser82 at fedoraproject.org
Fri Jul 11 12:44:51 UTC 2014


commit fbb0fd6f1bfdad9700e2ac45bbb7b9c8ae1122d8
Author: Björn Esser <bjoern.esser at gmail.com>
Date:   Fri Jul 11 14:19:36 2014 +0200

    use the most recent dependency-installer-script provided in upstream's scm
    copy the original dependency-installer-script to some non-changing file and
    package that one as existing file, the real dependency-installer-script as
    %%ghost; restore the real dependency-installer-script during %%post from
    the packaged one

 install-dependency | 1041 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 pipelight.spec     |   46 ++-
 2 files changed, 1079 insertions(+), 8 deletions(-)
---
diff --git a/install-dependency b/install-dependency
new file mode 100644
index 0000000..1d0c521
--- /dev/null
+++ b/install-dependency
@@ -0,0 +1,1041 @@
+#!/usr/bin/env bash
+
+usage()
+{
+	echo ""
+	echo "Usage: ./install-dependency DEPENDENCY1 [DEPENDENCY2 ...]"
+	echo ""
+	echo "Environment variables:"
+	echo "  WINE                  path to the wine executable"
+	echo "  WINEPREFIX            usually \$HOME/.wine-pipelight"
+	echo "  WINEARCH              usually win32"
+	echo "  QUIETINSTALLATION=1   don't show the original installation dialogs"
+	echo ""
+	echo "Package dependencies:"
+	echo "	wine-silverlight4-installer"
+	echo "	wine-silverlight5.0-installer"
+	echo "	wine-silverlight5.1-installer"
+	echo "	wine-flash-installer"
+	echo "	wine-flash-debug-installer"
+	echo "	wine-widevine-installer"
+	echo "	wine-unity3d-installer"
+	echo "	wine-x64-unity3d-installer"
+	echo "	wine-adobereader-installer"
+	echo "	wine-foxitpdf-installer"
+	echo "	wine-shockwave-installer"
+	echo "	wine-grandstream-installer"
+	echo "	wine-hikvision-installer"
+	echo "	wine-npactivex-installer"
+	echo "	wine-roblox-installer"
+	echo "	wine-vizzedrgr-installer"
+	echo "	wine-viewright-caiway-installer"
+	echo "	wine-triangleplayer-installer"
+	echo ""
+	echo "Library dependencies:"
+	echo "	wine-mpg2splt-installer"
+	echo "	wine-wininet-installer"
+	echo "	wine-mspatcha-installer"
+	echo ""
+}
+
+PRG=$(basename "$0")
+
+# > Marks a file in order to delete it at program termination
+# arguments:
+# $1	- File to delete
+ATEXIT_RM_LIST=()
+atexit_add_rm()
+{
+	ATEXIT_RM_LIST+=("$1")
+}
+
+atexit()
+{
+	local file
+	for file in "${ATEXIT_RM_LIST[@]}"; do
+		echo "Deleting temporary '$file'."
+		rm "$file"
+	done
+}
+
+mktemp_with_ext()
+{
+	file=$(mktemp --suffix=".$1" 2>/dev/null)
+	if [ "$?" -eq 0 ]; then echo "$file"; return 0; fi
+	file=$(mktemp 2>/dev/null) # old version of mktemp
+	if [ "$?" -eq 0 ]; then echo "$file"; return 0; fi
+	file=$(mktemp -t pipelight 2>/dev/null) # MacOS version of mktemp
+	if [ "$?" -eq 0 ]; then echo "$file"; return 0; fi
+	return 1
+}
+
+# > Checks if a dependency is already installed
+# arguments:
+# $1	- SHA256
+# $DEP
+is_installed()
+{
+	local SHA="$1"
+	local ckfile="$WINEPREFIX/$DEP.installed"
+	[ -f "$ckfile" ] && [ "$SHA" == "$(cat "$ckfile")" ]
+	return $?
+}
+
+# > Marks a dependency as already installed
+# arguments: same as is_installed
+mark_installed()
+{
+	local SHA="$1"
+	local ckfile="$WINEPREFIX/$DEP.installed"
+	echo "$SHA" > "$ckfile"
+}
+
+# > Download a given dependency file
+# arguments:
+# $1	- URL
+# $2	- SHA256
+# $3	- Overwrite file extension
+# returns:
+# $DOWNLOADFILE
+DOWNLOADFILE=""
+download()
+{
+	local URL="$1";	local SHA="$2";	local EXT="$3"
+
+	if [ -z "$EXT" ]; then
+		EXT=$(echo "$URL" | sed 's/.*\.//')
+	fi
+
+	# Reuse files from the netflix-desktop package if available
+	local dlfile="/var/lib/wine-browser-installer/$DEP.$EXT"
+	if [ -f "$dlfile" ] && [ "$SHA" == "$(sha256sum "$dlfile" | cut -d' ' -f1)" ]; then
+		DOWNLOADFILE="$dlfile"
+		return 0
+	fi
+
+	# Reuse existing download
+	local dlfile="/tmp/pipelight-$DEP.$EXT"
+	if [ -f "$dlfile" ] && [ "$SHA" == "$(sha256sum "$dlfile" | cut -d' ' -f1)" ]; then
+		DOWNLOADFILE="$dlfile"
+		return 0
+	fi
+
+	local trycount=3
+	local tmpfile=$(mktemp_with_ext "$EXT")
+	[ -f "$tmpfile" ] || return 1
+	local filesize=$(get_download_size "$URL")
+
+	# Download to tmpfile
+	while true; do
+		if [ "$trycount" -le 0 ]; then
+			rm "$tmpfile"
+			echo "[$PRG] ERROR: Downloading of $DEP failed multiple times. Please check:" >&2
+			echo "[$PRG]" >&2
+			echo "[$PRG]        * that your internet connection is working properly" >&2
+			echo "[$PRG]" >&2
+			echo "[$PRG]        * and that the plugin database is up-to-date. To update it just run:" >&2
+			echo "[$PRG]            sudo pipelight-plugin --update" >&2
+			echo "[$PRG]" >&2
+			echo "[$PRG]        If this doesn't help then most-likely the download URLs or checksums" >&2
+			echo "[$PRG]        have changed. We recommend to open a bug-report in this case." >&2
+			return 1
+		fi
+
+		download_file "$tmpfile" "$URL" 2>&1 | progressbar "Please wait, downloading ..." "Downloading $DEP ($filesize MiB)"
+		if [ -f "$tmpfile" ] && [ "$SHA" == "$(sha256sum "$tmpfile" | cut -d' ' -f1)" ]; then
+			break
+		fi
+
+		(( trycount-- ))
+		sleep 2
+	done
+
+	# Move the downloaded file to the right path
+	if mv "$tmpfile" "$dlfile"; then
+		chmod 0644 "$dlfile"
+		DOWNLOADFILE="$dlfile"
+		return 0
+	fi
+
+	# Continue using the temp path
+	atexit_add_rm "$tmpfile"
+	DOWNLOADFILE="$tmpfile"
+	return 0
+}
+
+# > Sets a registry key
+# arguments:
+# $1	- key
+# $2	- path
+register_mozilla_plugin()
+{
+	local KEY="$1"; local VAL="$2"
+
+	local tmpfile=$(mktemp)
+	[ -f "$tmpfile" ] || return 1
+
+	local valfile=$("$WINE" winepath --windows "$VAL" | sed 's/\\/\\\\/g')
+
+	(
+		echo "REGEDIT4"
+		echo ""
+		echo "[HKEY_LOCAL_MACHINE\\Software\\MozillaPlugins\\$KEY]"
+		echo "\"Path\"=\"$valfile\""
+	) > "$tmpfile"
+
+	"$WINE" regedit "$tmpfile"
+	local res=$?
+
+	# Cleanup
+	rm "$tmpfile"
+
+	# Successful
+	return "$res"
+}
+
+# > Installer for Silverlight
+# arguments:
+# $1	- version
+# $2	- short version
+# $DOWNLOADFILE
+install_silverlight()
+{
+	local VER="$1"
+	local SHORTVER="$2"
+
+	# Remove the registry keys for Silverlight since other versions can prevent this one from installing
+	"$WINE" msiexec /uninstall {89F4137D-6C26-4A84-BDB8-2E5A4BB71E00};
+
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" /noupdate 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /q /doNotRequireDRMPrompt /noupdate 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local programfiles="$WINEPREFIX/drive_c/Program Files"
+	if [ ! -d "$programfiles/Microsoft Silverlight/$VER" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Move the installation to a version-specific folder that nothing will touch
+	mkdir -p "$programfiles/Silverlight"
+	mv "$programfiles/Microsoft Silverlight/$VER" "$programfiles/Silverlight/$VER"
+
+	# Create a short symlink if SHORTVER is provided.
+	if [ ! -z "$SHORTVER" ]; then
+		local shortsymlink="$programfiles/Silverlight/$SHORTVER"
+		if [ -L "$shortsymlink" ]; then
+			rm "$shortsymlink"
+		elif [ -e "$shortsymlink" ]; then
+			echo "[$PRG] ERROR: Unable to overwrite $shortsymlink, please delete this file manually." >&2
+			return 1
+		fi
+		ln -s "$VER" "$shortsymlink"
+	fi
+
+	# Remove the Silverlight menu shortcut
+	rm -f "$WINEPREFIX/drive_c/users/$USER/Start Menu/Programs/Microsoft Silverlight/Microsoft Silverlight.lnk"
+
+	# Workaround for users that are upgrading install-dependency before Pipelight release 0.2.6
+	if [ "$VER" == "5.1.30214.0" ]; then
+		if [ -d "$programfiles/Silverlight/5.1.20913.0" ]; then
+			mv "$programfiles/Silverlight/5.1.20913.0" "$programfiles/Silverlight/5.1.20913.0.orig"
+		fi
+		ln -s "$programfiles/Silverlight/$VER" "$programfiles/Silverlight/5.1.20913.0"
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Extract cab library
+# arguments:
+# $1	- file to extract
+# $DOWNLOADFILE
+#
+# optional arguments:
+# --reg - run regsvr32.dll to register the dll
+install_cabextract()
+{
+	local FILE="$1"; shift
+
+	local system32="$WINEPREFIX/drive_c/windows/system32"
+	cabextract -d "$system32" "$DOWNLOADFILE" -F "$FILE"
+	if [ ! -f "$system32/$FILE" ]; then
+		echo "[$PRG] ERROR: Failed to extract $FILE from cab file." >&2
+		return 1
+	fi
+
+	# Process additional args
+	while [ $# -gt 0 ] ; do
+		local cmd=$1; shift
+		case "$cmd" in
+			--rename)
+				if ! mv "$system32/$FILE" "$system32/$1"; then
+					echo "[$PRG] ERROR: Unable to rename extracted file." >&2
+					return 1
+				fi
+				FILE="$1"; shift
+				;;
+			--reg)
+				"$WINE" regsvr32.exe "$FILE"
+				;;
+			*)
+				echo "[$PRG] ERROR: Internal error, install_cabextract called with argument: $cmd" >&2
+				return 1
+				;;
+		esac
+	done
+
+	# Successful
+	return 0
+}
+
+# > Install wininet.dll
+# arguments:
+# $DOWNLOADFILE
+install_wininet()
+{
+	if ! install_cabextract wininet.x86.5.0.3700.6713.dll --rename "wininet.dll"; then return 1; fi
+
+	# Setup wine dlloverride and adjust some wininet.dll related settings
+	local tmpfile=$(mktemp)
+	[ -f "$tmpfile" ] || return 1
+
+	(
+		echo "REGEDIT4"
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]"
+		echo "\"*wininet\"=\"native,builtin\""
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings]"
+		echo "\"MaxConnectionsPerServer\"=dword:7fffffff"
+		echo "\"MaxConnectionsPer1_0Server\"=dword:7fffffff"
+	) > "$tmpfile"
+
+	"$WINE" regedit "$tmpfile"
+	local res=$?
+
+	# Cleanup
+	rm "$tmpfile"
+
+	# Successful
+	return "$res"
+
+}
+
+# > Install flash
+# arguments:
+# $1	- version path component
+# $DOWNLOADFILE
+install_flash()
+{
+	VER="$1"
+
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" -install 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/windows/system32/Macromed/Flash"
+
+	local result=1
+	case "$WINEARCH" in
+		win32)
+			[ -f "$installdir/NPSWF32_$VER.dll" ]; result=$?
+			;;
+		win64)
+			[ -f "$installdir/NPSWF64_$VER.dll" ]; result=$?
+			;;
+		*)
+			[ -f "$installdir/NPSWF32_$VER.dll" ] || [ -f "$installdir/NPSWF64_$VER.dll" ]; result=$?
+			;;
+	esac
+
+	if [ "$result" -ne 0 ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+
+	local flashconfig="$installdir/mms.cfg"
+	if ! grep -q "^OverrideGPUValidation=" "$flashconfig" 2>/dev/null; then
+		(
+			grep -v "^OverrideGPUValidation=" "$flashconfig" 2>/dev/null
+			echo "OverrideGPUValidation=true"
+		) > "$flashconfig.bak"
+
+		if ! mv "$flashconfig.bak" "$flashconfig"; then
+			echo "[$PRG] ERROR: Unable to change $DEP plugin settings." >&2
+		fi
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install shockwave
+# arguments:
+# $1	- version path component
+# $DOWNLOADFILE
+install_shockwave()
+{
+	VER="$1"
+
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /S 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/windows/system32/Adobe/Director"
+	if [ ! -f "$installdir/np32dsw_$VER.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	 # Switch to OpenGL mode and disable fallback mode
+	 local tmpfile=$(mktemp)
+	 [ -f "$tmpfile" ] || return 1
+
+	(
+		echo "REGEDIT4"
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Adobe\\Shockwave 12\\allowfallback]"
+		echo "@=\"n\""
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Adobe\\Shockwave 12\\renderer3dsetting]"
+		echo "@=\"2\""
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Adobe\\Shockwave 12\\renderer3dsettingPerm]"
+		echo "@=\"2\""
+	) > "$tmpfile"
+
+	"$WINE" regedit "$tmpfile"
+	local res=$?
+
+	# Cleanup
+	rm "$tmpfile"
+
+	# Successful
+	return "$res"
+}
+
+# > Install Unity3D 32 bit
+# arguments: None
+# $DOWNLOADFILE
+install_unity3d()
+{
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" /AllUsers 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /S /AllUsers 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Unity/WebPlayer/loader"
+	if [ ! -f "$installdir/npUnity3D32.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Unity3D 64 bit
+# arguments: None
+# $DOWNLOADFILE
+install_x64_unity3d()
+{
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" /AllUsers 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /S /AllUsers 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Unity/WebPlayer64/loader-x64"
+	if [ ! -f "$installdir/npUnity3D64.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Foxit PDF
+# arguments: None
+# $DOWNLOADFILE
+install_foxitpdf()
+{
+	# Launch the installer
+	#if [ "$QUIETINSTALLATION" -eq 0 ]; then
+	#	"$WINE" "$DOWNLOADFILE" /AllUsers 2>&1
+	#else
+		"$WINE" msiexec.exe /i "$DOWNLOADFILE" ALLUSERS=1 /q /norestart MAKEDEFAULT=0 VIEW_IN_BROWSER=1 DESKTOP_SHORTCUT=0 AUTO_UPDATE=0 ADDLOCAL="FX_PDFVIEWER,FX_FIREFOXPLUGIN" REMOVE="ALL" 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	#fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Foxit Software/Foxit Reader/plugins"
+	if [ ! -f "$installdir/npFoxitReaderPlugin.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Grandstream
+# arguments: None
+# $DOWNLOADFILE
+install_grandstream()
+{
+	local tmpfile=$(mktemp_with_ext "exe")
+	[ -f "$tmpfile" ] || return 1
+
+	if ! unzip -p "$DOWNLOADFILE" "chrome_firefox_plugine_1.0.0.7.exe" > "$tmpfile"; then
+		echo "[$PRG] ERROR: Unable to extract installer from zip file." >&2
+		rm "$tmpfile"
+		return 1
+	fi
+
+	# Launch the installer and delete the program afterwards
+	"$WINE" "$tmpfile" 2>&1
+	rm "$tmpfile"
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/WebControl"
+	if [ ! -f "$installdir/npGS_Plugins.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install mspatcha.dll
+# arguments: None
+# $DOWNLOADFILE
+install_mspatcha()
+{
+	if ! install_cabextract mspatcha.dll; then return 1; fi
+
+	# Setup wine dlloverride
+	local tmpfile=$(mktemp)
+	[ -f "$tmpfile" ] || return 1
+
+	(
+		echo "REGEDIT4"
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]"
+		echo "\"*mspatcha\"=\"native,builtin\""
+	) > "$tmpfile"
+
+	"$WINE" regedit "$tmpfile"
+	local res=$?
+
+	# Cleanup
+	rm "$tmpfile"
+
+	# Successful
+	return "$res"
+
+}
+
+# > Install Adobe Reader
+# arguments: None
+# $DOWNLOADFILE
+install_adobereader()
+{
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /msi EULA_ACCEPT=YES /qn 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Adobe/Reader 11.0/Reader/AIR"
+	if [ ! -f "$installdir/nppdf32.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Disable sandbox as it does not work with Wine
+	local tmpfile=$(mktemp)
+	[ -f "$tmpfile" ] || return 1
+
+	(
+		echo "REGEDIT4"
+		echo ""
+		echo "[HKEY_CURRENT_USER\\Software\\Adobe\\Acrobat Reader\\11.0\\Privileged]"
+		echo "\"bProtectedMode\"=dword:00000000"
+	) > "$tmpfile"
+
+	"$WINE" regedit "$tmpfile"
+	local res=$?
+
+	# Cleanup
+	rm "$tmpfile"
+
+	# Successful
+	return "$res"
+}
+
+# > Install Widevine
+# arguments: None
+# $DOWNLOADFILE
+install_widevine()
+{
+	local system32="$WINEPREFIX/drive_c/windows/system32"
+	if ! unzip -p "$DOWNLOADFILE" "plugins/npwidevinemediaoptimizer.dll" > "$system32/npwidevinemediaoptimizer.dll"; then
+		echo "[$PRG] ERROR: Unable to extract plugin from xip file." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Hikvision
+# arguments: None
+# $DOWNLOADFILE
+install_hikvision()
+{
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" "$DOWNLOADFILE" /silent 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Web Components"
+	if [ ! -f "$installdir/npWebVideoPlugin.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install NP-ActiveX
+# arguments:
+# $1	- checksum of npactivex.dll
+# $DOWNLOADFILE
+install_npactivex()
+{
+	DLLSHA="$1"
+
+	local system32="$WINEPREFIX/drive_c/windows/system32"
+
+	# The exit code is 1, but the output is still valid
+	unzip -p "$DOWNLOADFILE" "npactivex.dll" > "$system32/npactivex.dll"
+
+	local installfile="$system32/npactivex.dll"
+	if [ ! -f "$installfile" ] || [ "$DLLSHA" != "$(sha256sum "$installfile" | cut -d' ' -f1)" ]; then
+		echo "[$PRG] ERROR: Unable to extract plugin from crx file." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Roblox
+# arguments:
+# $1	- version "number"
+# $DOWNLOADFILE
+install_roblox()
+{
+	VER="$1"
+
+	"$WINE" "$DOWNLOADFILE" 2>&1
+
+	local installdir="$WINEPREFIX/drive_c/users/$USER/Local Settings/Application Data/RobloxVersions/version-$VER"
+	if [ ! -f "$installdir/NPRobloxProxy.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	if ! "$WINE" regsvr32 "$installdir/RobloxProxy.dll"; then
+		echo "[$PRG] ERROR: Unable to register Roblox Launcher class." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install Vizeed RGR
+# arguments: None
+# $DOWNLOADFILE
+install_vizzedrgr()
+{
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" msiexec.exe /i "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" msiexec.exe /quiet /i "$DOWNLOADFILE" 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Vizzed/Vizzed Retro Game Room"
+	if [ ! -f "$installdir/NpVizzedRgr.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install ViewRight Plugin for Caiway
+# arguments: None
+# $DOWNLOADFILE
+install_viewright_caiway()
+{
+	# Launch the installer
+	if [ "$QUIETINSTALLATION" -eq 0 ]; then
+		"$WINE" msiexec.exe /i "$DOWNLOADFILE" 2>&1
+	else
+		"$WINE" msiexec.exe /quiet /i "$DOWNLOADFILE" 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+	fi
+
+	local installdir="$WINEPREFIX/drive_c/Program Files/Verimatrix/ViewRight Web"
+	if [ ! -f "$installdir/npViewRight.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# > Install TrianglePlayer
+# arguments: None
+# $DOWNLOADFILE
+install_triangleplayer()
+{
+	# Launch the installer
+	"$WINE" "$DOWNLOADFILE" 2>&1 | progressbar "Please wait, installing ..." "Running $DEP"
+
+	local installdir="$WINEPREFIX/drive_c/users/$USER/Application Data/TrianglePlayer"
+	if [ ! -f "$installdir/NPTrianglePlayer.dll" ]; then
+		echo "[$PRG] ERROR: Installer for $DEP did not run correctly or was aborted." >&2
+		return 1
+	fi
+
+	# Successful
+	return 0
+}
+
+# Use fetch on FreeBSD if wget is not available
+if command -v wget >/dev/null 2>&1; then
+	download_file()
+	{
+		wget -O "$1" "$2"
+	}
+	get_download_size()
+	{
+		local filesize="$(wget -O- "$1" --spider --server-response 2>&1 | sed -ne '/Content-Length/{s/.*: //;p}')"
+		local re='^[0-9]+$'
+		if [[ "$filesize" -ne "0" ]] && [[ "$filesize" =~ $re ]]; then
+			echo "$(($filesize/(1024*1024)))"
+		else
+			echo "N/A"
+		fi
+	}
+elif command -v fetch >/dev/null 2>&1; then
+	download_file()
+	{
+		fetch -o "$1" "$2"
+	}
+	get_download_size()
+	{
+		echo "N/A"
+	}
+else
+	download_file()
+	{
+		echo "ERROR: Could neither find wget nor fetch. Unable to download file!" >&2
+		return 1
+	}
+	get_download_size()
+	{
+		echo "N/A"
+	}
+fi
+
+# Use shasum instead of sha256sum on MacOS / *BSD
+if ! command -v sha256sum >/dev/null 2>&1 && command -v shasum >/dev/null 2>&1; then
+	sha256sum()
+	{
+		shasum -a 256 "$1"
+	}
+fi
+
+# Use md5 instead of md5sum on MacOS / *BSD
+if ! command -v md5sum >/dev/null 2>&1 && command -v md5 >/dev/null 2>&1; then
+	md5sum()
+	{
+		md5
+	}
+fi
+
+# Check if some visual feedback is possible
+if command -v zenity >/dev/null 2>&1; then
+	progressbar()
+	{
+		WINDOWID="" zenity --progress --title="$1" --text="$2" --pulsate --width=400 --auto-close --no-cancel ||
+		WINDOWID="" zenity --progress --title="$1" --text="$2" --pulsate --width=400 --auto-close
+	}
+
+elif command -v kdialog >/dev/null 2>&1 && command -v qdbus >/dev/null 2>&1; then
+	#Check if qdbus is symlinked to qtchooser (for Arch Linux)
+	QDBUSPATH=$(which qdbus)
+	QDBUSPATH=$(readlink "$QDBUSPATH")
+	if [ "$QDBUSPATH" == "qtchooser" ]; then
+		QDBUSPATH="qtchooser -run-tool=qdbus -qt=4"
+	else
+		QDBUSPATH="qdbus"
+	fi
+
+	progressbar()
+	{
+		local dcopref=$(kdialog --title "$1" --progressbar "$2" 10)
+
+		# Update the progress bar (not really the progress, but the user knows that something is going on)
+		(
+			local progress=1
+			while true; do
+				local err=$($QDBUSPATH $dcopref org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog value "$progress" 2>&1)
+				if [ ! -z "$err" ]; then break; fi
+
+				sleep 1
+
+				(( progress++ ))
+				if [ "$progress" -gt 10 ]; then progress=0; fi
+			done
+		) 0</dev/null &
+		local dialogpid="$!"
+
+		cat -
+
+		kill "$dialogpid"
+		$QDBUSPATH $dcopref org.kde.kdialog.ProgressDialog.close  &> /dev/null
+	}
+
+else
+	progressbar()
+	{
+		cat -
+	}
+fi
+
+# Print usage message when no arguments are given at all
+if [ $# -eq 0 ]; then
+	usage
+	exit 0
+fi
+
+# Check for environment variables
+if [ -z "$WINE" ] || [ -z "$WINEPREFIX" ]; then
+	echo "[$PRG] ERROR: Missing necessary environment variables WINE and WINEPREFIX." >&2
+	exit 1
+fi
+
+if [ ! -w "$WINEPREFIX" ]; then
+	WINEPREFIX_PARENT="$(dirname "$WINEPREFIX")"
+	if [ ! -w "$WINEPREFIX_PARENT" ] || [ ! -O "$WINEPREFIX_PARENT" ]; then
+		echo "[$PRG] ERROR: You're running this script as a wrong user - WINEPREFIX or parent directory not owned by you." >&2
+		exit 1
+	fi
+fi
+
+# Silent installation
+if [ -z "$QUIETINSTALLATION" ]; then
+	QUIETINSTALLATION=0
+fi
+
+# Generate a lock file based on the wine prefix
+LOCKFILE=$(echo "$WINEPREFIX" | md5sum | cut -d' ' -f1)
+LOCKFILE="/tmp/wine-$LOCKFILE.tmp"
+
+LOCKFD=9; eval "exec $LOCKFD> \"\$LOCKFILE\""
+if ! flock -x -w 360 "$LOCKFD"; then
+	echo "[$PRG] ERROR: Failed to obtain an installation lock in 6 minutes." >&2
+	exit 1;
+fi
+
+# Close file descriptor (ensure that the lock is released when the installation is ready)
+trap "EXITSTATUS=\$?; flock -u \"$LOCKFD\"; atexit; exit \"\$EXITSTATUS\"" 0
+
+# Initialize wine if not done yet
+if [ ! -f "$WINEPREFIX/system.reg" ]; then
+
+	# Directory exists, but without system.reg - wine will assume wrong platform, so create dummy system.reg
+	if [ -d "$WINEPREFIX" ] && [ ! -f "$WINEPREFIX/system.reg" ]; then
+		if [ "$WINEARCH" == "win32" ] || [ "$WINEARCH" == "win64" ]; then
+			echo -en "WINE REGISTRY Version 2\n\n#arch=$WINEARCH\n" > "$WINEPREFIX/system.reg"
+			echo "[$PRG] Forced creation of a $WINEARCH wine prefix."
+		fi
+	fi
+
+	DISPLAY="" "$WINE" wineboot.exe 2>&1 | progressbar "Please wait..." "Creating wine prefix"
+fi
+
+# Set default return value
+RET=0
+
+while [ $# -gt 0 ] ; do
+	DEP="$1"; INS=(); URL=""; SHA=""; EXT=""; DOWNLOADFILE=""; shift
+	case "$DEP" in
+		wine-prefix)
+			continue # The wine-prefix is created automatically for all packages
+			;;
+		wine-silverlight4-installer)
+			INS=(install_silverlight "4.1.10329.0")
+			URL="http://silverlight.dlservice.microsoft.com/download/6/A/1/6A13C54D-3F35-4082-977A-27F30ECE0F34/10329.00/runtime/Silverlight.exe"
+			SHA="b0e476090206b2e61ba897de9151a31e0182c0e62e8abd528c35d3857ad6131c"
+			;;
+		wine-silverlight5.0-installer)
+			INS=(install_silverlight "5.0.61118.0")
+			URL="http://silverlight.dlservice.microsoft.com/download/5/5/7/55748E53-D673-4225-8072-4C7A377BB513/runtime/Silverlight.exe"
+			SHA="dd45a55419026c592f8b6fc848dceface7e1ce98720bf13848a2e8ae366b29e8"
+			;;
+		wine-silverlight5.1-installer) # http://www.microsoft.com/getsilverlight/locale/en-us/html/Microsoft%20Silverlight%20Release%20History.htm
+			INS=(install_silverlight "5.1.30214.0" "latest")
+			URL="http://silverlight.dlservice.microsoft.com/download/B/A/9/BA94BEC9-5DBC-4B50-BC2B-046A42399067/30214.00/Silverlight.exe"
+			SHA="55806d7bacf61799eaee18b0e8a6eda7bf62e384174f506ee75bfa3e898b233c"
+			;;
+		wine-flash-installer) # http://www.adobe.com/de/software/flash/about/
+			INS=(install_flash "14_0_0_145")
+			URL="http://fpdownload.macromedia.com/get/flashplayer/pdc/14.0.0.145/install_flash_player.exe"
+			SHA="9224209235365cde5a89c04611943b8777ce8a2357df472defa21252e41b8c86"
+			;;
+		wine-flash-debug-installer)
+			INS=(install_flash "14_0_0_145")
+			URL="http://download.macromedia.com/pub/flashplayer/updaters/14/flashplayer_14_plugin_debug.exe"
+			SHA="5b0c8a4325d464a0fc5139602ce76c6791753c1056b6bdf87d8508576fa76084"
+			;;
+		wine-widevine-installer) # http://www.widevine.com/download/videooptimizer/index.html
+			INS=(install_widevine)
+			URL="https://dl.google.com/widevine/6.0.0.12442/WidevineMediaOptimizer_Win.xpi"
+			SHA="84cde1b83d8f5e4b287303a25e61227ce9a253268af6bd88b9a2f98c85129bc8"
+			EXT="zip"
+			;;
+		wine-unity3d-installer)
+			INS=(install_unity3d)
+			URL="http://webplayer.unity3d.com/download_webplayer-3.x/UnityWebPlayer.exe"
+			SHA="d252a967e104d2370aad5dea3066f3d5a8dee3adf2697fb36b9da646e4b39ea0"
+			;;
+		wine-x64-unity3d-installer)
+			INS=(install_x64_unity3d)
+			URL="http://webplayer.unity3d.com/download_webplayer-3.x/UnityWebPlayerFull64.exe"
+			SHA="8e36bd7ea0e0afb757b8f568cdb3fc3aac65db3616636fb2e156ab2236ac6ef7"
+			;;
+		wine-adobereader-installer) # http://get.adobe.com/de/reader/otherversions/
+			INS=(install_adobereader)
+			URL="http://ardownload.adobe.com/pub/adobe/reader/win/11.x/11.0.07/en_US/AdbeRdr11007_en_US.exe"
+			SHA="062e6a02e29cea96064364c3c66c227b1d6041e7b272e5f7b29145e6f4f44173"
+			;;
+		wine-foxitpdf-installer) # http://www.foxitsoftware.com/Secure_PDF_Reader/version_history.php
+			INS=(install_foxitpdf)
+			URL="http://cdn04.foxitsoftware.com/pub/foxit/reader/desktop/win/6.x/6.2/enu/EnterpriseFoxitReader621.0618_enu.msi"
+			SHA="7b0e2d19975fb0b6c5abd3f367c2d1190e15cb3f4243e91bb86d19da6b6e8c47"
+			;;
+		wine-shockwave-installer) # http://get.adobe.com/de/shockwave/otherversions/
+			INS=(install_shockwave "1213153")
+			URL="http://fpdownload.macromedia.com/get/shockwave/default/english/win95nt/latest/sw_lic_full_installer.exe"
+			SHA="e7ebe5771c741754bc933a3ad2a3fbd8c08619f3237342318d5751506d1a75ac"
+			;;
+		wine-grandstream-installer)
+			INS=(install_grandstream)
+			URL="http://www.grandstream.com/products/tools/surveillance/webcontrl_plugin.zip"
+			SHA="1162798378997373701967f3f0f291ae4c858e8cae29e55a5249e24f47f70df2"
+			;;
+		wine-mpg2splt-installer)
+			INS=(install_cabextract mpg2splt.ax --reg)
+			URL="http://download.microsoft.com/download/8/0/D/80D7E79D-C0E4-415A-BCCA-E229EAFE2679/dshow_nt.cab"
+			SHA="984ed15e23a00a33113f0012277e1e680c95782ce2c44f414e7af14e28e3f1a2"
+			;;
+		wine-wininet-installer)
+			INS=(install_wininet)
+			URL="http://download.microsoft.com/download/6/f/c/6fcc07f8-62e1-459e-aab3-06faa3adacff/IE-KB884931-v2-x86-enu.exe"
+			SHA="b3f31b0d523f03123e8def4f91ba2e64aaceb31d9bfe851516ad7f61b0268d4a"
+			;;
+		wine-mspatcha-installer)
+			INS=(install_mspatcha)
+			URL="http://download.microsoft.com/download/WindowsInstaller/Install/2.0/NT45/EN-US/InstMsiW.exe"
+			SHA="4c3516c0b5c2b76b88209b22e3bf1cb82d8e2de7116125e97e128952372eed6b"
+			;;
+		wine-hikvision-installer)
+			INS=(install_hikvision)
+			URL="http://cctvone.com/fillib/IP%20Camera/Hikvision-2DC-Series/CD/IE%20Client/WebComponents.exe"
+			SHA="04fec22ca61c657f6f46160e55334e3defeea0e193bc8ec6d7bb45c87e773361"
+			;;
+		wine-npactivex-installer) # https://code.google.com/p/np-activex/downloads/list
+			INS=(install_npactivex "6a31dac35cfda77ef4be724f226c5b54404aec61a81e663e47d39c7c9dd1580e")
+			URL="https://np-activex.googlecode.com/files/extension_1_5_0_7.crx"
+			SHA="12ba6c79079f53172ca897f717911c2613219236dca5ae58662d41636490e7a9"
+			EXT="zip"
+			;;
+		wine-roblox-installer)
+			INS=(install_roblox "ca7bb36aabe54be5")
+			URL="http://setup.roblox.com/version-ca7bb36aabe54be5-Roblox.exe"
+			SHA="7be0878706eb22ed09c8fe6ee401b744cf338d71a06060e61f159ab00852953a"
+			;;
+		wine-vizzedrgr-installer)
+			INS=(install_vizzedrgr)
+			URL="http://www.vizzed.co/VizzedRgrPlugin-v2.0.msi"
+			SHA="ddc99b1a6902e30f355533620637a2d1b7d1ff3b1bd76a65cb1fbd78b2b396cb"
+			;;
+		wine-viewright-caiway-installer) #https://www.caiway.nl/site/nl/applicatie/multiscreentvplugins
+			INS=(install_viewright_caiway)
+			URL="https://www.caiway.nl/downloads/ViewRightWebInstaller-3.5.0.0_CaiW.msi"
+			SHA="9436dea83e42204d0a9bc4d128c2f2693dd9c5f9636d5fa57441ef5886f3ab43"
+			;;
+		wine-triangleplayer-installer)
+			INS=(install_triangleplayer)
+			URL="http://107.6.61.221/TLT_GBE/TrianglePlayer_setup_GBE.exe"
+			SHA="30d871eb39002a52d405e3f40d2fb2047eb2e1f9b3597b27571633f442a5dea3"
+			;;
+		*)
+			echo "[$PRG] ERROR: No installer script found for $DEP." >&2
+			RET=1
+			break
+			;;
+	esac
+
+	# Is already installed?
+	if is_installed "$SHA"; then
+		echo "[$PRG] $DEP is already installed in '$WINEPREFIX'."
+		continue
+	fi
+
+	echo "[$PRG] Downloading and running $DEP."
+
+	# Fetch the download
+	if ! download "$URL" "$SHA" "$EXT"; then
+		echo "[$PRG] ERROR: Download of $DEP failed." >&2
+		RET=1
+		break
+	fi
+
+	# Do the installation
+	if ! eval "${INS[@]}"; then
+		echo "[$PRG] ERROR: Execution of $DEP failed." >&2
+		RET=1
+		break
+	fi
+
+	# Mark the package as installed
+	mark_installed "$SHA"
+done
+
+exit "$RET"
diff --git a/pipelight.spec b/pipelight.spec
index 7ddd5bb..3c63977 100644
--- a/pipelight.spec
+++ b/pipelight.spec
@@ -2,7 +2,7 @@
 #%%global rel_build 1
 
 # General needed defines.
-%global bburl		https://bitbucket.org/mmueller2012/%{name}/get
+%global bburl		https://bitbucket.org/mmueller2012/%{name}/
 %global commit		8b41e9505f7a8710b3817ae93ac46b3be5f96f1f
 %global shortcommit	%(c=%{commit};echo ${c:0:12})
 
@@ -10,20 +10,23 @@
 %{!?rel_build:%global commit_date	20140711}
 %{!?rel_build:%global gitver		git%{commit_date}-%{shortcommit}}
 %{!?rel_build:%global gitrel		.git%{commit_date}.%{shortcommit}}
-%{?rel_build: %global gittar		%{name}-%{version}.tar.gz}
+%{?rel_build:%global  gittar		%{name}-%{version}.tar.gz}
 %{!?rel_build:%global gittar		%{name}-%{version}-%{gitver}.tar.gz}
 
 Name:			pipelight
 Version:		0.2.7.1.1
-Release:		0.1%{?gitrel}%{?dist}
+Release:		0.2%{?gitrel}%{?dist}
 Summary:		NPAPI Wrapper Plugin for using Windows plugins in Linux browsers
 
 # No license-files in src-tarball.  Upstream is informed, see:
 # https://bitbucket.org/mmueller2012/pipelight/pull-request/11
 License:		BSD and (GPLv2+ or LGPLv2+ or MPLv1.1)
 URL:			http://%{name}.net/
-%{?rel_build:Source0:	%{bburl}/v%{version}.tar.gz#/%{?gittar}}
-%{!?rel_build:Source0:	%{bburl}/%{shortcommit}.tar.gz#/%{?gittar}}
+%{?rel_build:Source0:	%{bburl}get/v%{version}.tar.gz#/%{?gittar}}
+%{!?rel_build:Source0:	%{bburl}get/%{shortcommit}.tar.gz#/%{?gittar}}
+
+# Use the most recent dependency-installer-script provided in upstream's scm.
+Source1:		%{bburl}raw/master/share/install-dependency
 
 # See: https://bitbucket.org/mmueller2012/pipelight/pull-request/12/
 Patch0:			http://besser82.fedorapeople.org/patches/pipelight-0.2.7.1.1_improve-buildsys.patch
@@ -86,8 +89,11 @@ configuration and usage, please visit %{url}.
 	> bsd-3.txt &&							\
 %{_bindir}/touch -r src/npapi-headers/npruntime.h bsd-3.txt
 
-# Fix hashbang in install-dependency-script.
+# Replace the install-dependency-script with a more recent version
+# from upstream's scm and fix it's hashbang.
 _file="share/install-dependency"
+%{__rm} -f ${_file} &&							\
+%{__cp} -af %{SOURCE1} ${_file} &&					\
 %{__sed} -e '1 s~^#!.*$~#!%{_bindir}/bash~' < ${_file} > ${_file}.new &&\
 %{_bindir}/touch -r ${_file} ${_file}.new &&				\
 %{_bindir}/mv -f ${_file}.new ${_file}
@@ -110,9 +116,19 @@ _file="share/install-dependency"
 %install
 %make_install
 
+# Copy the packaged dependency-installer-script to some non-changing file.
+# The original file will be %%ghost inside the build rpm in case of manual
+# updates done by the user.  The real file will be installed during %%post.
+%{__cp} -af %{buildroot}%{_datadir}/%{name}/install-dependency		\
+	%{buildroot}%{_datadir}/%{name}/install-dependency.real
+%{_bindir}/touch %{buildroot}%{_datadir}/%{name}/install-dependency.sig
+
 
 %post
-# This will not enable any plugins.
+# This will not enable any plugins and restore the dependency-installer-script
+# shipped inside the recent package.
+%{__cp} -af %{_datadir}/%{name}/install-dependency.real			\
+	%{_datadir}/%{name}/install-dependency
 %{_bindir}/%{name}-plugin --create-mozilla-plugins &>/dev/null
 
 %preun
@@ -126,14 +142,28 @@ fi
 
 
 %files
+%dir %{_datadir}/%{name}
 %doc bsd-3.txt ChangeLog COPYRIGHT LICENSE
+%ghost %{_datadir}/%{name}/install-dependency
+%ghost %{_datadir}/%{name}/install-dependency.sig
 %{_bindir}/%{name}-plugin
-%{_datadir}/%{name}
+%{_datadir}/%{name}/*/
+%{_datadir}/%{name}/install-dependency.real
+%{_datadir}/%{name}/pluginloader*
+%{_datadir}/%{name}/sig-install-dependency.gpg
+%{_datadir}/%{name}/wine*
 %{_libdir}/%{name}
 %{_mandir}/man1/%{name}-plugin.1*
 
 
 %changelog
+* Fri Jul 11 2014 Björn Esser <bjoern.esser at gmail.com> - 0.2.7.1.1-0.2.git20140711.8b41e9505f7a
+- use the most recent dependency-installer-script provided in upstream's scm
+- copy the original dependency-installer-script to some non-changing file and
+  package that one as existing file, the real dependency-installer-script as
+  %%ghost; restore the real dependency-installer-script during %%post from
+  the packaged one
+
 * Fri Jul 11 2014 Björn Esser <bjoern.esser at gmail.com> - 0.2.7.1.1-0.1.git20140711.8b41e9505f7a
 - update to new snapshot git20140711.8b41e9505f7a8710b3817ae93ac46b3be5f96f1f
 - reworked spec-file for release or snapshot-builds


More information about the scm-commits mailing list