jw-pkg/scripts/ini-tools.sh
Jan Lindemann bc883deed4 Everywhere: Remove everything non-essential for "make clean all"
This commit removes everything not strictly necessary for running
"make clean all" inside jw-build.

packaging jw-devtest. This cuts the repo down from 24077 to 4725
lines of code.

The idea is to

1) Further remove bloat from the remaining bits

2) Re-add what's necessary to build and package other essential repos.

   The decision should be based on whether or not jw-build can also be
   useful in a non-janware context.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-14 15:02:56 +01:00

56 lines
860 B
Bash

ini_section()
{
local inifile="$1"
local sec="$2"
cat "$inifile" |
cut -d\# -f1 |
tr -s '\n' '\n' |
sed -n "/^ *\[$sec\]/,/^ *\[/ p" |
grep -v '^ *\[' |
sed '/^ *$/ d'
}
ini_value()
{
local inifile="$1"
local path="$2"
local sec=`echo "$path" | sed 's/\.[^.]\+$//'`
local key=`echo "$path" | sed 's/.*\.//'`
# echo "path=>$path<"
# echo "sec=>$sec<"
# echo "key=>$key<"
if [ "$key" = "$path" ]; then
ini_section "$inifile" "$path"
return 0
fi
ini_section "$inifile" "$sec" | sed "
/^ *$key *=/ !d
s/^ *$key *= *//
s/ *$//
/^ *$/ d
"
}
ini_has_section()
{
local inifile="$1"
local sec="$2"
grep -q "^ *\[$sec\]" $inifile || return 1
}
ini_has_value()
{
ini_value $@ | grep -q .
}
ini_escape()
{
cat | sed '
s/\$/\\$/g
s/`/\\\`/g
'
}