1 |
#!/bin/bash |
2 |
|
3 |
mk_tar() { |
4 |
# mk-tar <upstream_name> <url> <tartype> <mageia_package_name> |
5 |
cd $wkdir |
6 |
name=$1 |
7 |
url=$2 |
8 |
tartype=$3 |
9 |
pkgname=$4 |
10 |
chkflag=$5 |
11 |
maj= |
12 |
min= |
13 |
patch= |
14 |
tweak= |
15 |
version= |
16 |
[[ -d git ]] || mkdir git |
17 |
cd git |
18 |
[[ -d $name ]] && rm -rf $name |
19 |
git clone $url $name |
20 |
cd .. |
21 |
rm -rf $name && cp -rf git/$name/ . |
22 |
cd $name |
23 |
|
24 |
if [[ -f VERSION.cmake ]] ; then |
25 |
maj=$(cat VERSION.cmake|grep "SET(PLUGIN_VERSION_MAJOR"|cut -d'"' -f2) |
26 |
min=$(cat VERSION.cmake|grep "SET(PLUGIN_VERSION_MINOR"|cut -d'"' -f2) |
27 |
patch=$(cat VERSION.cmake|grep "SET(PLUGIN_VERSION_PATCH"|cut -d'"' -f2) |
28 |
tweak=$(cat VERSION.cmake|grep "SET(PLUGIN_VERSION_TWEAK"|cut -d'"' -f2) |
29 |
fi |
30 |
if [[ -z $maj ]] ; then |
31 |
maj=$(cat CMakeLists.txt|grep "(VERSION_MAJOR"|cut -d'"' -f2) |
32 |
min=$(cat CMakeLists.txt|grep "(VERSION_MINOR"|cut -d'"' -f2) |
33 |
patch=$(cat CMakeLists.txt|grep "(VERSION_PATCH"|cut -d'"' -f2) |
34 |
tweak=$(cat CMakeLists.txt|grep "(VERSION_TWEAK"|cut -d'"' -f2) |
35 |
fi |
36 |
if [[ -z $maj ]] ; then |
37 |
maj=$(cat VERSION.cmake|grep "(VERSION_MAJOR"|cut -d'"' -f2) |
38 |
min=$(cat VERSION.cmake|grep "(VERSION_MINOR"|cut -d'"' -f2) |
39 |
patch=$(cat VERSION.cmake|grep "(VERSION_PATCH"|cut -d'"' -f2) |
40 |
tweak=$(cat VERSION.cmake|grep "(VERSION_TWEAK"|cut -d'"' -f2) |
41 |
fi |
42 |
if [[ -z $maj ]] ; then |
43 |
maj=$(grep -r " PLUGIN_VERSION_MAJOR "|rev|cut -d' ' -f1|rev) |
44 |
min=$(grep -r " PLUGIN_VERSION_MINOR "|rev|cut -d' ' -f1|rev) |
45 |
patch=$(grep -r " PLUGIN_VERSION_PATCH "|rev|cut -d' ' -f1|rev) |
46 |
fi |
47 |
|
48 |
version=$maj.$min.$patch.$tweak |
49 |
if [[ -z $tweak ]]; then |
50 |
version=$maj.$min.$patch |
51 |
fi |
52 |
if [[ -z $patch ]]; then |
53 |
version=$maj.$min |
54 |
fi |
55 |
|
56 |
cd .. |
57 |
|
58 |
case $tartype in |
59 |
tar.gz) |
60 |
opt=z |
61 |
;; |
62 |
tar.bz2) |
63 |
opt=j |
64 |
;; |
65 |
tar.xz) |
66 |
opt=J |
67 |
;; |
68 |
tar) |
69 |
opt= |
70 |
;; |
71 |
*) |
72 |
echo "Unsupported compression type" |
73 |
exit 1 |
74 |
esac |
75 |
|
76 |
echo "Please wait creating tarball..." |
77 |
[[ -f $name-$version.$tartype ]] && rm $name-$version.$tartype |
78 |
tar -c"$opt"f $name-$version.$tartype $name/ |
79 |
#--exclude-vcs |
80 |
[[ $? = 0 ]] && chmod 644 $name-$version.$tartype && \ |
81 |
echo "Written $name-$version.$tartype" |
82 |
|
83 |
rm -rf $name |
84 |
# Clear vars created by this fn |
85 |
pkgname= |
86 |
name= |
87 |
url= |
88 |
tartype= |
89 |
maj= |
90 |
min= |
91 |
patch= |
92 |
tweak= |
93 |
version= |
94 |
opt= |
95 |
} |
96 |
|
97 |
# Main routine ----------- |
98 |
# Check we are in SOURCES |
99 |
[[ $(pwd|rev|cut -d/ -f1|rev) = "SOURCES" ]] || { echo "Not in SOURCES directory - aborting!"; exit 1; } |
100 |
wkdir=$(pwd) |
101 |
rm -f chklist.txt |
102 |
rm -rf git |
103 |
mk_tar polar_pi https://github.com/ptulp/polar_pi/ tar.gz opencpn-polar-plugin |
104 |
rm -rf git |
105 |
|