-
-
Save jiaoyk/5685f7809525d2a5bfd5d10c4557357d to your computer and use it in GitHub Desktop.
SciTools Understand for Arch Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg/ | |
src/ | |
understand-bin-*.pkg.* | |
Understand-*.tgz | |
.SRCINFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fn2vma path function => vma_in_hex | |
fn2vma() { | |
nm -CD "$1" | grep " $2\$" | grep -o "^[^ ]*" | sed -e 's/^0*/0x0/' | |
} | |
# vma2offset path vma => file_offset_in_dec | |
vma2offset() { | |
local query="$2" | |
objdump -h "$1" | grep -Po "( +[0-9a-f]+){4}" | sed -Ee 's/ +0+/ 0x0/g' | | |
while read line; do | |
read size vma lma offset <<< "$line" | |
local vma_end=$(("$vma" + "$size")) | |
if [[ "$query" -ge "$vma" ]] && [[ "$query" -le "$vma_end" ]]; then | |
echo $(("$query" - "$vma" + "$offset")) | |
return | |
fi | |
done | |
} | |
# patch_bytes path offset bytes_in_hex | |
patch_binary() { | |
local patch_path=$(mktemp) | |
xxd -r -p <<< "$3" >> "$patch_path" | |
local patch_length=$(stat --printf="%s" "$patch_path") | |
local backup_path=$(mktemp) | |
cp "$1" "$backup_path" -f | |
local part2_begin="$2" | |
local part3_begin=$(("$part2_begin" + "$patch_length" + 1)) | |
head "$backup_path" -c "$part2_begin" > "$1" | |
cat "$patch_path" >> "$1" | |
tail "$backup_path" -c "+$part3_begin" >> "$1" | |
rm "$patch_path" "$backup_path" | |
} | |
patch() { | |
local binary="$1" | |
local symbol="$2" | |
local content="$3" | |
local vma=$(fn2vma "$binary" "$symbol") | |
[[ -z "$vma" ]] && echo "Symbol not found" && exit 1 | |
echo "VMA of $symbol = $vma" | |
local offset=$(vma2offset "$binary" "$vma") | |
[[ -z "$vma" ]] && echo "Offset not found" && exit 2 | |
echo "File offset = $offset" | |
patch_binary "$binary" "$offset" "$content" | |
echo "Patch completed" | |
} | |
patch_understand() { | |
patch "$1" \ | |
"HeliosLicenseManager::testGuiLicense(int&, HeliosLicenseManager::LoginStatus&, bool)" \ | |
"b8 01 00 00 00 c3" | |
patch "$1" \ | |
"STI::MaintainApp::TestHeliosHeartbeat()" \ | |
"c3" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: Alex Sarum <rum.274.4 at gmail dot com> | |
check-version() { | |
_buf=$(curl https://licensing.scitools.com/download/getDownloads/Understand/0) | |
_pkgprefix=$(echo "$_buf" | jq -r .versionNumber) | |
_pkgbuild=$(echo "$_buf" | jq -r .latestBuild) | |
_url=$(echo "$_buf" | jq -r ".filePaths[0].path") | |
} | |
echo "Checking new version" | |
check-version | |
echo "prefix $_pkgprefix build $_pkgbuild" | |
pkgname=understand-bin | |
pkgver="$_pkgprefix.$_pkgbuild" | |
pkgrel=1 | |
pkgdesc="Static analysis tool for maintaining, measuring & analyzing critical or large code bases." | |
arch=('x86_64') | |
url="https://scitools.com/" | |
license=('custom') | |
depends=('libx11' 'libxau' 'libxcb' 'libxdmcp' 'libxext' 'ncurses5-compat-libs') | |
options=('!strip') | |
source_x86_64=($_url | |
"understand.desktop" | |
"understand" | |
) | |
md5sums_x86_64=('SKIP' | |
'86ea741c38198d7291d5126ef0cd17f8' | |
'feb6804e81096bd28d611d19e45aebe2') | |
package() { | |
install -d "$pkgdir/opt" | |
cp -r "$srcdir/scitools" "$pkgdir/opt/" | |
# Remove bundled libraries. | |
rm -f "$pkgdir/opt/scitools/bin/linux64/"{libfreetype.so.6,libx*} | |
install -Dm755 "$srcdir/understand" "$pkgdir/usr/bin/understand" | |
install -Dm644 "understand.desktop" "$pkgdir/usr/share/applications/understand.desktop" | |
install -Dm644 "$pkgdir/opt/scitools/bin/linux64/understand_64.png" "$pkgdir/usr/share/pixmaps/understand.png" | |
source $srcdir/../patch.sh | |
patch_understand "$pkgdir/opt/scitools/bin/linux64/understand" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export LD_LIBRARY_PATH=/opt/scitools/bin/linux64 | |
unset QT_PLUGIN_PATH | |
exec /opt/scitools/bin/linux64/understand "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Name=Understand | |
Version=1.0 | |
Exec=/usr/bin/understand | |
Icon=understand | |
Type=Application | |
Terminal=false | |
Comment=Analyze it, measure it, visualize it, maintain it - Understand it | |
Comment[ru]=Статический анализатор кода | |
GenericName=Static analysis tool | |
Categories=Development;IDE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment