-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgeneratePackage.sh
83 lines (75 loc) · 2.44 KB
/
generatePackage.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
#!/usr/bin/bash
# Default values for the flags
FLAG_CCAPI="none"
FLAG_LABEL="1.0"
SKIP_COLL_GEN=false
# You can change this if you want to avoid using the --name flag
FLAG_NAME="cc-tools-demo"
# Process command-line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--label | -l)
if [[ $# -gt 1 ]]; then
FLAG_LABEL=$2
shift 2
else
echo "Error: --label flag requires a value."
exit 1
fi
;;
--name | -n)
if [[ $# -gt 1 ]]; then
FLAG_NAME=$2
shift 2
else
echo "Error: --name flag requires a value."
exit 1
fi
;;
--org | -o)
if [[ $# -gt 1 ]]; then
orgs+=("$2")
shift 2
else
echo "Error: --org flag requires a value."
exit 1
fi
;;
--skip | -s)
SKIP_COLL_GEN=true
shift 1
;;
--help | -h)
echo "Usage: ./generateTar.sh [--label <label>] [--name <name>]"
echo " --help , -h: Show this help message."
echo " --label, -l: Label to be used for the chaincode package. Default is 1.0."
echo " --name , -n: Name of the chaincode package. Default is ${FLAG_NAME}."
echo " --org , -o: Include an organization in the collection configuration file"
echo " This option can be used multiple times to include multiple organizations"
echo " If no organizations are specified, the default is to include any organization found in the readers"
echo " --skip , -s: Skip the generation of the collections.json file"
exit 0
;;
*)
# Ignore unrecognized arguments
shift
;;
esac
done
# Generate collection configuration file
if [ "$SKIP_COLL_GEN" = false ]
then
if [ ${#orgs[@]} -gt 0 ]
then
cd ./chaincode; go run . -g --orgs ${orgs[@]}; cd ..
else
cd ./chaincode; go run . -g; cd ..
fi
fi
# Remove previous tar file
rm -f chaincode.tar.gz
# Make sure go mod is up to date
cd chaincode && GOWORK=off go mod vendor && cd ..
# Pack chaincode
export FABRIC_CFG_PATH=fabric/config
peer lifecycle chaincode package chaincode.tar.gz --path chaincode --lang golang --label ${FLAG_NAME}_${FLAG_LABEL}