test: use `command` instead of `env` to bypass Bash’s built-ins
[nit.git] / bin / nit-makepackage
1 #!/bin/bash
2
3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # This shell script creates (or overrides) a package.ini template file in the current directory.
18 # The result must be examined and adapted.
19 #
20 # Default values are guessed from git and the file system.
21
22 name=`basename $PWD`
23 maintainer=`git shortlog -esn . | head -n 1 | sed 's/\s*[0-9]*\s*//'`
24 dir=`git rev-parse --show-prefix`
25 git=`git remote get-url origin`
26
27 # Setup default keys.
28 # The following values works for Github and Gitlab
29 root=${git%.git}
30 browse=$root
31 homepage=$root
32 if [ -n "$dir" ]; then
33         browse=$root/tree/master/$dir
34 fi
35 issues=$root/issues
36
37 # Special cases to override
38 case "$git" in
39         */nit.git)
40                 # For projects on the main Nit tree
41                 license=Apache-2.0
42                 git=https://github.com/nitlang/nit.git
43                 homepage=http://nitlanguage.org
44                 root=https://github.com/nitlang/nit
45                 browse=$root/tree/master/$dir
46                 issues=$root/issues
47                 ;;
48 esac
49
50 # Generate the `package.ini` file
51 sed '/^$/d' > package.ini <<SUPERCALIFRAGILISTICEXPIALIDOCIOUS
52 [package]
53 name=$name
54 tags=
55 maintainer=$maintainer
56 license=$license
57 [upstream]
58 browse=$browse
59 git=$git
60 `test -n "$dir" && echo "git.directory=$dir"`
61 homepage=$homepage
62 issues=$issues
63 SUPERCALIFRAGILISTICEXPIALIDOCIOUS