This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/000_validate.sh

115 lines
3.8 KiB
Bash
Raw Normal View History

2021-07-23 02:36:56 +02:00
#!/bin/bash
2021-10-14 23:46:36 +02:00
clear
2021-07-23 02:36:56 +02:00
2021-10-14 23:46:36 +02:00
echo "--> Validating inx files with xmllint. Only errors are printed to console"
for folder in */ ; do
xmllint --noout --relaxng ./inkscape.extension.rng ${folder}*.inx > /dev/null 2>> 000_xmllint.out
done
grep -v "validates\|warning: failed to load external entity" 000_xmllint.out; rm 000_xmllint.out
2021-07-23 02:36:56 +02:00
2021-10-14 23:46:36 +02:00
#complete set of meta information
AGGLOMERATED_JSON=""
for folder in */ ; do
if [[ ! -f "${folder}meta.json" ]]; then
2021-10-14 23:46:36 +02:00
echo "meta.json missing for ${folder}"
else
JSON_OKAY=$(jq -e . ${folder}meta.json)
if [ $? -eq 0 ]; then
echo ${AGGLOMERATED_JSON} > /tmp/prevJson
AGGLOMERATED_JSON=$(jq -s ".[0] + .[1]" /tmp/prevJson ${folder}meta.json)
else
echo Format error in ${folder}meta.json
fi
2021-10-14 23:46:36 +02:00
#DEBUG
#cat ${folder}meta.json | jq
2021-10-14 23:46:36 +02:00
fi
done
#print overall json
#echo $AGGLOMERATED_JSON | jq
2021-10-14 23:46:36 +02:00
echo "--> Show unique license kinds used:"
echo $AGGLOMERATED_JSON | jq -r '.[]|{license}|.[]' | sort | uniq -c
2021-10-14 23:46:36 +02:00
echo "--> show unique list of involved contributors (thanks/credits):"
#echo $AGGLOMERATED_JSON | jq -r '.[]|{main_authors}|.[]|.[]' | sort | uniq -c
echo $AGGLOMERATED_JSON | jq -r '.[]|{main_authors}|.[]|.[]' | sort | uniq
2021-10-14 23:46:36 +02:00
#show extensions which are in gallery
GALLERY_EXTENSIONS=$(echo $AGGLOMERATED_JSON | jq -r '.[]|{inkscape_gallery_url}|.[]' | sort | grep -v "null")
for GALLERY_EXTENSION in ${GALLERY_EXTENSIONS}; do
EXTENSION=$(echo ${AGGLOMERATED_JSON} | jq -r '.[]|select(.inkscape_gallery_url=="'$GALLERY_EXTENSION'")|{name}|.[]')
done
echo "--> Count of inx files:"
2021-07-23 02:36:56 +02:00
INX=$(find ./ -type f -name "*.inx" | wc -l)
echo INX: $INX
2021-10-14 23:46:36 +02:00
echo "--> Count of extension folders:"
2021-07-23 02:36:56 +02:00
FOLDERS=$(ls -d */ | wc -l)
echo FOLDERS: $FOLDERS
2021-07-23 02:36:56 +02:00
README="../../README.md"
#replace values in README.md
sed -i 's/\*\*.* extension folders\*\*/\*\*'${FOLDERS}' extension folders\*\*/g' ${README}
sed -i 's/\*\* with .* \.inx files\*\*/\*\* with \*\*'${INX}' \.inx files\*\*/g' ${README}
2021-07-23 02:36:56 +02:00
echo "Removing unrequired pyc cache files"
find . -type d -name "__pycache__" -exec rm -rf {} \; > /dev/null
2021-07-23 02:36:56 +02:00
read -p "Update zip files for zipmirror?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Building extension zip files for zipmirror"
TARGETDIR="../../../mightyscape-1.X-zipmirror"
mkdir -p $TARGETDIR > /dev/null 2>&1
for EXTENSION in */; do
EXTENSION="${EXTENSION%/}" #strip trailing slash
EXTRA=""
2021-12-02 18:12:25 +01:00
DEPS=$(jq -r 'try .[]|.dependent_extensions|.[]' ${EXTENSION}/meta.json)
DEPS=$(echo $DEPS|tr -d '\n')
#if dependencies are not empty, then ...
if [[ ! -z $DEPS ]]; then
EXTRA="$DEPS"
fi
ZIPFILE=$TARGETDIR/$EXTENSION.zip
echo "--> creating/updating $ZIPFILE"
2021-12-02 18:12:25 +01:00
zip -ru $ZIPFILE $EXTENSION/ 000_about_fablabchemnitz.svg $EXTRA > /dev/null 2>&1
done
fi
2021-07-23 02:36:56 +02:00
read -p "Build local gallery extension zip files?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Building Inkscape gallery extension zip files"
TARGETDIR="../000_Inkscape_Gallery"
2021-10-14 23:46:36 +02:00
mkdir -p $TARGETDIR > /dev/null 2>&1
#show extensions which are in gallery
GALLERY_EXTENSIONS=$(echo $AGGLOMERATED_JSON | jq -r '.[]|{inkscape_gallery_url}|.[]' | sort | grep -v "null")
for GALLERY_EXTENSION in ${GALLERY_EXTENSIONS}; do
EXTENSION="$(echo ${AGGLOMERATED_JSON} | jq -r '.[]|select(.inkscape_gallery_url=="'$GALLERY_EXTENSION'")|{path}|.[]')"
2021-12-02 18:12:25 +01:00
EXTRA=""
DEPS=$(jq -r 'try .[]|.dependent_extensions|.[]' ${EXTENSION}/meta.json)
DEPS=$(echo $DEPS|tr -d '\n')
#if dependencies are not empty, then ...
if [[ ! -z $DEPS ]]; then
EXTRA="$DEPS"
fi
2021-10-14 23:46:36 +02:00
ZIPFILE=$TARGETDIR/$EXTENSION.zip
rm $ZIPFILE > /dev/null 2>&1
2021-12-02 18:12:25 +01:00
echo "--> creating/updating $ZIPFILE"
zip -ru $ZIPFILE $EXTENSION/ 000_about_fablabchemnitz.svg $EXTRA > /dev/null 2>&1
2021-10-14 23:46:36 +02:00
done
2021-07-23 02:36:56 +02:00
fi