automatically generate repository files

This commit is contained in:
Xuan Sang LE 2020-05-21 12:29:55 +02:00
parent 24f887a2c0
commit 71e63d2bf2
2 changed files with 143 additions and 10 deletions

View File

@ -1,11 +1,93 @@
[ [
{
"pkgname": "About",
"name": "__(About AntOS)",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/About/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/About/build/release/About.zip"
},
{
"pkgname": "ActivityMonitor",
"name": "Activity monitor",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/README.md",
"category": "System",
"author": "Xuan Sang LE",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/build/release/ActivityMonitor.zip"
},
{
"pkgname": "GraphEditor",
"name": "Graph Editor",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/GraphEditor/README.md",
"category": "Office",
"author": "Xuan Sang LE",
"version": "0.0.4-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/GraphEditor/build/release/GraphEditor.zip"
},
{
"pkgname": "MarkOn",
"name": "Markdown editor",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/README.md",
"category": "Utils",
"author": "Xuan Sang LE",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/build/release/MarkOn.zip"
},
{
"pkgname": "OpenPage",
"name": "OpenPage",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OpenPage/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.2-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OpenPage/build/release/OpenPage.zip"
},
{
"pkgname": "Preview",
"name": "Preview",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Preview/README.md",
"category": "Utils",
"author": "Xuan Sang LE",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Preview/build/release/Preview.zip"
},
{
"pkgname": "RemoteDesktop",
"name": "WVNC remote desktop",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/README.md",
"category": "Other",
"author": "",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/RemoteDesktop/build/release/RemoteDesktop.zip"
},
{
"pkgname": "ShowCase",
"name": "ShowCase",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ShowCase/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ShowCase/build/release/ShowCase.zip"
},
{
"pkgname": "TinyEditor",
"name": "TinyEditor",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/TinyEditor/README.md",
"category": "Other",
"author": "",
"version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/TinyEditor/build/release/TinyEditor.zip"
},
{ {
"pkgname": "wTerm", "pkgname": "wTerm",
"name": "Terminal", "name": "Terminal",
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/README.md", "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/README.md",
"category": "System", "category": "System",
"author": "xsang.le@gmail.com", "author": "Xuan Sang LE",
"version": "0.0.3-a", "version": "0.0.1-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/build/release/wTerm.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/build/release/wTerm.zip"
} }
] ]

51
reposify.sh Executable file
View File

@ -0,0 +1,51 @@
#! /bin/bash
set -e
repodir=$1
repofile=$2
function get_json_entry()
{
cmd="cat $1 | sed -n 's/\"$2\"[[:space:]]*:[[:space:]]*\"\(.*\)\"[[:space:]]*,*/\1/p'|sed -e 's/^[[:space:]]*//'"
value=$(eval "$cmd")
echo "$value"
}
function join_by { local IFS="$1"; shift; echo "$*"; }
function gen_pkg_meta()
{
author=$(get_json_entry "$1/package.json" "author")
name=$(get_json_entry "$1/package.json" "name")
category=$(get_json_entry "$1/package.json" "category")
version=$(get_json_entry "$1/package.json" "version")
printf "\t{\n"
printf "\t\t\"pkgname\": \"%s\",\n" "$2"
printf "\t\t\"name\": \"%s\",\n" "$name"
printf "\t\t\"description\": \"https://raw.githubusercontent.com/lxsang/antosdk-apps/master/%s/README.md\",\n" "$2"
printf "\t\t\"category\": \"%s\",\n" "$category"
printf "\t\t\"author\": \"%s\",\n" "$author"
printf "\t\t\"version\": \"%s\",\n" "$version"
printf "\t\t\"download\": \"https://raw.githubusercontent.com/lxsang/antosdk-apps/master/%s/build/release/%s.zip\"\n" "$2" "$2"
printf "\t}\n"
}
# generate packages meta-data
[ ! -d "$repodir" ] && echo "No such directory: $repodir" && exit 1
[ -z "$repofile" ] && repofile="packages.json"
echo "[" > "$repofile"
for file in "$repodir"/* ; do
if [ -d "$file" ]; then
pkgname=$(basename "$file")
# test if it has release file
pkgpath="$file/build/release/$pkgname.zip"
if [ -f "$pkgpath" ] && [ -f "$file/package.json" ]; then
#read the package meta-data
meta=$(gen_pkg_meta "$file" "$pkgname")
printf "%s,\n" "$meta" >> "$repofile"
fi
fi
done
sed '$ s/,$//' < "$repofile" > "$repofile.tmp"
printf "\n]" >> "$repofile.tmp"
mv "$repofile.tmp" "$repofile"