Commit 089f8944 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm pack common.sh: add get_json_value and use it

parent e244b6ab
...@@ -13,7 +13,7 @@ mv 1C-Connect-Linux-x64* opt/$PRODUCT ...@@ -13,7 +13,7 @@ mv 1C-Connect-Linux-x64* opt/$PRODUCT
echo "true" > ./opt/$PRODUCT/app/bin/updater echo "true" > ./opt/$PRODUCT/app/bin/updater
VERSION="$(grep version_name opt/$PRODUCT/dist.json | sed -e 's|",.*||' -e 's|.*"||')" VERSION="$(get_json_value opt/$PRODUCT/dist.json version_name)"
[ -n "$VERSION" ] || fatal "Can't get version from dist.json file." [ -n "$VERSION" ] || fatal "Can't get version from dist.json file."
PKGNAME=$PRODUCT-$VERSION PKGNAME=$PRODUCT-$VERSION
......
...@@ -78,6 +78,26 @@ has_wildcard() ...@@ -78,6 +78,26 @@ has_wildcard()
[ "${1/\*/}" != "$1" ] [ "${1/\*/}" != "$1" ]
} }
# ["version"]
parse_json_value()
{
local field="$1"
echo "$field" | grep -q -E "^\[" || field='["'$field'"]'
epm tool json -b | grep -m1 -F "$field" | sed -e 's|.*[[:space:]]||' | sed -e 's|"\(.*\)"|\1|g'
}
# URL/file ["version"]
get_json_value()
{
if is_url "$1" ; then
eget -q -O- "$1" | parse_json_value "$2"
else
[ -s "$1" ] || fatal "File $1 is missed, can't get json"
parse_json_value "$2" < "$1"
fi
}
__handle_tarname() __handle_tarname()
{ {
# TODO: we don't know PKGNAME here # TODO: we don't know PKGNAME here
......
...@@ -15,7 +15,7 @@ erc unpack $BASENAME.tar.gz || fatal ...@@ -15,7 +15,7 @@ erc unpack $BASENAME.tar.gz || fatal
mkdir -p opt mkdir -p opt
mv Postman/app opt/postman mv Postman/app opt/postman
VERSION=$(cat "opt/postman/resources/app/package.json" | epm --inscript tool json -b | grep version | awk 'gsub(/"/, "", $2) {print $2}') #' VERSION="$(get_json_value opt/postman/resources/app/package.json version)"
[ -n "$VERSION" ] || fatal "Can't get package version" [ -n "$VERSION" ] || fatal "Can't get package version"
install_file opt/postman/resources/app/assets/icon.png /usr/share/pixmaps/postman.png install_file opt/postman/resources/app/assets/icon.png /usr/share/pixmaps/postman.png
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment