tprtsum - scripts - various script and utils
HTML git clone git://z3bra.org/scripts
DIR Log
DIR Files
DIR Refs
---
tprtsum (1025B)
---
1 #!/bin/sh
2 #
3 # z3bra - (c) wtfpl 2015
4
5 PKGMK_ARCH=64 source /etc/pkgmk.conf
6
7 echo_color () {
8 tput bold
9 tput setaf $1
10 shift
11
12 echo "$@"
13
14 tput sgr0
15 }
16
17 # check wether we're in a port directory or not
18 if [ ! -f Pkgfile ]; then
19 echo_color 1 "Not in a port directory"
20 exit 1
21 fi
22
23 port_dir=$PWD
24
25 get_version() {
26 cd $PKGMK_SOURCE_DIR
27 }
28
29 update_pkgfile() {
30 cd $port_dir
31
32 # update version
33 sed -i "s/^version=.*$/version=$version/" Pkgfile
34
35 # update sversion if it exists
36 if grep -q 'sversion' Pkgfile; then
37 sed -i "s/^sversion=.*$/sversion=$sversion/" Pkgfile
38
39 # create it otherwise
40 else
41 sed -i "/version/a\
42 sversion=$sversion" Pkgfile
43 fi
44 }
45
46 main() {
47
48 # we'll need the $name var later
49 source Pkgfile
50
51 # get the git hashes
52 get_version
53
54 # update Pkgfile accordingly
55 update_pkgfile
56
57 if [ ! "$1" = "-q" ]; then
58 echo "port : $name"
59 echo "version: $version"
60 echo "commit : $sversion"
61 fi
62 }
63
64 main $@