forked from trueos/lpreserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkport.sh
executable file
·70 lines (58 loc) · 1.39 KB
/
mkport.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# Helper script which will create the port / distfiles
# from a checked out git repo
if [ -z "$1" ] ; then
echo "Usage: ./mkports.sh <portstree> <distfiles>"
exit 1
fi
if [ ! -d "${1}/Mk" ] ; then
echo "Invalid directory: $1"
exit 1
fi
portsdir="${1}"
if [ -z "$portsdir" -o "${portsdir}" = "/" ] ; then
portsdir="/usr/ports"
fi
if [ -z "$2" ] ; then
distdir="${portsdir}/distfiles"
else
distdir="${2}"
fi
if [ ! -d "$distdir" ] ; then
mkdir -p ${distdir}
fi
echo "Sanity checking the repo..."
OBJS=`find . | grep '\.o$'`
if [ -n "$OBJS" ] ; then
echo "Found the following .o files, remove them first!"
echo $OBJS
exit 1
fi
# Get the GIT tag
ghtag=`git log -n 1 . | grep '^commit ' | awk '{print $2}'`
# Get the version
if [ -e "version" ] ; then
verTag=$(cat version)
else
verTag=$(date '+%Y%m%d%H%M')
fi
# Set the port
port="sysutils/life-preserver"
dfile="life-preserver"
# Cleanup old distfiles
rm ${distdir}/${dfile}-* 2>/dev/null
# Copy ports files
if [ -d "${portsdir}/${port}" ] ; then
rm -rf ${portsdir}/${port} 2>/dev/null
fi
cp -r port-files ${portsdir}/${port}
# Set the version numbers
sed -i '' "s|%%CHGVERSION%%|${verTag}|g" ${portsdir}/${port}/Makefile
sed -i '' "s|%%GHTAG%%|${ghtag}|g" ${portsdir}/${port}/Makefile
# Create the makesums / distinfo file
cd "${portsdir}/${port}"
make makesum
if [ $? -ne 0 ] ; then
echo "Failed makesum"
exit 1
fi