-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-scripts.sh
executable file
·58 lines (58 loc) · 1.89 KB
/
package-scripts.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
#!/bin/bash
###
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2018-2023 SCANOSS.COM
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
###
#
# Package up the local scripts directory into a tar archive for deployment on a server
#
if [ "$1" = "-h" ] || [ "$1" = "-help" ] ; then
echo "$0 [-help] <platform> <version>"
echo " Create a compressed archived of the scripts folder"
echo " <platform> platform the package is destined for (linux_amd64, linux_arm64)"
echo " <version> version number of the package"
exit 1
fi
if [ -z "$1" ] ; then
echo "ERROR: Please provide a package platform: linux_amd or linux_arm"
exit 1
fi
if [ -z "$2" ] ; then
echo "ERROR: Please provide a package version"
exit 1
fi
if [ ! -d "scripts" ] ; then
echo "ERROR: script folder does not exist."
exit 1
fi
export COPYFILE_DISABLE=true # Required if packaging on OSX
platform=$1
version=$2
build=1
prefix_name="scanoss-dependencies-api"
tar_name="${prefix_name}_${platform}_${version}-${build}.tgz"
# Get a unique archive name
while [ -f "$tar_name" ] ; do
((build++))
tar_name="${prefix_name}_${platform}_${version}-${build}.tgz"
done
echo "Packing scripts..."
if ! tar --format=ustar -cvzf "$tar_name" scripts ; then
echo "ERROR packaging the scripts folder"
exit 1
fi
echo
echo "Package archive name: $tar_name"
exit 0