forked from puppylinux-woof-CE/woof-CE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
petget
executable file
·41 lines (41 loc) · 1.57 KB
/
petget
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
#!/bin/bash
#set -x
#rm /root/petget.log
#exec &> >(tee -a /root/petget.log)
PKG_PATH_sc0ttman="`which pkg`"
PKG_PATH="$(realpath "$1")"
PKG_NAME="$(basename "$PKG_PATH")"
export PWD="$(realpath "${PWD}")"
confirm_download(){
#confirm want to install... #Based on: https://github.com/puppylinux-woof-CE/woof-CE/blob/849a9faa7ea8cac74e04d04e4f99f4425652c26b/woof-code/rootfs-skeleton/usr/local/petget/petget#L166
if [ "$DISPLAY" ]; then
. /usr/lib/gtkdialog/box_yesno "$(gettext 'Puppy Package Manager')" "$(gettext 'Do you want to install this package:')" "<b>${FULLPKGNAME}</b>"
if [ "$EXIT" != "yes" ]; then
exit 0
fi
else
dialog --yesno "$(gettext 'Do you want to install this package:') $FULLPKGNAME" 0 0
if [ $? -ne 0 ];then
exit 0
fi
fi
}
echo_commands(){
echo ". /etc/profile"
echo "cd \"$(realpath "$PWD")\""
echo "bash -x $PKG_PATH_sc0ttman i \"$PKG_PATH\" #2>&1 | tee -a /root/petget.log"
echo ""
}
if [ ! -z "$PKG_PATH_sc0ttman" ]; then
confirm_download
#echo_commands > /tmp/bla
bash <(echo_commands)
#bash -x /tmp/bla 2>&1 | tee /root/petget.log
#"$PKG_PATH_sc0ttman" -i "$PKG_PATH" 2>&1 | tee -a /root/petget.log
else
CUR_DIR=dirname "$(readlink -f "$0")" #https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself
cd "$CUR_DIR"
PETGET_PATH="../local/petget/petget" #See if a relative path is possible (useful in prefixed systems)
[ ! -x "$(readlink -f "$PETGET_PATH")" ] && PETGET_PATH="/usr/local/petget/petget" #otherwise use absolute paths
"$PETGET_PATH" "$@"
fi