Last active
April 12, 2025 13:32
-
-
Save hghwng/c4bd86cc773a93955b5ff692cc9ea59d to your computer and use it in GitHub Desktop.
SciTools Understand for Arch Linux
This file contains hidden or 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 hidden or 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) | |
echo -ne "$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)" \ | |
"\xb8\x01\x00\x00\x00\xc3" | |
patch "$1" \ | |
"STI::MaintainApp::TestHeliosHeartbeat()" \ | |
"\xc3" | |
} |
This file contains hidden or 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() { | |
echo "Checking new version" | |
local _buf=$(curl https://licensing.scitools.com/download/getDownloads/Understand/0) | |
local _pkgprefix=$(echo "$_buf" | jq -r .versionNumber) | |
local _pkgbuild=$(echo "$_buf" | jq -r .latestBuild) | |
_url=$(echo "$_buf" | jq -r ".filePaths[0].path") | |
_pkgver="$_pkgprefix.$_pkgbuild" | |
echo "Version: $_pkgver" | |
} | |
if [[ -v PKGVER ]]; then | |
# See also: https://support.scitools.com/support/solutions/folders/70000470871 | |
echo "PKGVER is set to: $PKGVER" | |
_pkgver="$PKGVER" | |
_url="https://latest.scitools.com/Understand/Understand-${PKGVER}-Linux-64bit.tgz" | |
else | |
check-version | |
fi | |
pkgname=understand-bin | |
pkgver="$_pkgver" | |
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') | |
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 hidden or 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 hidden or 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; |
Understand-6.5.1184-Linux-64bit.tgz
patch之后依然有demo相关提示,感觉是没完全成功
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好,请问是怎么使用?谢谢