Debian Codegraph @

deps.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # Check for the --yes command line argument to skip yes/no prompts
4 if [scip-shell system . . `[`. "$1" = "--yes" ]
5 then
6 YES=1
7 else
8 YES=0
9 fi
10
11 set -eu
12 set -o nounset
13 set -x
14
15 if ! whichscip-shell system . . which. lsb_release > /dev/nullscip-shell filesystem . . `/dev/null`.
16 then
17 lsb_releasescip-shell shell shell-project 0.0.0 lsb_release().() {
18 if [scip-shell system . . `[`. -f /etc/os-releasescip-shell filesystem . . `/etc/os-release`. ]
19 then
20 [[ "$1" = "-i" ]] && catscip-shell system . . cat. /etc/os-releasescip-shell filesystem . . `/etc/os-release`. | grepscip-shell system . . grep. ^"ID" | cutscip-shell system . . cut. -d= -f 2
21 [[ "$1" = "-r" ]] && catscip-shell system . . cat. /etc/os-releasescip-shell filesystem . . `/etc/os-release`. | grepscip-shell system . . grep. "VERSION_ID" | cutscip-shell system . . cut. -d= -d'"' -f 2
22 elif [scip-shell system . . `[`. -f /etc/lsb-releasescip-shell filesystem . . `/etc/lsb-release`. ]
23 then
24 [[ "$1" = "-i" ]] && catscip-shell system . . cat. /etc/lsb-releasescip-shell filesystem . . `/etc/lsb-release`. | grepscip-shell system . . grep. "DISTRIB_ID" | cutscip-shell system . . cut. -d= -f 2
25 [[ "$1" = "-r" ]] && catscip-shell system . . cat. /etc/lsb-releasescip-shell filesystem . . `/etc/lsb-release`. | grepscip-shell system . . grep. "DISTRIB_RELEASE" | cutscip-shell system . . cut. -d= -f 2
26 else
27 echoscip-shell system . . echo. Unknown
28 fi
29 }
30 fi
31
32 if [scip-shell system . . `[`. $YES -eq 0 ]
33 then
34 distro="${1:-$(lsb_releasescip-shell shell shell-project 0.0.0 lsb_release(). -i|cutscip-shell system . . cut. -f 2)}"
35 distro_version="${1:-$(lsb_releasescip-shell shell shell-project 0.0.0 lsb_release(). -r|cutscip-shell system . . cut. -f 2|cutscip-shell system . . cut. -c1-2)}"
36 else
37 distro="${2:-$(lsb_releasescip-shell shell shell-project 0.0.0 lsb_release(). -i|cutscip-shell system . . cut. -f 2)}"
38 distro_version="${2:-$(lsb_releasescip-shell shell shell-project 0.0.0 lsb_release(). -r|cutscip-shell system . . cut. -f 2|cutscip-shell system . . cut. -c1-2)}"
39 fi
40 APTCMD="apt"
41 APTGETCMD="apt-get"
42 APT_CANDIDATES="arj build-essential bzip2 cabextract cpio cramfsswap git gzip lhasa liblzma-dev liblzo2-dev locales lzop mtd-utils p7zip p7zip-full python3-distutils python3-setuptools python3-matplotlib python3-capstone python3-pycryptodome python3-gnupg python3-poetry pipx squashfs-tools sleuthkit srecord tar wget zlib1g-dev"
43
44 # Check for root privileges
45 if [scip-shell system . . `[`. $UID -eq 0 ]
46 then
47 echoscip-shell system . . echo. "UID is 0, sudo not required"
48 SUDO=""
49 else
50 SUDO="sudo -E"
51 fi
52
53 install_yaffshivscip-shell shell shell-project 0.0.0 install_yaffshiv().()
54 {
55 gitscip-shell system . . git. clone --quiet --depth 1 --branch "master" https://github.com/devttys0/yaffshiv
56 (cd yaffshiv && pipx install .)
57 rmscip-shell system . . rm. -rf yaffshiv
58 }
59
60 install_sasquatchscip-shell shell shell-project 0.0.0 install_sasquatch().()
61 {
62 gitscip-shell system . . git. clone --quiet --depth 1 --branch "master" https://github.com/devttys0/sasquatch
63 (cd sasquatch &&
64 wget https://github.com/devttys0/sasquatch/pull/47.patch &&
65 patchscip-shell system . . patch. -p1 < 47.patch &&
66 ./build.sh)
67 rmscip-shell system . . rm. -rf sasquatch
68 }
69
70 install_cramfstoolsscip-shell shell shell-project 0.0.0 install_cramfstools().()
71 {
72 # Downloads cramfs tools from sourceforge and installs them to $INSTALL_LOCATION
73 TIME=`datescip-shell system . . date. +%s`
74 INSTALL_LOCATION=/usr/local/binscip-shell filesystem . . `/usr/local/bin`.
75
76 # https://github.com/torvalds/linux/blob/master/fs/cramfs/README#L106
77 gitscip-shell system . . git. clone --quiet --depth 1 --branch "master" https://github.com/npitre/cramfs-tools
78 # There is no "make install"
79 (cd cramfs-tools \
80 && makescip-shell system . . make. \
81 && $SUDO install cramfsck $INSTALL_LOCATION)
82
83 rmscip-shell system . . rm. -rf cramfs-tools
84 }
85
86 install_pip_packagescip-shell shell shell-project 0.0.0 install_pip_package().()
87 {
88 PACKAGE="$1"
89 pipx install $PACKAGE
90 }
91
92 find_pathscip-shell shell shell-project 0.0.0 find_path().()
93 {
94 FILE_NAME="$1"
95
96 echoscip-shell system . . echo. -ne "checking for $FILE_NAME..."
97 whichscip-shell system . . which. $FILE_NAME > /dev/nullscip-shell filesystem . . `/dev/null`.
98 if [scip-shell system . . `[`. $? -eq 0 ]
99 then
100 echoscip-shell system . . echo. "yes"
101 return 0
102 else
103 echoscip-shell system . . echo. "no"
104 return 1
105 fi
106 }
107
108 # Make sure the user really wants to do this
109 if [scip-shell system . . `[`. $YES -eq 0 ]
110 then
111 echoscip-shell system . . echo. ""
112 echoscip-shell system . . echo. "WARNING: This script will download and install all required and optional dependencies for binwalk."
113 echoscip-shell system . . echo. " This script has only been tested on, and is only intended for, Debian based systems."
114 echoscip-shell system . . echo. " Some dependencies are downloaded via unsecure (HTTP) protocols."
115 echoscip-shell system . . echo. " This script requires internet access."
116 echoscip-shell system . . echo. " This script requires root privileges."
117 echoscip-shell system . . echo. ""
118 if [scip-shell system . . `[`. "$distro" != Unknown ]
119 then
120 echoscip-shell system . . echo. " $distro $distro_version detected"
121 else
122 echoscip-shell system . . echo. "WARNING: Distro not detected, using package-manager defaults"
123 fi
124 echoscip-shell system . . echo. ""
125 echoscip-shell system . . echo. -n "Continue [y/N]? "
126 read YN
127 if [scip-shell system . . `[`. "$(echoscip-shell system . . echo. "$YN" | grepscip-shell system . . grep. -i -e 'y' -e 'yes')" == "" ]
128 then
129 echoscip-shell system . . echo. "Quitting..."
130 exit 1
131 fi
132 elif [scip-shell system . . `[`. "$distro" != Unknown ]
133 then
134 echoscip-shell system . . echo. "$distro $distro_version detected"
135 else
136 echoscip-shell system . . echo. "WARNING: Distro not detected, using package-manager defaults"
137 fi
138
139 # Check for supported package managers and set the PKG_* envars appropriately
140 find_pathscip-shell shell shell-project 0.0.0 find_path(). $APTCMD
141 if [scip-shell system . . `[`. $? -eq 1 ]
142 then
143 find_pathscip-shell shell shell-project 0.0.0 find_path(). $APTGETCMD
144 if [scip-shell system . . `[`. $? -ne 1 ]
145 then
146 PKGCMD="$APTGETCMD"
147 PKGCMD_OPTS="install -y"
148 PKG_CANDIDATES="$APT_CANDIDATES"
149 fi
150 else
151 if "$APTCMD" install -s -y dpkg > /dev/nullscip-shell filesystem . . `/dev/null`.
152 then
153 PKGCMD="$APTCMD"
154 PKGCMD_OPTS="install -y"
155 PKG_CANDIDATES="$APT_CANDIDATES"
156 else
157 PKGCMD="$APTGETCMD"
158 PKGCMD_OPTS="install -y"
159 PKG_CANDIDATES="$APT_CANDIDATES"
160 fi
161 fi
162
163 # Install system packages
164 $SUDO $PKGCMD $PKGCMD_OPTS $PKG_CANDIDATES
165
166 # Do the install(s)
167 cd /tmpscip-shell filesystem . . `/tmp`.
168 if [scip-shell system . . `[`. $? -ne 0 ]
169 then
170 echoscip-shell system . . echo. "Package installation failed: $PKG_CANDIDATES"
171 exit 1
172 fi
173
174 install_pip_packagescip-shell shell shell-project 0.0.0 install_pip_package(). ubi_reader
175 install_pip_packagescip-shell shell shell-project 0.0.0 install_pip_package(). jefferson
176 install_sasquatchscip-shell shell shell-project 0.0.0 install_sasquatch().
177 install_yaffshivscip-shell shell shell-project 0.0.0 install_yaffshiv().
178 install_cramfstoolsscip-shell shell shell-project 0.0.0 install_cramfstools().
179