Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doit.sh #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions doit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export WGET_CMD=`which wget`
export UNZIP_CMD=`which unzip`
URL="https://media.amazonwebservices.com/AWS-Design/Arch-Center/17.1.19_Update/AWS_Simple_Icons_EPS-SVG_v17.1.19.zip"
URL="https://d1.awsstatic.com/webteam/architecture-icons/q2-2021/Asset-Package_04302021.7efed5c84a17020a6ddd81ef1f42e86ccd33a531.zip"

echo "JUST DO IT!! (waiting for enter keystroke)"
read
Expand All @@ -17,22 +17,26 @@ elif [[ $ret_code -eq 4 ]]; then
echo "location unavailable"
exit 1;
fi
$UNZIP_CMD icons.zip
$UNZIP_CMD -q icons.zip

mkdir svg

find -name '*.svg' -exec cp {} svg/ \;
find -name '* *' -print0 | xargs -0 rm
find svg -name '\.*' -exec rm -v {} \;
for svgfile in `ls svg/* | grep '&'`; do mv -v $svgfile svg/`basename $svgfile | sed -e s/\&/and/g` ; done

echo "Break here (ctrl-c) to do it manually or press enter to JUST DO IT!"
read

make

echo "All done"
echo "Copy .output/shapes.sheet to ~/.dia/sheets/"
echo "Copy .output/shapes/* to ~/.dia/shapes/"
echo
echo "Yesterday you said tomorrow..."
echo "Copy shapes to user's home?"
echo "Break here (ctrl-c) to do it manually or press enter to JUST DO IT!"
read

