forked from wuqunyong/APie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_release.sh
71 lines (52 loc) · 1.79 KB
/
make_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
#! /bin/bash
set -e # Exit immediately if a simple command exits with a non-zero status.
set -x # activate debugging from here
trap 'echo ">>> Something went wrong. Unable to generate the release package <<<"' ERR
echo "$0"
BASE_DIR="$(cd "$(dirname -- "$0")" ; pwd)"
echo "CurDir: $BASE_DIR"
SPEC=`ls *.spec`
Name=`awk '/__name/{printf $3; exit;}' "$SPEC"`
Version=`awk '/__ver/{printf $3; exit;}' "$SPEC"`
Release=`awk '/__rel/{printf $3; exit;}' "$SPEC"`
ZipName="${Name}-${Version}-${Release}"
PackageName="${ZipName}.x86_64.rpm"
echo "Name: $Name"
echo "Version: $Version"
echo "Release: $Release"
echo "PackageName: $PackageName"
if [ ! -e ./build/x86_64/${PackageName} ]
then
echo "./build/x86_64/${PackageName} not exist"
exit 1
fi
if [ -e "$ZipName.x86_64.zip" ]
then
/bin/rm -f "$ZipName.x86_64.zip"
echo "rm -f $ZipName.x86_64.zip"
exit 1
fi
TMP_DIR="`mktemp -d`"
echo "TMP_DIR=$TMP_DIR"
# make sure we won't remove the wrong files
echo $TMP_DIR | grep "^/tmp/" >/dev/null 2>&1 || exit 1
#trap "rm -rf $TMP_DIR" EXIT
mkdir -p "$TMP_DIR/$ZipName"
/bin/cp -rf ./releaseTemplate/* "$TMP_DIR/$ZipName"
/bin/cp -f ./build/x86_64/${PackageName} "$TMP_DIR/$ZipName/res"
/bin/cp -rf ./SQL/updates/* "$TMP_DIR/$ZipName/sql/updates"
if [ -n "$1" ]; then
echo "first params:$1"
/bin/cp -rf ./SQL/base/* "$TMP_DIR/$ZipName/sql/base"
else
echo "no params"
fi
pushd "$TMP_DIR"
sed -i "s/@@version@@/${Version}/g" ./$ZipName/config/install.conf
sed -i "s/@@release@@/${Release}/g" ./$ZipName/config/install.conf
sed -i "s/@@package_name@@/${PackageName}/g" ./$ZipName/shell/install.sh
sed -i "s/@@package_name@@/${PackageName}/g" ./$ZipName/shell/upgrade.sh
/usr/bin/zip -r "$ZipName.x86_64.zip" "$ZipName/"
/bin/mv "$ZipName.x86_64.zip" "${BASE_DIR}/"
popd
echo ">>> Generate successfully! <<<"