Welcome to little lamb

Code » comain » release » tree

[release] / mkreadme

#!/bin/sh

. "$(dirname $0)"/libcomain

isprj=0
if test "$1" = "--project"; then isprj=1; fi

loadoptions
loaddeps

if test ! -e meta/desc; then error 2 "File 'meta/desc' missing"; fi
if test ! -e meta/LICENSE; then error 2 "File 'meta/LICENSE' missing"; fi

links()
{
    local lnks=
    local label="official site"
    if test -f meta/upstream; then
        label="lila's version"
        if test $isprj -eq 0; then
            echo "- [upstream]"
            lnks="$links
[upstream]: $(cat meta/upstream)"
        else
            echo "- '<li><a href=\"$(cat meta/upstream)\">Upstream</a>'"
        fi
    fi
    if test $isprj -eq 0; then
        if test -f meta/site; then
            echo "- [$label]"
            lnks="$lnks
[$label]: $(head -1 meta/site)"
        fi
    fi
    if test -f meta/git; then
        if test $isprj -eq 0; then
            echo "- [repository]"
            lnks="$lnks
[repository]: $(head -1 meta/git)"
        else
            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]: $(head -1 meta/code)"
        else
            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]: $(head -1 meta/doc)"
        else
            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
$lnks
$LINKS
EOF
    fi
}

if test $isprj -eq 1; then
    cat <<EOF
---
layout: project
title: $name: $(head -1 meta/desc)
links:
$(links)
---

EOF
fi

echo "# $name: $(head -1 meta/desc)"
tail -n +2 meta/desc

if test ! -f meta/released-on; then
    cat <<EOF

# Not yet released

* Still in development
EOF
else
    cat <<EOF

# Latest release: $version ($(cat meta/released-on))
$(getchangelog)
EOF
fi

LINKS=
echodep()
{
    local dep="$2"
    local depname="${dep##*/}"
    local name="$depname"
    local needed
    eval needed=\"\$need$depname\"
    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
$name: $site"
    fi
    echon " * $name version $(cat $dep/version)"
    if test "$needed" != "1"; then
        echon " [optional: --with-$(echo $needed | sed "s/ /, --with-/g")]"
    fi
    echo
}
if test $nb_cpnt -gt 0; then
cat <<EOF

## Components

Those are /internal components/, the required source code is included in
the tarball and they lead to no runtime dependency.

EOF
foreach "cpnt" $nb_cpnt echodep
fi

if test $nb_deps -gt 0; then
cat <<EOF

## Dependencies

Those are dependencies on librairies that will need to be present at build
time. A runtime dependency will be set, unless static linking was used.

EOF
foreach "deps" $nb_deps echodep
fi

cat <<EOF

# Free Software

$(cat meta/LICENSE)

EOF
if test $isprj -eq 1; then
    echo "$LINKS"
else
    cat <<EOF
# Links

$(links)
EOF
fi