diff options
author | nishi <nishi@vegaa.systems> | 2023-07-07 23:40:27 +0000 |
---|---|---|
committer | nishi <nishi@vegaa.systems> | 2023-07-07 23:40:27 +0000 |
commit | d963772c6633a0610898aaba2ae90d461e8f2de8 (patch) | |
tree | 64d9e0a7b09b205d5f42011aa2bfe88e321f706d /tools/meta-rip |
should be working, should be
git-svn-id: https://svn.vegaa.systems/svn/vega-Vega/trunk@7 a8a8aea2-181d-ee11-89e8-15fd0e089fc4
Diffstat (limited to 'tools/meta-rip')
-rwxr-xr-x | tools/meta-rip | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/meta-rip b/tools/meta-rip new file mode 100755 index 0000000..873a003 --- /dev/null +++ b/tools/meta-rip @@ -0,0 +1,42 @@ +#!/bin/bash +# $Id$ + +if [[ ! -f $1 ]] +then + echo "File not found: $1" + exit +fi + +readelf -S $1 | grep -q "\.meta\.note" > /dev/null +if [ $? -ne 0 ] +then + echo "No metadata in ELF; '.meta.note' non-existent" + exit +fi + +meta=$(objcopy $1 /dev/null --dump-section .meta.note=/dev/stdout | cat | tr -d '\0') + +# Remove the leading and trailing '$' characters +meta=${meta#'$'} +meta=${meta%'$'} + +# Use regular expression to extract the cookie, filename, author, and description +if [[ $meta =~ ^([^:]+):\s*([^,]+),\s*([^,]+),\s*(.*)$ ]]; then + cookie=${BASH_REMATCH[1]} + filename=${BASH_REMATCH[2]} + author=${BASH_REMATCH[3]} + description=${BASH_REMATCH[4]} + cookie=${cookie%?} # Remove the last character +fi + +if [[ $cookie != "Vega" ]] +then + echo "Invalid cookie found!" + exit +fi + +echo "Cookie: $cookie" +echo "Filename: $filename" +echo "Author: $author" +echo "Description: $description" + |