95 lines
2.5 KiB
Bash
Executable File
95 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Author : Ismael Barros² <ismael@barros2.org>
|
|
# License : BSD http://en.wikipedia.org/wiki/BSD_license
|
|
|
|
pg4l_dir=$(dirname $(readlink -f $0))
|
|
source "$pg4l_dir/util.sh"
|
|
|
|
OIFS=$IFS
|
|
NIFS=$'\n'
|
|
IFS=$NIFS
|
|
|
|
for i in $(ls -1t "$@"); do
|
|
pkg=$(basename "$i")
|
|
name=${pkg% *}
|
|
v=${pkg##* }
|
|
v=${v%.*}
|
|
release=${v#*r}
|
|
version=${v/r$release/}
|
|
version=${version%-}
|
|
#size=$(du "$i" | awk '{printf "%0.2f\n", $1/1000}')
|
|
size=$(du "$i" | awk '{printf $1}')
|
|
|
|
mountpoint="$(mktemp -d --suffix=_unpackAppImage)"
|
|
fuseiso -p "$i" "$mountpoint" || exit 1
|
|
desktopFile="$(ls -1 "$mountpoint"/*.desktop | head -n1)"
|
|
|
|
url=
|
|
if [ -f "$desktopFile" ]; then
|
|
title=$(desktopFile_getParameter "$desktopFile" "X-AppImage-Title")
|
|
url=$(desktopFile_getParameter "$desktopFile" "X-AppImage-URL")
|
|
fi
|
|
|
|
icon=
|
|
if [ -f "$mountpoint/.DirIcon" ]; then
|
|
icon=$(mktemp)
|
|
cp "$mountpoint/.DirIcon" "$icon"
|
|
fi
|
|
|
|
fusermount -u "$mountpoint"
|
|
|
|
|
|
icons=
|
|
screenshots=
|
|
|
|
[ -n "$icon" ] && icons+="$icon"
|
|
|
|
cat <<END
|
|
{
|
|
"name" : "$pkg",
|
|
"version" : "$version-r$release",
|
|
"description" : "",
|
|
"partner" : "1036",
|
|
"basePrice" : "0",
|
|
"file" : "$pkg",
|
|
"size" : "$size",
|
|
"previews" : [
|
|
END
|
|
|
|
for j in $icons; do
|
|
if [ -f "$j" ]; then
|
|
#size=$(identify -format "%[fx:w]x%[fx:h]" "$j")
|
|
width=$(identify -format "%[fx:w]" "$j")
|
|
case "$width" in
|
|
"512") subtype="huge" ;;
|
|
"256") subtype="large" ;;
|
|
"128") subtype="big" ;;
|
|
"64") subtype="medium" ;;
|
|
"48") subtype="small" ;;
|
|
"32") subtype="small" ;;
|
|
"22") subtype="tiny" ;;
|
|
*) subtype="unknown" ;;
|
|
esac
|
|
echo { \"type\" : \"icon\", \"subtype\" : \"$subtype\", \"file\" : \"$j\", \"mimetype\" : \"$(file -b --mime-type "$j")\" }
|
|
fi
|
|
done
|
|
for j in $screenshots; do
|
|
[ -f "$j" ] && echo { \"type\" : \"screenshot\", \"subtype\" : \"screen1\", \"file\" : \"$j\", \"mimetype\" : \"$(file -b --mime-type "$j")\" }
|
|
done
|
|
|
|
cat <<END
|
|
],
|
|
"tags" : [
|
|
{"type" : "license", "title" : "Proprietary / All rights reserved"},
|
|
{"type" : "contentrating", "title" : "Everyone"},
|
|
{"type" : "assetType", "title" : "game"},
|
|
{"type" : "author", "title" : "__AUTHOR__"},
|
|
{"type" : "publisher", "title" : "PortableLinuxGames.org"},
|
|
{"type" : "created", "title" : "$(date +%d-%m-%Y)"},
|
|
{"type" : "url", "title" : "$url"}
|
|
]
|
|
}
|
|
END
|
|
|
|
done
|