1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#!/bin/bash
# Copyright (C) 2007-2011 PlayOnLinux Team
# Copyright (C) 2007-2011 Pâris Quentin
# 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.
# plugins.lib
# -----------
#
# This lib manages playonlinux's plugins
install_plugins ()
{
# Install defaults plugin into home directory
# Usage: install_plugins
# Package local variables
local Puid Pfichier PinstDir PplugStatus PverStr Pversion plugStatus
# User local variables
local Uuid Ufichier UinstDir UplugStatus UverStr Uversion Uligne
# _2 because format is not backward compatible
readonly ULST="$POL_USER_ROOT/configurations/plugins_2"
touch $ULST
cat < "$PLAYONLINUX/plugins/plugins.lst" |\
while read ligne
do
# skip empty and comment lines
grep -q '^#' <<< $ligne && continue
grep -q '^$' <<< $ligne && continue
# Split fields
Puid=$(cut -d';' -f1 <<< $ligne)
Pfichier=$(cut -d';' -f2 <<< $ligne)
PinstDir=$(cut -d';' -f3 <<< $ligne)
PplugStatus=$(cut -d';' -f4 <<< $ligne)
PverStr=$(cut -d';' -f5 <<< $ligne)
Pversion=$(cut -d';' -f6 <<< $ligne)
Plinux=$(cut -d';' -f7 <<< $ligne)
Pmac=$(cut -d';' -f8 <<< $ligne)
PfreeBSD=$(cut -d';' -f8 <<< $ligne)
# Install only OS compatible plugins (07/07/2011)
install="false"
[ "$POL_OS" = "Linux" -a "$Plinux" = "1" ] && install="true"
[ "$POL_OS" = "FreeBSD" -a "$PfreeBSD" = "1" ] && install="true"
[ "$POL_OS" = "Mac" -a "$Pmac" = "1" ] && install="true"
[ "$install" = "true" ] || continue
[ "$SILENT" = "TRUE" ] || POL_Debug_Message "$(eval_gettext "Checking plugin: ")$PinstDir..."
# Look for existing local installation, the ";" matters
Uligne=$(grep "^$Puid;" $ULST)
if [ -n "$Uligne" ] ; then
# Plugin is already installed
# Split fields again
Uuid=$(cut -d';' -f1 <<< $Uligne)
Ufichier=$(cut -d';' -f2 <<< $Uligne)
UinstDir=$(cut -d';' -f3 <<< $Uligne)
UplugStatus=$(cut -d';' -f4 <<< $Uligne)
UverStr=$(cut -d';' -f5 <<< $Uligne)
Uversion=$(cut -d';' -f6 <<< $Uligne)
#using let to automaticly replace invalid numbers with 0
let "Uversion = Uversion"
let "Pversion = Pversion"
# Check if plugin needs upgrading
[ $Pversion -gt $Uversion ] || continue
[ "$SILENT" = "TRUE" ] || POL_Debug_Message " -->$(eval_gettext 'Updating plugin. Previous: ')'$UverStr'/$Uversion. $(eval_gettext 'New: ')'$PverStr'/$Pversion."
# Already enabled plugins stay enabled (otherwise go with plugins.lst default status)
[ -f "$POL_USER_ROOT/plugins/$UinstDir/enabled" ] && PplugStatus="enable"
# Uninstall previous version, plugins shouldn't store state in their installation directory!
rm -rf "$POL_USER_ROOT/plugins/$UinstDir/"
grep -v "^$Puid;" "$ULST" > "$POL_USER_ROOT/tmp/ulst.tmp"
mv -f "$POL_USER_ROOT/tmp/ulst.tmp" "$ULST"
# Ready for reinstallation
fi
# Installation
[ "$SILENT" = "TRUE" ] || POL_Debug_Message " -->$(eval_gettext "Installing plugin: ")'$PinstDir'."
"$PLAYONLINUX/playonlinux-pkg" -i "$PLAYONLINUX/plugins/$Pfichier" > /dev/null
## =~ to match either enable or enabled
if [[ "$PplugStatus" =~ "enable" ]]
then
touch "$POL_USER_ROOT/plugins/$PinstDir/enabled"
fi
# Update installed packages list
echo "$Puid;$Pfichier;$PinstDir;$PplugStatus;$PverStr;$Pversion" >> $ULST
done
}
#### Load plugins libs
PREVPWD="$PWD"
mkdir -p "$POL_USER_ROOT/plugins" &&
cd "$POL_USER_ROOT/plugins" &&
for plugin in *
do
plugin_dir="$POL_USER_ROOT/plugins/$plugin"
if [ -e "$plugin_dir/enabled" ]
then
#echo "Loading $plugin"
if [ -e "$plugin_dir/scripts/lib" ]
then
source "$plugin_dir/scripts/lib"
fi
fi
done
cd "$PREVPWD"
|