diff options
author | Steven Koo <steven.koo@ni.com> | 2020-04-07 11:48:23 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-04-15 07:48:48 -0500 |
commit | 1a8e654d691909e894d9129a4896a07b6dd23efd (patch) | |
tree | 6c86b236857ba3c00272e738096f3528e842d54a | |
parent | 62011391d342bd3c5ac9539f8c736d1f909c8485 (diff) | |
download | uhd-1a8e654d691909e894d9129a4896a07b6dd23efd.tar.gz uhd-1a8e654d691909e894d9129a4896a07b6dd23efd.tar.bz2 uhd-1a8e654d691909e894d9129a4896a07b6dd23efd.zip |
uhd: Create shell script to replace CMake's package_source
This script replaces CMake's package_source implementation to allow
for pulling in the firmware, fpga, mpm, host, and tools folders.
This builds two tarballs, one with and one without the firmware,
fpga, and mpm folders.
-rwxr-xr-x | tools/package_source.sh | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/tools/package_source.sh b/tools/package_source.sh new file mode 100755 index 000000000..181a056f6 --- /dev/null +++ b/tools/package_source.sh @@ -0,0 +1,108 @@ +#!/bin/sh +# Copyright 2020 Ettus Research, a National Instruments Brand +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Shell script to generate uhd tar.gz packages. +# Builds 2 packages. One with the firmware, fpga, and mpm folders and one without + +set -e + +echo_help () { + echo "-h/--help: This help doc" + echo "-d/--dir /path/to/uhd/root: Point to custom path. Defaults to '../'" + echo "-n/--name Specifies package name. Required" + echo "-f/--fpganame Specifies fpga package name. If unspecified, '_fpga' gets appended to provided name" +} + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + echo_help + exit 0 + ;; + -d|--dir) + UHD_ROOTDIR="$2" + shift # past argument + shift # past value + ;; + -n|--name) + UHD_TARNAME="$2" + shift # past argument + shift # past value + ;; + -f|--fpganame) + UHD_TARFPGANAME="$2" + shift # past argument + shift # past value + ;; + *) # unknown option + echo "Unknown argument" + exit 1 + ;; +esac +done + +if [[ -z "$UHD_ROOTDIR" ]]; then + UHD_ROOTDIR='..' +fi +echo "Root Dir: "$UHD_ROOTDIR + +if [[ -z "$UHD_TARNAME" ]]; then + echo_help + exit 1 +fi + +if [[ -z "$UHD_TARFPGANAME" ]]; then + UHD_TARFPGANAME="${UHD_TARNAME}_fpga" +fi + +# Create working directory if it doesn't already exist otherwise clear it +if [ ! -d "$UHD_ROOTDIR/build/root" ]; then + mkdir -p $UHD_ROOTDIR/build/root +else + rm -r $UHD_ROOTDIR/build/root/* +fi + +# Copy basic source and create tar.gz +cp -R $UHD_ROOTDIR/host $UHD_ROOTDIR/build/root +cp -R $UHD_ROOTDIR/images $UHD_ROOTDIR/build/root +cp -R $UHD_ROOTDIR/tools $UHD_ROOTDIR/build/root +find $UHD_ROOTDIR/build/root/ -type d -name "build*" -exec rm -r {} + + +UHD_EXITSTATUS=0 + +echo "Building $UHD_ROOTDIR/build/$UHD_TARNAME.tar.bz2" +tar --exclude='.git*' -jcf $UHD_ROOTDIR/build/$UHD_TARNAME.tar.bz2 -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.bz2 file -- Is bzip2 installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARNAME.tar.gz" +tar --exclude='.git*' -zcf $UHD_ROOTDIR/build/$UHD_TARNAME.tar.gz -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.gz file -- Is gzip installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARNAME.tar.xz" +tar --exclude='.git*' -Jcf $UHD_ROOTDIR/build/$UHD_TARNAME.tar.xz -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.xz file -- Is xz installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARNAME.tar.Z" +tar --exclude='.git*' -Zcf $UHD_ROOTDIR/build/$UHD_TARNAME.tar.Z -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.Z file -- Is compress installed?"; UHD_EXITSTATUS=1; } + +# Copy firmware, fpga, and mpm folders and create tar.gz +cp -R $UHD_ROOTDIR/firmware $UHD_ROOTDIR/build/root +cp -R $UHD_ROOTDIR/fpga $UHD_ROOTDIR/build/root +cp -R $UHD_ROOTDIR/mpm $UHD_ROOTDIR/build/root +find $UHD_ROOTDIR/build/root/ -type d -name "build*" -exec rm -r {} + + +echo "Building $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.bz2" +tar --exclude='.git*' -jcf $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.bz2 -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.bz2 file -- Is bzip2 installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.gz" +tar --exclude='.git*' -zcf $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.gz -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.gz file -- Is gzip installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.xz" +tar --exclude='.git*' -Jcf $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.xz -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.xz file -- Is xz installed?"; UHD_EXITSTATUS=1; } + +echo "Building $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.Z" +tar --exclude='.git*' -Zcf $UHD_ROOTDIR/build/$UHD_TARFPGANAME.tar.Z -C $UHD_ROOTDIR/build/root/ . || { echo "Could not create .tar.Z file -- Is compress installed?"; UHD_EXITSTATUS=1; } + +exit $UHD_EXITSTATUS |