forked from libremesh/libremesh.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect_packages.sh
executable file
·49 lines (39 loc) · 972 Bytes
/
collect_packages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
PACKAGES_INDEX=$(yq '.packages' _data/packages.yml)
GITHUB_URL="https://raw.githubusercontent.com/libremesh/lime-packages/master/packages"
PACKAGES_DIR=packages
mkdir -p $PACKAGES_DIR
echo $PACKAGES_INDEX | jq -r '.[]|[.name, .readme, .makefile_external_url] | @tsv' |
while IFS=$'\t' read -r name readme makefile_external_url; do
[ -n "$name" ] && echo $name && \
cat /dev/null > $PACKAGES_DIR/$name.txt && \
cat << EOF >> $PACKAGES_DIR/$name.txt
---
title: $name
ref: $name
lang: en
---
EOF
[ -n "$readme" ] && echo $readme && \
README="" && \
README=$(curl "$GITHUB_URL/$name/$readme") && \
cat << EOF >> $PACKAGES_DIR/$name.txt
== Readme
[,markdown]
____
$README
____
EOF
MAKEFILE_URL=""
[ -n "$makefile_external_url" ] && \
MAKEFILE_URL="$makefile_external_url" || \
MAKEFILE_URL="$GITHUB_URL/$name/Makefile"
MAKEFILE=$(curl "$MAKEFILE_URL") && \
cat << EOF >> $PACKAGES_DIR/$name.txt
== Makefile
[,make]
----
$MAKEFILE
----
EOF
done