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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
|
#!/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.
# scripts.lib
# -----------
#
# This lib contains useful tools for scriptors
POL_Shortcut_InsertBeforeWine ()
{
# Insert a command into a script just before running wine
# Usage: POL_Shortcut_InsertBeforeWine [Application] [Line to insert]
POL_Debug_Message "Inserting before POL_Wine : $2"
Application="$1"
CommandsToInsert="$2"
COMMANDS="${CommandsToInsert}" perl -ni -e '
if(!$done && /^POL_Wine/) {
print "$ENV{COMMANDS}\n";
$done=1;
}
print;' "$REPERTOIRE/shortcuts/${Application}"
}
POL_Open()
{
# Extended xdg-open function, works for mac
# Usage : POL_Open whatever you want
POL_Debug_Message "Opening: $@"
[ "$POL_OS" == "Mac" ] && open "$@"
[ "$POL_OS" == "Linux" ] && xdg-open "$@"
}
POL_Browser ()
{
# Open default's user browser
# Usage : POL_Brower [URL]
POL_Open "$@"
}
POL_System_TmpCreate()
{
# Create a temporary directory for a script
# Usage: POL_System_TmpCreate [tmp_name]
[ "$1" = "" ] && POL_Debug_Fatal "TmpName not defined !"
mkdir -p "$POL_USER_ROOT/tmp/$1"
export POL_System_TmpDir="$POL_USER_ROOT/tmp/$1"
export POL_System_TmpName="$1"
}
POL_System_TmpDelete()
{
# Delete the temporary directory created before
# Usage: POL_System_TmpDelete
[ ! "$POL_System_TmpName" = "" ] && rm -rf "$POL_USER_ROOT/tmp/$POL_System_TmpName" || POL_Debug_Warning "POL_System_TmpName is not defined !"
}
POL_System_SetArch()
{
# Set the architecture to use for the current script
# Usage: POL_System_SetArch (auto|x86|amd64)
# If amd64 is specified and not supported, the script will end
# Auto, x86, amd64
if [ ! "$1" == "x86" ] && [ ! "$1" == "amd64" ]
then
[ "$AMD64_COMPATIBLE" == "True" ] && export POL_ARCH="amd64" || export POL_ARCH="x86"
fi
if [ "$1" == "x86" ]
then
export POL_ARCH="x86"
fi
if [ "$1" == "amd64" ]
then
[ "$AMD64_COMPATIBLE" == "True" ] && export POL_ARCH="amd64" || POL_Debug_Fatal "amd64 is not supported by your system"
fi
POL_Debug_Message "POL_ARCH set to $POL_ARCH"
}
POL_Shortcut_GetPrefix()
{
# Get a prefixname from a shortcut
# Usage: POL_Shortcut_GetPrefix [Shortcut]
[ "$1" = "" ] && POL_Debug_Error "No shortcut specified"
fichier="$REPERTOIRE/shortcuts/$1"
if [ -e "$fichier" ]
then
fichier="$(cat "$fichier" | grep WINEPREFIX | tail -n 1 | sed s/'\/\//\/'/)"
fichier="${fichier/"$POL_USER_ROOT"/""}"
fichier="$(printf "$fichier" | cut -d "/" -f2)"
fi
printf "$fichier" | tr -d \"
}
POL_GetLocalIcon()
{
# Get a local icon and add it into playonlinux
# Usage: POL_GetLocalIcon [PlayOnLinux's shortcut] [icon name]
convert "$HOME/.local/share/icons/$2" -geometry 32X32 "$REPERTOIRE/icones/32/$1"
convert "$HOME/.local/share/icons/$2" "$REPERTOIRE/icones/full_size/$1"
}
POL_ExtractIcon()
{
# Extract the icon of a .exe or .ico file
# Usage: POL_ExtractIcon [.exe file] [output image file]
mkdir -p "$REPERTOIRE/tmp/win32Icon"
case "$1" in
*.[iI][cC][oO])
cp "$1" "$REPERTOIRE/tmp/win32Icon/icons-brut"
;;
*)
wrestool -x -t14 "$1" &> "$REPERTOIRE/tmp/win32Icon/icons-brut"
;;
esac
(cd "$REPERTOIRE/tmp/win32Icon"
icotool -x "icons-brut" -o "$REPERTOIRE/tmp/win32Icon/"
find . -name "*32x32x32.png" > icons-list
find . -name "*32x32x16.png" >> icons-list
find . -name "*32x32x8.png" >> icons-list
find . -name "*32x32x4.png" >> icons-list
ICON_FILE=$(cat "icons-list" | head -n 1)
[ "$ICON_FILE" != "" ] && [ -s "$ICON_FILE" ] && cp "$ICON_FILE" "$2" || POL_Debug_Warning "Icon was not extracted"
[ "$ICON_FILE" != "" ] && [ -s "$ICON_FILE" ] && [ ! "$3" = "" ] && cp "$ICON_FILE" "$3"
)
rm -r "$REPERTOIRE/tmp/win32Icon"
}
POL_ExtractBiggestIcon()
{
# Extract the biggest icon of a .exe or .ico file
# Usage: POL_ExtractCustomIcon [.exe file] [output image file] [size]
mkdir -p "$REPERTOIRE/tmp/win32Icon"
case "$1" in
*.[iI][cC][oO])
cp "$1" "$REPERTOIRE/tmp/win32Icon/icons-brut"
;;
*)
wrestool -x -t14 "$1" &> "$REPERTOIRE/tmp/win32Icon/icons-brut"
;;
esac
(cd "$REPERTOIRE/tmp/win32Icon"
icotool -x "icons-brut" -o "$REPERTOIRE/tmp/win32Icon/"
find . -name "*256x256x32.png" > icons-list
find . -name "*256x256x16.png" >> icons-list
find . -name "*256x256x8.png" >> icons-list
find . -name "*256x256x4.png" >> icons-list
find . -name "*128x128x32.png" >> icons-list
find . -name "*128x128x16.png" >> icons-list
find . -name "*128x128x8.png" >> icons-list
find . -name "*128x128x4.png" >> icons-list
find . -name "*96x96x32.png" >> icons-list
find . -name "*96x96x16.png" >> icons-list
find . -name "*96x96x8.png" >> icons-list
find . -name "*96x96x4.png" >> icons-list
find . -name "*48x48x32.png" >> icons-list
find . -name "*48x48x16.png" >> icons-list
find . -name "*48x48x8.png" >> icons-list
find . -name "*48x48x4.png" >> icons-list
find . -name "*32x32x32.png" >> icons-list
find . -name "*32x32x16.png" >> icons-list
find . -name "*32x32x8.png" >> icons-list
find . -name "*32x32x4.png" >> icons-list
ICON_FILE=$(cat "icons-list" | head -n 1)
[ "$ICON_FILE" != "" ] && [ -s "$ICON_FILE" ] && cp "$ICON_FILE" "$2" || POL_Debug_Warning "Icon was not extracted"
)
rm -r "$REPERTOIRE/tmp/win32Icon"
}
POL_Shortcut()
{
# Make a shortcut
# Usage: POL_Shortcut [binary] [shortcut name] [playonlinux website icon] [argument]
# If playonlinux website icon is not specified, playonlinux will try to extract it from the program
# Possibly to use a path instead of the executable.
Binaire="$1"
SpecialArg="$4"
if [ "$2" = "" ]
then
NOMICONE_="$1"
else
NOMICONE_="$2"
fi
mkdir -p "$REPERTOIRE/icones/32"
mkdir -p "$REPERTOIRE/icones/full_size"
ICON_WEB_NAME="$3"
ICON_OK=0
## On chope le dossier du binaire
cd "$WINEPREFIX" || POL_Debug_Fatal "Prefixe $WINEPREFIX does not exists"
cd drive_c || POL_Debug_Fatal "drive_c folder does not exists"
binary_path=""
if [ "$(echo "$Binaire" | grep "/")" = "" ]; then # Binaire
binary_path="$(find ./ -iname "$Binaire" -a -type f | tail -n 1)"
else # Chemin
[ -e "./$Binaire" ] && binary_path="./$Binaire"
fi
binary_dir="$(dirname "$binary_path")"
Binaire="$(basename "$binary_path")"
[ "$binary_dir" = "" ] && POL_Debug_Fatal "Can't find $Binaire"
if [ -n "$ICON_WEB_NAME" ]; then
if [ ! "$OFFLINE" = "1" ]; then # On peut le télécharger...
$POL_WGET "$SITE/icones/$ICON_WEB_NAME" -O- > "$REPERTOIRE/icones/full_size/$NOMICONE_" || rm "$REPERTOIRE/icones/full_size/$NOMICONE_" # On prend l'icone full size
fi
if [ -f "$REPERTOIRE/icones/full_size/$NOMICONE_" ]; then
convert -resize 32 "$REPERTOIRE/icones/full_size/$NOMICONE_" "$REPERTOIRE/icones/32/$NOMICONE_" # On fabrique l'icone 32*32
ICON_OK=1
fi
elif [ "$ICON_OK" -ne 1 ]; then # Pas d'incone sur le web => Création à partir de l'exe...
POL_ExtractIcon "$WINEPREFIX/drive_c/$binary_dir/$Binaire" "$REPERTOIRE/icones/32/$NOMICONE_"
POL_ExtractBiggestIcon "$WINEPREFIX/drive_c/$binary_dir/$Binaire" "$REPERTOIRE/icones/full_size/$NOMICONE_"
fi
if [ "$Binaire" = "" ]
then
POL_Debug_Error "Binary not found! : $1\n\nHave you installed the program to the default location?"
fi
## On génère le binaire
echo "#!/bin/bash" > "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "[ \"\$PLAYONLINUX\" = \"\" ] && exit 0" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "source \"\$PLAYONLINUX/lib/sources\"" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "export WINEPREFIX=\"$WINEPREFIX\"" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "export WINEDEBUG=\"-all\"" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
[ ! "$LOGTITLE" = "" ] && echo "#POL_Log=$LOGTITLE" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "cd \"$WINEPREFIX/drive_c/$binary_dir\"" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
echo "POL_Wine \"$Binaire\" $SpecialArg \"\$@\"" >> "$REPERTOIRE/shortcuts/$NOMICONE_"
chmod +x "$REPERTOIRE/shortcuts/$NOMICONE_"
if [ ! "$(POL_Config_Read NO_DESKTOP_ICON)" = "TRUE" ]
then
if [ "$POL_OS" = "Mac" ]
then
POL_SetupWindow_AutoApp "$NOMICONE_"
else
if [ -f "$REPERTOIRE/icones/full_size/$NOMICONE_" ]; then # L'icone existe...
iconPath="$REPERTOIRE/icones/full_size/$NOMICONE_"
else
iconPath="$PLAYONLINUX/etc/playonlinux.png"
fi
generer_icone "$iconPath" "$NOMICONE_" "$DESKTOP" "$PLAYONLINUX/playonlinux --run \"$NOMICONE_\""
fi
fi
POL_Debug_Message "Shortcut created: $Binaire $NOMICONE_"
}
POL_Shortcut_QuietDebug()
{
# Disable "crash" message on exitcode != 0 unless in debug mode
# Usage: POL_Shortcut_QuietDebug "shortcutname"
echo '[ "$WINEDEBUG" = "-all" ] && exit 0' >> "$REPERTOIRE/shortcuts/$1"
}
POL_Call()
{
# Call a function in PlayOnLinux website
# Usage: POL_Call [function name]
POL_Debug_Message "Calling $1"
if [ ! "$1" = "" ]
then
OLD_PC_DIR="$PWD"
cd "$REPERTOIRE/tmp/"
$POL_WGET "$SITE/V4_data/repository/get_file.php?version=playonlinux-$VERSION&id=$1" -O- > "$1"
polMd5="$(POL_MD5_file "$1")"
if [ "$polMd5" = "68b329da9893e34099c7d8ad5cb9c940" ] || [ "$polMd5" = "0f1b63a74ab217a19270be0df9e0590d" ] # Empty file
then
POL_Debug_Error "Function $1 does not exist!"
else
POL_Source "$@"
fi
cd "$OLD_PC_DIR"
fi
}
POL_Call_list ()
{
# Make a list so that the user can choose functions to install
# Usage: POL_Call_List
[ "$WINEPREFIX" == "" ] && POL_Debug_Fatal "POL_Call_list : WINEPREFIX is not set"
wineserver -k
ITEMS=$($POL_WGET $SITE/V4_data/repository/getf.php -O-)
POL_SetupWindow_checkbox_list "$(eval_gettext "Please make your choice")" "$APPLICATION_TITLE" "$ITEMS" "/"
old="$IFS"
IFS=/
set "$APP_ANSWER"
for i in $*
do
POL_Debug_Message "POL_Call_list is calling $i"
IFS="$old"
POL_Call "$i"
IFS=/
done
IFS="$old"
}
POL_Tools_GenID()
{
# Generate a random string
# Usage: POL_Tools_GenID
N_LETTRES="$1"
if [ "$1" != "" ]
then
N_LETTRES=$1
fi
ALPHA='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
MOT=""
i=0
while ((i < $N_LETTRES));
do
CHIFFRE=$(( $RANDOM % ${#ALPHA}));
printf ${ALPHA:$CHIFFRE:1};
(( i=i+1 ))
done
}
POL_Download ()
{
# Download a file and place it in the current directory
# Usage: POL_Download [URL] [MD5]
POL_Debug_Message "Downloading $1"
local URL="$1"
local FICHIER="${URL##*/}"
if [ "$URL" = "" ]
then
POL_Debug_Error "POL_Download - URL is missing !"
else
POL_SetupWindow_download "$(eval_gettext 'Please wait while $APPLICATION_TITLE is downloading:')\n$FICHIER" "$TITLE" "$URL"
if [ "$2" = "" ]
then
POL_Debug_Warning "POL_Download - MD5 is missing!"
elif [ "$2" = "NO_MD5" ]
then
POL_Debug_Message "Skipping MD5 checksum control"
else
local LOCAL_MD5="$(POL_MD5_file "$FICHIER")"
if [ ! "$2" = "$LOCAL_MD5" ]
then
local SERVER_MD5="$2"
POL_SetupWindow_message "$(eval_gettext 'Error ! Files mismatch\n\nLocal : $LOCAL_MD5\nServer : $SERVER_MD5')"
POL_Debug_Error "POL_Download - MD5 sum mismatch !"
fi
fi
fi
}
POL_Download_Resource ()
{
# Download a file and place it in the resource directory (if it does not exist)
# Usage: POL_Download_Resource [URL] [MD5] (Folder)
POL_Debug_Message "Downloading resource $1"
# 1 - URL
# 2 - MD5 SUM
local URL="$1"
local FICHIER="${URL##*/}"
mkdir -p "$POL_USER_ROOT/ressources/$3"
cd "$POL_USER_ROOT/ressources/$3"
if [ ! -e "$FICHIER" ] || [ ! "$(POL_MD5_file "$FICHIER")" = "$2" ]
then
if [ "$URL" = "" ]
then
POL_Debug_Error "POL_Download - URL is missing !"
else
rm "$FICHIER"
POL_SetupWindow_download "$(eval_gettext "Please wait while $APPLICATION_TITLE is downloading:") $FICHIER" "$TITLE" "$URL"
if [ "$2" = "" ]
then
POL_Debug_Warning "POL_Download - MD5 is missing !"
else
local LOCAL_MD5="$(POL_MD5_file "$FICHIER")"
if [ ! "$2" = "$LOCAL_MD5" ]
then
local SERVER_MD5="$2"
POL_SetupWindow_message "$(eval_gettext 'Error ! Files mismatch\n\nLocal : $LOCAL_MD5\nServer : $SERVER_MD5')"
POL_Debug_Error "POL_Download - MD5 sum mismatch !"
fi
fi
fi
fi
}
POL_MD5 ()
{
# Give the md5 sum of a string
# Usage: POL_MD5 <string>
if [ "$POL_OS" == "Mac" ]
then
printf "$1" | md5
fi
if [ "$POL_OS" == "Linux" ]
then
printf "$1" | md5sum | awk '{print $1}'
fi
}
POL_MD5_file ()
{
# Give the md5 sum of a file
# Usage: POL_MD5_file <file>
if [ "$POL_OS" == "Mac" ]
then
cat "$1" | md5
fi
if [ "$POL_OS" == "Linux" ]
then
cat "$1" | md5sum | awk '{print $1}'
fi
}
POL_base64()
{
[ "$POL_OS" = "Linux" ] && base64
[ "$POL_OS" = "Mac" ] && openssl base64
}
POL_unbase64()
{
[ "$POL_OS" = "Linux" ] && base64 -d
[ "$POL_OS" = "Mac" ] && openssl base64 -d
}
POL_System_ExtractSingleFile ()
{
# This function has been written by hifi
# Extract a single file from an archive, with a progressbar
# Usage: POL_System_ExtractSingleFile <archive> <file> <destination>
local archive="$1"
local file="$2"
local dest="$3"
local archivename=`basename "$archive"`
local filename=`basename "$file"`
local szpid
local szip=`which 7z`
POL_Debug_Message "Extracting single file : \"$archive\", \"$file\", \"$dest\""
if [ "$szip" == "" ]; then
POL_Debug_Fatal "$(eval_gettext '7z not installed, please check that you have 7zip installed and try again')"
return 1
fi
local size=`"$szip" l -slt "$archive" "$file" | grep '^Size' | cut -d' ' -f3`
if [ "$size" == "" ]; then
POL_Debug_Error "$(eval_gettext 'Failed to locate ${dest} from ${archive}')"
return 1
fi
POL_SetupWindow_pulsebar "$(eval_gettext 'Extracting ${filename} from ${archivename}')" "$TITLE"
rm -f "$dest"
"$szip" e -so "$archive" "$file" 2>/dev/null 1>"$dest" & szpid=$!
while kill -0 $szpid 2>/dev/null; do
#POL_SetupWindow_pulse $(((`stat -c%s "$dest"` * 100) / "$size")) # Does not work for Mac OS
sleep 1
POL_SetupWindow_pulse $(((`ls -l "$dest" | awk '{print $5}'` * 100) / $size))
done
POL_SetupWindow_pulse 100
#if [ `stat -c%s "$dest"` != "$size" ]; then
if [ `ls -l "$dest" | awk '{print $5}'` != "$size" ]; then
POL_Debug_Error "$(eval_gettext 'Extracted file size does not match!')"
return 1
fi
return 0
}
POL_System_cp ()
{
# Extract a single file with a progressbar
# Usage: POL_System_cp <file> <destination>
local file="$1"
local dest="$2"
local filename=`basename "$file"`
#local szpid
POL_Debug_Message "Copying single file : \"$archive\", \"$file\", \"$dest\""
local size="$(ls -l $file | awk '{print $5}')"
POL_SetupWindow_pulsebar "$(eval_gettext 'Copying ${filename}')" "$TITLE"
rm -f "$dest"
cp "$file" "$dest" 2>/dev/null & szpid=$!
while kill -0 $szpid 2>/dev/null; do
sleep 0.3
POL_SetupWindow_pulse $(((`ls -l "$dest" | awk '{print $5}'` * 100) / $size))
done
POL_SetupWindow_pulse 100
if [ "`ls -l "$dest" | awk '{print $5}'`" != "$size" ]; then
POL_Debug_Error "$(eval_gettext 'File size does not match!')"
return 1
fi
return 0
}
POL_System_wget ()
{
# Wget with a progressbar
# Usage: Same than wget except that the title of the file is the first parameter, URL must be the second one parameter
url="$1"
POL_Debug_Message "Downloading $1 with wget"
shift
FICHIER="$1"
shift
POL_SetupWindow_pulsebar "$(eval_gettext 'Please wait while $APPLICATION_TITLE is downloading:')\n$FICHIER" "$TITLE"
prev=0
${POL_WGET/-q} -v -c "$url" "$@" 2>&1 | \
grep -o --line-buffered '[0-9]\{1,2\}%' | \
while read perc; do
if [ -n "$perc" -a "$perc" != "$prev" ]; then
POL_SetupWindow_pulse ${perc%%%}
prev="$perc"
fi
done
POL_SetupWindow_pulse 100
return 0
}
POL_System_CopyDirectory()
{
# Usage POL_System_CopyDirectory [From] [To] [expected size]
if [ "$3" = "" ]; then
esize="$(du "$1"| tail -n 1 | awk '{print $1}')"
else
esize="$3"
fi
cp -R "$1/." "$2/" & pid="$!"
POL_SetupWindow_DirectoryProgress "$2" "$esize" "$pid"
}
POL_Shortcut_Document()
{
# Add a manual to a shortcut
# Usage : POL_Shortcut_Document <Shortcut Name> <file path>
[ "$2" = "" ] && return
rm -f "$POL_USER_ROOT/configurations/manuals/$1"
ln -s "$2" "$POL_USER_ROOT/configurations/manuals/$1"
}
POL_RequiredVersion ()
{
# Stop the current script is the current version is lower the required one
# Usage : POL_RequiredVersion [VERSION]
NEEDED="$1"
if VersionLower "$VERSION" "$NEEDED"
then
POL_Debug_Warning "POL_RequiredVersion not satisfied! User version :$VERSION, expected $NEEDED"
POL_SetupWindow_message "$(eval_gettext 'Sorry, $APPLICATION_TITLE $VERSION is too old to continue.\n$APPLICATION_TITLE $NEEDED is required.')" "$TITLE"
POL_SetupWindow_Close
exit 0
fi
}
POL_AdvisedVersion ()
{
# Alert the user, but don't stop the current script is the current version is lower the required one
# Usage : POL_AdvisedVersion [VERSION]
NEEDED="$1"
if VersionLower "$VERSION" "$NEEDED"
then
POL_Debug_Warning "POL_AdvisedVersion not satisfied! User version :$VERSION, expected $NEEDED"
POL_SetupWindow_message "$(eval_gettext 'Warning: You are running $APPLICATION_TITLE $VERSION.\n$APPLICATION_TITLE $NEEDED is recommended to continue.')" "$TITLE"
fi
}
POL_Configurator_runparts ()
{
# Inside a configurator, in a place where SetupWindow and Debug are initialized, sources
# the the configurator parts named after main configurator script plus some extension
# (say the patch they're related to) in alphabetical order.
# Usage : POL_Configurator_runparts
shopt -s nullglob
for conf in "$0".*; do
source "$conf"
done
}
|