new script to ease the creation of `package.ini` files
authorJean Privat <jean@pryen.org>
Fri, 9 Jun 2017 15:57:12 +0000 (11:57 -0400)
committerJean Privat <jean@pryen.org>
Mon, 12 Jun 2017 13:29:23 +0000 (09:29 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

bin/nit-makepackage [new file with mode: 0755]

diff --git a/bin/nit-makepackage b/bin/nit-makepackage
new file mode 100755 (executable)
index 0000000..3ee3090
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This shell script creates (or overrides) a package.ini template file in the current directory.
+# The result must be examined and adapted.
+#
+# Default values are guessed from git and the file system.
+
+name=`basename $PWD`
+maintainer=`git shortlog -esn . | head -n 1 | sed 's/\s*[0-9]*\s*//'`
+dir=`git rev-parse --show-prefix`
+git=`git remote get-url origin`
+
+# Setup default keys.
+# The following values works for Github and Gitlab
+root=${git%.git}
+browse=$root
+homepage=$root
+if [ -n "$dir" ]; then
+       browse=$root/tree/master/$dir
+fi
+issues=$root/issues
+
+# Special cases to override
+case "$git" in
+       */nit.git)
+               # For projects on the main Nit tree
+               license=Apache-2.0
+               git=https://github.com/nitlang/nit.git
+               homepage=http://nitlanguage.org
+               root=https://github.com/nitlang/nit
+               browse=$root/tree/master/$dir
+               issues=$root/issues
+               ;;
+esac
+
+# Generate the `package.ini` file
+sed '/^$/d' > package.ini <<SUPERCALIFRAGILISTICEXPIALIDOCIOUS
+[package]
+name=$name
+tags=
+maintainer=$maintainer
+license=$license
+[upstream]
+browse=$browse
+git=$git
+`test -n "$dir" && echo "git.directory=$dir"`
+homepage=$homepage
+issues=$issues
+SUPERCALIFRAGILISTICEXPIALIDOCIOUS