cp -v .outputs/shapes.sheet ~/.dia/sheets/AWS.sheet
cp -v .outputs/shapes/* ~/.dia/shapes/
echo "Copy .output/shapes.sheet to ~/.dia/sheets/"
echo "Copy .output/shapes/* to ~/.dia/shapes/"
cp -av .outputs/shapes.sheet ~/.dia/sheets/AWS.sheet
cp -av .outputs/shapes/* ~/.dia/shapes/
168 changes: 74 additions & 94 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


.DEFAULT : __generate__
.PHONY : __generate__ __clean__
.SUFFIXES :
Expand All @@ -11,9 +9,6 @@
_svg_inputs_root := $(abspath ./svg)
_svg_inputs := $(wildcard $(_svg_inputs_root)/*.svg)

_eps_inputs_root := $(abspath ./eps)
_eps_inputs := $(wildcard $(_eps_inputs_root)/*.eps)

_outputs_root := $(abspath ./.outputs)
_shapes_outputs_root := $(_outputs_root)/shapes
_shapes_sheet_output := $(_outputs_root)/shapes.sheet
Expand All @@ -22,111 +17,96 @@ _shapes_sheet_output := $(_outputs_root)/shapes.sheet
__generate__ : $(_outputs_root)

__clean__ :
test ! -e $(_outputs_root) || rm -R $(_outputs_root)
test ! -e $(_outputs_root) || rm -R $(_outputs_root)


$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.svg, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.svg \
: $(_svg_inputs_root)/%.svg makefile
$(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
cp -T $(<) $(@)
cat <$(@) \
| tr '\t\n\r' ' ' \
| tr -s ' ' \
| sed -E -e 's!( *)<!\n<!g' -e 's!>( *)!>\n!g' \
| sed -E -e '/^$$/d' \
| cat >$(@)1
mv -T $(@)1 $(@)

#$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.svg, $(_svg_inputs)) \
# : $(_shapes_outputs_root)/%.svg \
# : $(_eps_inputs_root)/%.eps makefile
# $(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
# test ! -e $(@) || rm $(@)
# test -e $(@D) || mkdir -p $(@D)
# #a# epstopdf $(<) --outfile=$(@).pdf
# #a# inkscape --export-plain-svg $(@) $(@).pdf
# #b# pstoedit -f plot-svg $(<) $(@)
# cat <$(@) \
# | tr '\t\n\r' ' ' \
# | tr -s ' ' \
# | sed -E -e 's!( *)<!\n<!g' -e 's!>( *)!>\n!g' \
# | sed -E -e '/^$$/d' \
# | cat >$(@)1
# mv -T $(@)1 $(@)
: $(_shapes_outputs_root)/%.svg \
: $(_svg_inputs_root)/%.svg makefile
$(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
cp -T $(<) $(@)
cat <$(@) \
| tr '\t\n\r' ' ' \
| tr -s ' ' \
| sed -E -e 's!( *)<!\n<!g' -e 's!>( *)!>\n!g' \
| sed -E -e '/^$$/d' \
| cat >$(@)1
mv -T $(@)1 $(@)

$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.svg, $(_svg_inputs))


$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.shape, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.shape \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
name="$$( basename -- $(@F) .shape | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo '<?xml version="1.0" encoding="UTF-8"?>' ; \
echo '<shape' ; \
echo ' xmlns="http://www.daa.com.au/~james/dia-shape-ns"' ; \
echo ' xmlns:svg="http://www.w3.org/2000/svg">' ; \
echo ' <name>'"$${name}"'</name>' ; \
echo ' <icon>$(strip $(patsubst %.shape, %.png, $(@F)))</icon>' ; \
echo ' <aspectratio type="fixed" /> ' ; \
echo ' <default-width>2</default-width>' ; \
echo ' <default-height>2</default-height>' ; \
echo ' <connections>' ; \
echo ' <point x="35" y="35" main="yes" />' ; \
echo ' </connections>' ; \
echo ' <textbox x1="0" x2="70" y1="0" y2="70" text="..." align="center" resize="no" />' ; \
sed -n -E \
-e '/^<\?xml/d' \
-e '/^<!DOCTYPE/d' \
-e '/^<!--/d' \
-e 's!<([^/:]+[ >])!<svg:\1!g' \
-e 's!</([^/:]+>)!</svg:\1!g' \
-e 's!fill="([^"]+)"!style="stroke: foreground; stroke-linecap: round; stroke-linejoin: round; fill: \1;"!g' \
-e 'p' \
<$(<) ; \
echo '</shape>' ; \
} >$(@)
: $(_shapes_outputs_root)/%.shape \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [make shapes definitions] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
name="$$( basename -- $(@F) .shape | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo '<?xml version="1.0" encoding="UTF-8"?>' ; \
echo '<shape' ; \
echo ' xmlns="http://www.daa.com.au/~james/dia-shape-ns"' ; \
echo ' xmlns:svg="http://www.w3.org/2000/svg">' ; \
echo ' <name>'"$${name}"'</name>' ; \
echo ' <icon>$(strip $(patsubst %.shape, %.png, $(@F)))</icon>' ; \
echo ' <aspectratio type="fixed" /> ' ; \
echo ' <default-width>2</default-width>' ; \
echo ' <default-height>2</default-height>' ; \
echo ' <connections>' ; \
echo ' <point x="35" y="35" main="yes" />' ; \
echo ' </connections>' ; \
echo ' <textbox x1="0" x2="70" y1="0" y2="70" text="..." align="center" resize="no" />' ; \
sed -n -E \
-e '/^<\?xml/d' \
-e '/^<!DOCTYPE/d' \
-e '/^<!--/d' \
-e 's!<([^/:]+[ >])!<svg:\1!g' \
-e 's!</([^/:]+>)!</svg:\1!g' \
-e 's!fill="([^"]+)"!style="stroke: foreground; stroke-linecap: round; stroke-linejoin: round; fill: \1;"!g' \
-e 'p' \
<$(<) ; \
echo '</shape>' ; \
} >$(@)

$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.shape, $(_svg_inputs))


$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.png, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.png \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
convert -density 600 -resize 22x22 $(<) $(@)
: $(_shapes_outputs_root)/%.png \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [make convert files] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
convert -density 600 -resize 22x22 $(<) $(@)

$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.png, $(_svg_inputs))


$(_shapes_sheet_output) : $(_svg_inputs) makefile
$(info [xx] [make] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
echo '<?xml version="1.0" encoding="utf-8"?>' ; \
echo '' ; \
echo '<sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns">' ; \
echo ' ' ; \
echo ' <name>AWS shapes</name>' ; \
echo ' <description>AWS shapes</description>' ; \
echo ' ' ; \
echo ' <contents>' ; \
for shape in $(_svg_inputs) ; do \
name="$$( basename -- "$${shape}" .svg | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo ' <object name="'"$${name}"'"><description>'"$${name}"'</description></object>' ; \
done | sort ; \
echo ' </contents>' ; \
echo ' ' ; \
echo '</sheet>' ; \
} >$(@)

$(_shapes_sheet_output) : $(_svg_inputs_root) makefile

$(info [xx] [make AWS sheet] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
echo '<?xml version="1.0" encoding="utf-8"?>' ; \
echo '' ; \
echo '<sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns">' ; \
echo ' ' ; \
echo ' <name>AWS shapes</name>' ; \
echo ' <description>AWS shapes</description>' ; \
echo ' ' ; \
echo ' <contents>' ; \
for shape in $(_svg_inputs_root)/*.svg; do \
name="$$( basename -- "$${shape}" .svg | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo ' <object name="'"$${name}"'"><description>'"$${name}"'</description></object>' ; \
done | sort ; \
echo ' </contents>' ; \
echo ' ' ; \
echo '</sheet>' ; \
} >$(@)

$(_outputs_root) : $(_shapes_sheet_output)