Welcome to little lamb

Code » comain » commit 8cdddeb

Support multiple lines in meta/{site,code,git,doc}

author Olivier Brunel
2023-12-22 13:16:17 UTC
committer Olivier Brunel
2024-01-02 10:18:38 UTC
parent 4d4c2244c824ad26b3d6505cd60005f0f2596fcd

Support multiple lines in meta/{site,code,git,doc}

So we can put both lila.oss & lila.oss.jjacky.com, also for git allows
to have both git & https protocols.

configure +1 -1
getdeps +3 -3
initprj +3 -3
initrepo +6 -0
mkreadme +13 -9

diff --git a/configure b/configure
index 2ee4ef9..b7b2b23 100755
--- a/configure
+++ b/configure
@@ -1059,7 +1059,7 @@ mv -f config.mk.tmp config.mk
 
 echo "  -> Generating config.h..."
 
-url="$(cat meta/site 2>/dev/null)"
+url="$(head -1 meta/site 2>/dev/null)"
 if test -z "$url"; then url="https://lila.oss"; fi
 
 exec 5>&1 1>config.h.tmp
diff --git a/getdeps b/getdeps
index a0420a0..f5f919a 100755
--- a/getdeps
+++ b/getdeps
@@ -35,8 +35,8 @@ showdep()
         echon " [optional: --with-$(echo $needed | sed "s/ /, --with-/g")]"
     fi
     echo
-    if test -f "$dep/site"; then echo "$rec  site : $(cat $dep/site)"; fi
-    if test -f "$dep/git" ; then echo "$rec  repo : $(cat $dep/git)" ; fi
+    if test -f "$dep/site"; then echo "$rec  site : $(head -1 $dep/site)"; fi
+    if test -f "$dep/git" ; then echo "$rec  repo : $(head -1 $dep/git)" ; fi
     if test -f "$dep/ref" ; then echo "$rec  ref  : $(cat $dep/ref)" ; fi
 
     # recursive lila dependency
@@ -95,7 +95,7 @@ getdep()
     if test -e "$dst/$depname"; then
         warn "cannot clone: '$dst/$depname' already exists"
     else
-        mbrun git clone "$(cat $dep/git)" "$dst/$depname"
+        mbrun git clone "$(head -1 $dep/git)" "$dst/$depname"
         local ref="$(cat $dep/ref 2>/dev/null)"
         if test -z "$ref"; then ref="$(cat $dep/version)"; fi
         mbrun git -C "$dst/$depname" checkout -b "for-$prjname-$version" "$ref"
diff --git a/initprj b/initprj
index fe6e3a0..235dfd7 100755
--- a/initprj
+++ b/initprj
@@ -19,9 +19,9 @@ if test ! -d comain; then
 fi
 
 desc="$(head -1 meta/desc)"
-site="$(cat meta/site)"
-code="$(cat meta/code)"
-git="$(cat meta/git)"
+site="$(head -1 meta/site)"
+code="$(head -1 meta/code)"
+git="$(head -1 meta/git)"
 sp=$((52 - ${#name} - ${#site}))
 sp="$(printf "%${sp}s")"
 prefix=$(sanitize $name)
diff --git a/initrepo b/initrepo
index 67d7017..2f86bd0 100755
--- a/initrepo
+++ b/initrepo
@@ -21,9 +21,15 @@ run cp -n comain/project.mk.tpl project.mk
 run mkdir src
 run cp -n comain/meta/README.git meta
 run echo https://lila.oss/$name > meta/site
+run echo https://lila.oss.jjacky.com/$name >> meta/site
 run echo git://lila.oss/$name.git > meta/git
+run echo https://lila.oss/$name.git >> meta/git
+run echo git://lila.oss.jjacky.com/$name.git >> meta/git
+run echo https://lila.oss.jjacky.com/$name.git >> meta/git
 run echo https://lila.oss/doc/$name > meta/doc
+run echo https://lila.oss.jjacky.com/doc/$name >> meta/doc
 run echo https://lila.oss/code/$name > meta/code
+run echo https://lila.oss.jjacky.com/code/$name >> meta/code
 run echo FIXME: desc here > meta/desc
 run $EDITOR meta/desc
 run cp -n comain/meta/COPYING meta
diff --git a/mkreadme b/mkreadme
index c6c8cb6..1026ce7 100755
--- a/mkreadme
+++ b/mkreadme
@@ -29,34 +29,38 @@ links()
         if test -f meta/site; then
             echo "- [$label]"
             lnks="$lnks
-[$label]: $(cat meta/site)"
+[$label]: $(head -1 meta/site)"
         fi
     fi
     if test -f meta/git; then
         if test $isprj -eq 0; then
             echo "- [repository]"
             lnks="$lnks
-[repository]: $(cat meta/git)"
+[repository]: $(head -1 meta/git)"
         else
-            echo "- '<li>Repository:<br><code>$(cat meta/git)</code>'"
+            printf %s "- '<li>Repository:<br><code class=\"nowrap\">"
+            cat meta/git | while read url; do
+                printf "%s<br>" "$url"
+            done
+            echo "</code>'"
         fi
     fi
     if test -f meta/code; then
         if test $isprj -eq 0; then
             echo "- [source code]"
             lnks="$lnks
-[source code]: $(cat meta/code)"
+[source code]: $(head -1 meta/code)"
         else
-            echo "- '<li><a href=\"$(cat meta/code)\">Source Code</a>'"
+            echo "- '<li><a href=\"$(head -1 meta/code | sed -e 's/https:\/\/lila.oss//')\">Source Code</a>'"
         fi
     fi
     if test -f meta/doc; then
         if test $isprj -eq 0; then
             echo "- [documentation]"
             lnks="$lnks
-[documentation]: $(cat meta/doc)"
+[documentation]: $(head -1 meta/doc)"
         else
-            echo "- ' <li><a href=\"$(cat meta/doc)\">Documentation</a>'"
+            echo "- ' <li><a href=\"$(head -1 meta/doc | sed -e 's/https:\/\/lila.oss//')\">Documentation</a>'"
         fi
     fi
     if test $isprj -eq 0; then cat <<EOF
@@ -104,8 +108,8 @@ echodep()
     local name="$depname"
     local needed
     eval needed=\"\$need$depname\"
-    local site="$(cat $dep/site 2>/dev/null)"
-    if test -z "$site"; then site="$(cat $depname/meta/site 2>/dev/null)"; fi
+    local site="$(head -1 $dep/site 2>/dev/null)"
+    if test -z "$site"; then site="$(head -1 $depname/meta/site 2>/dev/null)"; fi
     if test -n "$site"; then
         name="[$name]"
         LINKS="$LINKS