-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·142 lines (115 loc) · 2.44 KB
/
build.sh
File metadata and controls
executable file
·142 lines (115 loc) · 2.44 KB
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
#!/bin/bash
#
# Build script for time2backup Windows package
#
# Website: https://time2backup.org
# MIT License
# Copyright (c) 2017-2021 Jean Prunneaux
#
# go into current directory
cd "$(dirname "$0")" || exit 1
# test if sources are there
if ! [ -d src ] ; then
echo "ERROR: you must put your sources in the src directory!"
exit 1
fi
#
# Functions
#
# Print usage
print_help() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -v, --version VERSION Specify a version"
echo " -h, --help Print this help"
}
##################
# MAIN PROGRAM #
##################
# get options
while [ $# -gt 0 ] ; do
case $1 in
-v|--version)
if [ -z "$2" ] ; then
print_help
exit 1
fi
version=$2
shift
;;
-h|--help)
print_help
exit
;;
*)
break
;;
esac
shift
done
# prompt to choose version
if [ -z "$version" ] ; then
version=$(grep 'version=' src/time2backup.sh | head -1 | cut -d= -f2)
echo -n "Choose version: [$version] "
read version_user
if [ -n "$version_user" ] ; then
version=$version_user
fi
echo
fi
# create build environment
mkdir -p archives
if [ $? != 0 ] ; then
echo "ERROR while creating archives directory. Please verify your access rights."
exit 3
fi
build_directory=archives/build
# clean and copy package files
echo "Clean and copy package..."
rm -rf "$build_directory" && cp -rp package "$build_directory"
if [ $? != 0 ] ; then
echo "ERROR while copying package files. Please verify your access rights."
exit 1
fi
echo "Copy time2backup sources..."
cp -rp src "$build_directory"/files/time2backup
if [ $? != 0 ] ; then
echo "ERROR while copying sources files. Please verify your access rights."
exit 1
fi
# go into the copied package directory
cd "$build_directory" || exit 4
echo "Set version number in install.bat..."
sed -i "s/set version=/set version=$version/" install.bat
if [ $? != 0 ] ; then
echo "...Failed!"
exit 3
fi
echo
echo "Building package..."
# set archive name
archive=time2backup-${version}_win64.zip
echo "ZIP package..."
zip -r "$archive" * > /dev/null
if [ $? != 0 ] ; then
echo "...Failed!"
exit 5
fi
# create version directory
mkdir -p ../"$version"
if [ $? != 0 ] ; then
echo "ERROR: Cannot create version directory!"
exit 1
fi
# move zip above
mv "$archive" ../"$version"
if [ $? != 0 ] ; then
echo "ERROR: Failed to move the archive!"
exit 1
fi
# going up
cd .. || exit 4
echo "Clean files..."
rm -rf build
echo
echo "Package is ready!"