#!/bin/sh
if test -d meta; then
echo "Directory 'meta' already exists" >&2
exit 2
fi
name=$(basename "$(pwd)")
mkdir meta
echo $name > meta/name
echo 0.0.0 > meta/version
. "$(dirname $0)"/libcomain
if test ! -d comain; then
error 2 "Directory 'comain' not found"
fi
run cp -n comain/Makefile Makefile
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
run cp -n comain/meta/LICENSE meta
run cp -n comain/meta/AUTHORS.tpl meta/AUTHORS
run mkdir meta/deps
run mkdir meta/deps/comain
run touch meta/deps/comain/cpnt
run cp -n comain/meta/version meta/deps/comain/version
run cp -n comain/meta/git meta/deps/comain/git
run mkdir meta/options
for opt in comain/meta/options/*; do
run ln -s ../../$opt meta/options
done
run ln -sf meta/README.git README
run ln -sf meta/AUTHORS
run ln -sf meta/COPYING
run ln -sf meta/HISTORY
run mkdir deps
run ln -s ../comain deps/comain
if test -e .gitignore; then error 2 "File '.gitignore' already exists"; fi
run cat > .gitignore <<EOF
/comain
/configure
/common.mk
/config.mk
/config.tmp
/src/include/config.h
/deps
/build
EOF
if test -e .git; then error 2 "Already a git repo (.git exist)"; fi
git init .
git add . .gitignore
git commit --message="Initial commit: just init the (empty) repo"
echo "done."