forked from Thomas-Tsai/partclone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·268 lines (239 loc) · 5.93 KB
/
release.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/bin/bash
set -e
packbase="$HOME/download/pre-release/"
[ ! -d $presrc ] && mkdir $presrc
rm -rf $packbase/*
presrc="$HOME/download/pre-release/src"
ptlpath="$HOME/partclone"
[ ! -d $presrc ] && mkdir $presrc
GPGID="0x68cdf01d"
SRC=0
DPKG=0
TAGS=0
PO=0
LOG=0
SYNC=0
VER=0
VERSION=auto
gVERSION="HEAD"
TEST=0
_dch_options="-b"
is_release=1
USAGE(){
cat << EOF
$0 is script to auto release partclone. This script will create partclone
tar ball file and auto build debian package with my key.
It's only for developer usage.
recognized flags are:
-s, --src build tar ball
-d, --dpkg build dpkg files
-p, --po run make po
-t, --test run make check
-v, --ver update version.h
-l, --sync-log update Changelog
-f, --sync-fs update source i.e btrfs
-g, --git give git commit version like b655 or 0.2.54
-a, --tags add version as git tag
-n, --no_push do NOT auto push to git repo
-h, --help show this help
EOF
}
check_option(){
while [ $# -gt 0 ]; do
case "$1" in
-g|--git)
shift
if [ -z "$(echo $1 |grep ^-.)" ]; then
gVERSION=$1
shift
pushd $ptlpath
#git pull
vgit=$(git log -1 $gVERSION)
if [ -z "$vgit" ]; then
echo "can't find git version $VERSION"> 2&
exit 1
fi
popd
fi
;;
-d|--dpkg)
DPKG=1
shift
;;
-s|--src)
SRC=1
shift
;;
-t|--test)
TEST=1
shift
;;
-a|--tags)
TAGS=1
shift
;;
-p|--po)
PO=1
shift
;;
-l|--sync-log)
LOG=1
shift
;;
-f|--sync-fs)
SYNC=1
shift
;;
-n|--no_push)
is_release=0
shift
;;
-v|--ver)
VER=1
shift
;;
-h|--help)
USAGE >& 2
exit 2
;;
-*)
echo "${0}: ${1}: invalid option" >&2
USAGE >& 2
exit 2
;;
*)
break
;;
esac
done
}
# exit if not git
is_git(){
GIT_REPOSITORY=`git remote -v | grep partclone`
if [ "${GIT_REPOSITORY}" = "" ];
then
echo "not git repository?"
exit 0
fi
}
check_version(){
pushd $ptlpath
is_git
#git pull
git fetch --tags
if [ "$gVERSION" != "HEAD" ]; then
git checkout $gVERSION -b 'g_$gVERSION'
ptlversion=$(grep ^PACKAGE_VERSION= configure | sed s/PACKAGE_VERSION//g | sed s/[\'=]//g)
if [ "$gVERSION" == "$ptlversion" ]; then
VERSION=$ptlversion
_dch_options="-v $VERSION-2 -b"
else
VERSION=$ptlversion~git$gVERSION
_dch_options="-v $VERSION-1 -b"
fi
fi
if [ "$VERSION" == "auto" ];then
VERSION=$(grep ^PACKAGE_VERSION= configure | sed s/PACKAGE_VERSION//g | sed s/[\'=]//g)
gVERSION="HEAD"
_dch_options=" -v $VERSION-1 -b"
fi
popd
if [ -z "$VERSION" ]; then
echo "can't find version $VERSION"> 2&
exit 1
fi
}
tarball (){
pushd $ptlpath
## release tar ball
autoreconf
update_version
update_po
sync_log
git add -u
git commit -m "release $VERSION"
git archive --format=tar --prefix=partclone-$VERSION/ $gVERSION | gzip > $presrc/partclone-$VERSION.tar.gz
git archive --format=tar --prefix=partclone-$VERSION/ $gVERSION | gzip > $presrc/partclone_$VERSION.orig.tar.gz
[ is_releae == 1 ] && git push
popd
}
dpkg_package() {
pushd $packbase
if [ -f $presrc/partclone_$VERSION.orig.tar.gz ]; then
cp $presrc/partclone_$VERSION.orig.tar.gz $packbase/ && tar -zxvf partclone_$VERSION.orig.tar.gz
else
echo "copy partclone_$VERSION.orig.tar.gz to $presrc/partclone_$VERSION.orig.tar.gz first"
echo "i.e: wget http://partclone.nchc.org.tw/download/source/partclone_$VERSION.orig.tar.gz -P $presrc/"
exit
fi
pushd partclone-$VERSION
cp -r README.Packages/debian debian
debuild -k$GPGID
popd
popd
}
push_tags(){
pushd $ptlpath
git tag -f -a $VERSION -m "release $VERSION"
git push --tags
popd
}
sync_log(){
pushd $ptlpath
is_git
# get source code from Jim Meyering at
# http://git.mymadcat.com/index.php/p/tracker/source/tree/master/gitlog-to-changelog
perl gitlog-to-changelog --since 1999-01-01 > ChangeLog
popd
cp -r README.Packages/debian debian
dch $_dch_options
dch -r
cp -r debian README.Packages/
}
update_po(){
pushd $ptlpath
make -C po/ update-po
popd
}
sync_fs(){
BTRFS_SOURCE="bitops.h ctree.h extent_io.c inode-item.c math.h radix-tree.c root-tree.c ulist.c volumes.c btrfsck.h dir-item.c extent_io.h inode-map.c print-tree.c radix-tree.h send.h ulist.h volumes.h btrfs-list.c disk-io.c extent-tree.c ioctl.h print-tree.h raid6.c send-stream.c utils.c btrfs-list.h disk-io.h file-item.c kerncompat.h qgroup.c rbtree.c send-stream.h utils.h crc32c.c free-space-cache.c list.h qgroup.h rbtree.h send-utils.c utils-lib.c rbtree-utils.c crc32c.h extent-cache.c free-space-cache.h list_sort.c qgroup-verify.c repair.c send-utils.h uuid-tree.c ctree.c extent-cache.h hash.h list_sort.h qgroup-verify.h repair.h transaction.h version.h rbtree-utils.h rbtree_augmented.h"
echo "manual run : cp $BTRFS_SOURCE $ptlpath/src/btrfs/"
}
update_version(){
pushd $ptlpath
file="$ptlpath/src/version.h"
is_git
GIT_REVISION=`git log -1 | grep ^commit | sed 's/commit //'`
#GIT_REVISION_UPSTREAM=`git log master -1 | grep commit | sed 's/commit //'`
git_ver="none"
#if [ "${GIT_REVISION_UPSTREAM}" != "" ]; then
# git_ver=$GIT_REVISION_UPSTREAM
#el
if [ "${GIT_REVISION}" != "" ]; then
git_ver=$GIT_REVISION
else
git_ver="none"
fi
if [ "$git_ver" != "none" ];
then
echo "create ${file}"
cat > ${file} << EOF
/* DO NOT EDIT THIS FILE - IT IS REGENERATED AT EVERY COMPILE -
* IT GIVES BETTER TRACKING OF DEVELOPMENT VERSIONS
* WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE
* OFFICIAL PARTCLONE RELEASES.
*/
#define git_version "$git_ver"
EOF
fi
}
# main
check_option "$@"
check_version
[ $SRC == 1 ] && tarball
[ $DPKG == 1 ] && dpkg_package
[ $LOG == 1 ] && sync_log
[ $TAGS == 1 ] && push_tags
[ $PO == 1 ] && update_po
[ $SYNC == 1 ] && sync_fs
[ $VER == 1 ] && update_version