Changcheng Liu | bea6a7c | 2019-11-14 22:59:40 +0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # Copyright (C) 2019 Liu Changcheng <changcheng.liu@aliyun.com> |
| 3 | # Author: Liu Changcheng <changcheng.liu@aliyun.com> |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or |
| 6 | # modify it under the terms of the GNU General Public License |
| 7 | # as published by the Free Software Foundation; either version 2 |
| 8 | # of the License, or (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | # |
| 18 | set -xe |
| 19 | |
| 20 | # Create dir for build |
| 21 | base=${1:-/tmp/release} |
| 22 | codename=$(lsb_release -sc) |
| 23 | releasedir=$base/$(lsb_release -si)/liburing |
| 24 | rm -rf $releasedir |
| 25 | mkdir -p $releasedir |
| 26 | |
| 27 | src_dir=$(readlink -e `basename $0`) |
| 28 | liburing_dir=$(dirname $src_dir) |
| 29 | basename=$(basename $liburing_dir) |
| 30 | dirname=$(dirname $liburing_dir) |
| 31 | version=$(git describe --match "lib*" | cut -d '-' -f 2) |
| 32 | outfile="liburing-$version" |
| 33 | orgfile=$(echo $outfile | tr '-' '_') |
| 34 | |
| 35 | # Prepare source code |
| 36 | cp -arf ${dirname}/${basename} ${releasedir}/${outfile} |
| 37 | cd ${releasedir}/${outfile} |
| 38 | git clean -dxf |
| 39 | |
| 40 | # Change changelog if it's needed |
| 41 | cur_ver=`head -l debian/changelog | sed -n -e 's/.* (\(.*\)) .*/\1/p'` |
| 42 | if [ "$cur_ver" != "$version-1" ]; then |
| 43 | dch -D $codename --force-distribution -b -v "$version-1" "new version" |
| 44 | fi |
| 45 | |
| 46 | # Create tar archieve |
| 47 | cd ../ |
| 48 | tar cvzf ${outfile}.tar.gz ${outfile} |
| 49 | ln -s ${outfile}.tar.gz ${orgfile}.orig.tar.gz |
| 50 | |
| 51 | # Build debian package |
| 52 | cd - |
| 53 | debuild |