Skip to content

Commit 5dc5573

Browse files
committed
update ipm package script
1 parent f1914a3 commit 5dc5573

File tree

1 file changed

+88
-24
lines changed

1 file changed

+88
-24
lines changed

ipm_package.bash

+88-24
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/bin/bash
2-
# to run use bash ipm_package.bash --version x.x.x --ip_name name
3-
# More safety, by turning some bugs into errors.
2+
# To run use: bash ipm_package.bash --version x.x.x --ip_name name
3+
4+
# Enable safety options to turn some bugs into errors
45
set -o errexit -o pipefail -o nounset
56

6-
# now enjoy the options in order and nicely split until we see --
7-
# option --output/-o requires 1 argument
8-
LONGOPTS=version:ip_name:
7+
# Define the options for getopt
8+
LONGOPTS=version:,ip_name:
99
OPTIONS=
1010

11-
# -temporarily store output to be able to check for errors
12-
# -activate quoting/enhanced mode (e.g. by writing out "--options")
13-
# -pass arguments only via -- "$@" to separate them correctly
14-
# -if getopt fails, it complains itself to stdout
11+
# Parse the options using getopt
1512
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") || exit 2
16-
# read getopt's output this way to handle the quoting right:
13+
14+
# Read getopt's output to handle quoting correctly
1715
eval set -- "$PARSED"
18-
unset PARSED
1916

17+
# Initialize variables
18+
version=""
19+
ip_name=""
2020

21+
# Process the options
2122
while true; do
2223
case "$1" in
2324
--version)
2425
version="$2"
2526
shift 2
2627
;;
27-
--)
2828
--ip_name)
2929
ip_name="$2"
3030
shift 2
@@ -34,33 +34,97 @@ while true; do
3434
break
3535
;;
3636
*)
37-
echo "Programming error"
37+
echo "Programming error: unknown option $1"
3838
exit 3
3939
;;
4040
esac
4141
done
4242

43+
# Ensure required arguments are set
44+
if [[ -z "$version" || -z "$ip_name" ]]; then
45+
echo "Error: Both --version and --ip_name options are required."
46+
exit 1
47+
fi
48+
49+
# Output the parsed arguments
4350
echo "+ version=$version"
51+
echo "+ ip_name=$ip_name"
52+
53+
54+
set -x
55+
56+
# Generate the list of files to include in the tarball
57+
files_to_compress=$(find . \
58+
! -path "./hdl" \
59+
! -path "./hdl/rtl" \
60+
! -path "./hdl/rtl/bus_wrappers" \
61+
! -path "./hdl/rtl/bus_wrappers/dft" \
62+
| grep -v "\./verify" \
63+
| grep -v "\./ipm_package.bash" \
64+
| grep -v ".*\.dev\.v" \
65+
| grep -v "\.git" \
66+
| grep -v "\.tar\.gz" \
67+
| grep -v "\./ip" \
68+
| grep -v "\./docs" \
69+
| grep -v "\./README.md" \
70+
| grep -v "\.\$")
71+
72+
# Print the files that will be compressed
73+
echo "Files to be compressed:"
74+
echo "$files_to_compress"
75+
76+
# Write the list of files to a temporary file
77+
temp_file=$(mktemp)
78+
echo "$files_to_compress" > "$temp_file"
4479

45-
# zip needed files
80+
# Create the tarball using the temporary file
81+
tar czf v$version.tar.gz --files-from="$temp_file"
4682

83+
# Clean up the temporary file
84+
rm -f "$temp_file"
4785

48-
tar czf v$version.tar.gz --files-from <(find . | grep -v "\./verify" | grep -v "\./fw/Doxyfile" | grep -v "\./ipm_package.bash" | grep -v ".*\.dev\.v" | grep -v "\./hdl/rtl/bus_wrappers/dft" | grep -v "\.git" | grep -v "\.tar\.gz" | grep -v "\./ip" | grep -v "\./docs" | grep -v "\.\$"; ls "./ip/dependencies.json")
49-
# tar czf v$version.tar.gz \
50-
# --exclude='verify' \
51-
# --exclude='hdl/rtl/bus_wrappers/dft' \
52-
# --exclude='hdl/rtl/bus_wrappers/*.dev.v' \
53-
# --exclude='ipm_package.bash' \
54-
# --exclude='fw/Doxyfile' \
55-
# --include='*.c' \
56-
# *
5786
# get checksum
5887
shasum -a 256 v$version.tar.gz > v$version.tar.gz.sha256
5988

6089
# update yaml
6190
sed -i "s/version.*/version: v$version/" *.yaml
6291
sed -i "s/date.*/date: $(date +"%Y-%m-%d")/" *.yaml
6392

93+
# Extract information from YAML using sed
94+
date=$(sed -n 's/^[[:space:]]*date:[[:space:]]*//p' $ip_name.yaml)
95+
maturity=$(sed -n 's/^[[:space:]]*status:[[:space:]]*//p' $ip_name.yaml)
96+
bus=$(sed -n '/^[[:space:]]*bus:/,/^[[:space:]]*type:/p' $ip_name.yaml | sed -n 's/^[[:space:]]*-[[:space:]]*//p' | paste -sd "," -)
97+
type=$(sed -n 's/^[[:space:]]*type:[[:space:]]*//p' $ip_name.yaml)
98+
width=$(sed -n 's/^[[:space:]]*width":[[:space:]]*//p' $ip_name.yaml)
99+
height=$(sed -n 's/^[[:space:]]*height":[[:space:]]*//p' $ip_name.yaml)
100+
cell_count=$(sed -n '/^[[:space:]]*cell_count:/,/^[[:space:]]*width:/p' $ip_name.yaml | sed -n 's/^[[:space:]]*-[[:space:]]*//p' | paste -sd "," -)
101+
clock_freq_mhz=$(sed -n '/^[[:space:]]*clock_freq_mhz:/,/^[[:space:]]*digital_supply_voltage:/p' $ip_name.yaml | sed -n 's/^[[:space:]]*-[[:space:]]*//p' | paste -sd "," -)
102+
supply_voltage=$(sed -n 's/^[[:space:]]*digital_supply_voltage:[[:space:]]*//p' $ip_name.yaml)
103+
sha256=$(cat v$version.tar.gz.sha256 | awk '{print $1}')
104+
105+
# Format JSON section
106+
json_section=$(cat <<EOF
107+
,"release": {
108+
"v$version": {
109+
"date": "$date",
110+
"maturity": "$maturity",
111+
"bus": [
112+
"$bus"
113+
],
114+
"type": "$type",
115+
"width": "$width",
116+
"height": "$height",
117+
"cell_count": "$cell_count",
118+
"clock_freq_mhz": "$clock_freq_mhz",
119+
"supply_voltage": [
120+
"$supply_voltage"
121+
],
122+
"sha256": "$sha256"
123+
}
124+
EOF
125+
)
126+
127+
64128
# create tag
65129
git tag -a $ip_name-v$version -m "Release version $version"
66130
git push origin $ip_name-v$version
@@ -71,5 +135,5 @@ if gh release view $ip_name-v$version > /dev/null 2>&1; then
71135
echo "Release $ip_name-v$version already exists. Skipping..."
72136
else
73137
echo "Creating release $ip_name-v$version..."
74-
gh release create $ip_name-v$version v$version.tar.gz -t "$ip_name-v$version" --notes "sha256: $(cat v$version.tar.gz.sha256)"
138+
gh release create $ip_name-v$version v$version.tar.gz -t "$ip_name-v$version" --notes "$json_section"
75139
fi

0 commit comments

Comments
 (0)