forked from korcankaraokcu/PINCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_pince.sh
executable file
·110 lines (94 loc) · 3.55 KB
/
install_pince.sh
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
#!/bin/bash
: '
Copyright (C) 2016-2017 Korcan Karaokçu <[email protected]>
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 3 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, see <http://www.gnu.org/licenses/>.
'
# this file cannot (or any file) be named `install.sh` since libtoolize(automake) will not work properly if it does
# it will create the necessary files in PINCEs directory instead of scanmems, which will result in having to run `sh autogen.sh`
# twice, see this link https://github.com/protocolbuffers/protobuf/issues/149#issuecomment-473092810
CURRENT_USER="$(who mom likes | awk '{print $1}')"
# assumes you're in scanmem directory
compile_scanmem() {
sh autogen.sh
./configure --prefix="$(pwd)"
make -j libscanmem.la
chown -R "${CURRENT_USER}":"${CURRENT_USER}" . # give permissions for normal user to change file
}
install_scanmem() {
echo "Downloading scanmem"
git submodule update --init --recursive
if [ ! -d "libpince/libscanmem" ]; then
mkdir libpince/libscanmem
chown -R "${CURRENT_USER}":"${CURRENT_USER}" libpince/libscanmem
fi
(
echo "Entering scanmem"
cd scanmem || exit
if [ -d "./.libs" ]; then
echo "Recompile scanmem? [y/n]"
read -r answer
if echo "$answer" | grep -iq "^[Yy]"; then
compile_scanmem
fi
else
compile_scanmem
fi
cp --preserve .libs/libscanmem.so ../libpince/libscanmem/libscanmem.so
cp --preserve gui/scanmem.py ../libpince/libscanmem
cp --preserve gui/misc.py ../libpince/libscanmem
echo "Exitting scanmem"
)
# required for relative import, since it will throw an import error if it's just `import misc`
sed -i 's/import misc/from \. import misc/g' libpince/libscanmem/scanmem.py
}
OS_NAME="Debian"
PKG_MGR="apt-get"
INSTALL_COMMAND="install"
PKG_NAMES_ALL="python3-pip gdb libtool intltool"
PKG_NAMES_DEBIAN="$PKG_NAMES_ALL python3-pyqt5 libreadline-dev"
PKG_NAMES_SUSE="$PKG_NAMES_ALL python3-qt5 gcc readline-devel python3-devel typelib-1_0-Gtk-3_0 make"
PKG_NAMES_FEDORA="$PKG_NAMES_ALL python3-qt5 readline-devel python3-devel"
PKG_NAMES_ARCH="python-pip python-pyqt5 readline intltool gdb lsb-release" # arch defaults to py3 nowadays
PKG_NAMES="$PKG_NAMES_DEBIAN"
PKG_NAMES_PIP="psutil pexpect distorm3 pygdbmi keyboard"
PIP_COMMAND="pip3"
LSB_RELEASE="$(command -v lsb_release)"
if [ -n "$LSB_RELEASE" ] ; then
OS_NAME="$(${LSB_RELEASE} -d -s)"
else
# shellcheck disable=SC1091
. /etc/os-release
OS_NAME="$NAME"
fi
case "$OS_NAME" in
*SUSE*)
PKG_MGR="zypper"
PKG_NAMES="$PKG_NAMES_SUSE"
;;
*Arch*)
PKG_MGR="pacman"
PKG_NAMES="$PKG_NAMES_ARCH"
INSTALL_COMMAND="-S"
PIP_COMMAND="pip"
;;
*Fedora*)
PKG_MGR="dnf -y"
PKG_NAMES="$PKG_NAMES_FEDORA"
;;
esac
# shellcheck disable=SC2086
sudo ${PKG_MGR} ${INSTALL_COMMAND} ${PKG_NAMES}
# shellcheck disable=SC2086
sudo ${PIP_COMMAND} install ${PKG_NAMES_PIP}
install_scanmem
echo "PINCE has been installed successfully!"
echo "Now, just run 'sh PINCE.sh' from terminal"