File: plugins.lib

package info (click to toggle)
playonlinux 4.1.1-1
  • links: PTS, VCS
  • area: contrib
  • in suites: wheezy
  • size: 11,208 kB
  • sloc: python: 6,173; sh: 5,358; ansic: 72; makefile: 8
file content (146 lines) | stat: -rwxr-xr-x 4,858 bytes parent folder | download
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/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
	
	#declaration de variables locale
	#le P c'est pour euh POL/Package/?
	local Puid Pfichier PinstDir PplugStatus PverStr Pversion plugStatus
	#la le U par contre c'est pour user
	local Uuid Ufichier UinstDir UplugStatus UverStr Uversion Uligne
	# _2 parce que avant c'était pas pareil 
	readonly ULST="$POL_USER_ROOT/configurations/plugins_2"
	touch $ULST

	#lecture du fichier ligne/ligne
	while read ligne
	do
		#sauter les lignes qui commence par #
		grep -q '^#' <<< $ligne && continue
		#et les lignes vides ... parce que ça fait plus propre
		grep -q '^$' <<< $ligne && continue

		#paf pif split!
		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)


		# On complique un peu le truc (07/07/2011)
		install="false"
		[ "$POL_OS" = "Linux" ] && [ "$Plinux" = "1" ] && install="true"
		[ "$POL_OS" = "Mac" ] && [ "$Pmac" = "1" ] && install="true"
		
		if [ "$install" = "true" ]
		then
		[ "$SILENT" = "TRUE" ] || POL_Debug_Message "$(eval_gettext "Checking plugin: ")$PinstDir..."
		
		Uligne=$(grep "^$Puid;" $ULST)
		#tres important le ; !
		
		plugStatus="$PplugStatus" #ouai ouai c'est débile d'utiliser 2 variables pour la même chose :D

		#chk si la ligne existe déjà
		if [ -n "$Uligne" ] ; then
			#oui

			#la même mais avec un U =) 
			#y a des trucs dont on se fiche mais bon c/c is great
			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 replace automaticly invalid number by 0 
			let "Uversion = Uversion"
			let "Pversion = Pversion"

			#chk version
			#si la version du P est la même ou plus old que l'U on passe au plugin suivant
			[ $Pversion -gt $Uversion ] || continue

			#bon ben la c'est sur le gus a vieux truc
				[ "$SILENT" = "TRUE" ] || POL_Debug_Message "   -->$(eval_gettext 'Updating plugin. Previous: ')'$UverStr'/$Uversion. $(eval_gettext 'New: ')'$PverStr'/$Pversion."
			
			#est ce que le plugin était déjà actif?
			#UplugStatus="disable"
			[ -f "$POL_USER_ROOT/plugins/$UinstDir/enabled" ] && plugStatus="enable"
			#la c'est barbare ... si déjà actif on force l'update actif ...
			#sinon dépend du plugins.lst


			#on vire l'ancienne installation (utile si le plugin change de place)
			#les perdants sont les plugins qui gardent des fichiers de config dans leur dossier ... tant pis pour eux
			rm -rf "$POL_USER_ROOT/plugins/$UinstDir/"

			#on vire la ligne dans le fichier utilisateur 
			grep -v "^$Puid;" "$ULST" > "$POL_USER_ROOT/tmp/ulst.tmp"
			mv -f "$POL_USER_ROOT/tmp/ulst.tmp" "$ULST"
			#voilà ménage fait plus qu'à installer
		fi

		[ "$SILENT" = "TRUE" ] || POL_Debug_Message "   -->$(eval_gettext "Installing plugin: ")'$PinstDir'."
		#là on installe
		"$PLAYONLINUX/playonlinux-pkg" -i "$PLAYONLINUX/plugins/$Pfichier" > /dev/null

		## =~ ok pour enable et enabled
		#active or nto
		if [[ "$plugStatus" =~ "enable" ]]
		then
			touch "$POL_USER_ROOT/plugins/$PinstDir/enabled"
		fi

		#et on enregistre qu'on vient de faire
		echo "$Puid;$Pfichier;$PinstDir;$plugStatus;$PverStr;$Pversion" >> $ULST
	fi
	#est voilà on continue .... et moi j'ai fait cramer mes patates
	done < "$PLAYONLINUX/plugins/plugins.lst"
}

#### This part of the script load plugins libs
mkdir -p "$REPERTOIRE/plugins"
cd "$REPERTOIRE/plugins"
for file in *
do
	MY_FILE="$REPERTOIRE/plugins/$file"
	if [ -e "$MY_FILE/enabled" ]
	then
		#echo "Loading $file"
		if [ -e "$MY_FILE/scripts/lib" ]
		then
			source "$MY_FILE/scripts/lib"
		fi
	fi
done

cd "$REPERTOIRE"