2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2020-01-19 18:03:11 +01:00
|
|
|
# tools/zipme.sh
|
2007-02-18 00:21:28 +01:00
|
|
|
#
|
2013-04-29 16:57:46 +02:00
|
|
|
# Copyright (C) 2007-2011, 2013 Gregory Nutt. All rights reserved.
|
2012-09-13 20:32:24 +02:00
|
|
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in
|
|
|
|
# the documentation and/or other materials provided with the
|
|
|
|
# distribution.
|
2008-11-07 20:11:27 +01:00
|
|
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
# used to endorse or promote products derived from this software
|
|
|
|
# without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
|
2011-03-12 23:21:17 +01:00
|
|
|
#set -x
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
WD=`pwd`
|
2020-04-07 04:35:38 +02:00
|
|
|
TAR=tar
|
2020-04-09 01:31:22 +02:00
|
|
|
GPG="gpg -sab"
|
|
|
|
SHASUM=sha512sum
|
|
|
|
verbose=0
|
|
|
|
sign=0
|
2013-04-29 16:57:46 +02:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
# A list of files and folders to exclude from the final tarball.
|
|
|
|
|
|
|
|
EXCLPAT="
|
|
|
|
.github
|
|
|
|
.asf.yaml
|
|
|
|
|
|
|
|
"
|
2020-04-09 01:31:22 +02:00
|
|
|
# Get command line parameters
|
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
USAGE="USAGE: $0 [-d|h|v|s] [-b <build]> [-e <exclude>] [-k <key-id>] [<major.minor.patch>]"
|
2020-04-09 01:31:22 +02:00
|
|
|
ADVICE="Try '$0 -h' for more information"
|
2020-04-07 04:35:38 +02:00
|
|
|
|
2013-04-29 16:57:46 +02:00
|
|
|
unset VERSION
|
2013-04-29 18:34:53 +02:00
|
|
|
unset VERSIONOPT
|
2013-04-29 16:57:46 +02:00
|
|
|
unset BUILD
|
2013-04-29 18:34:53 +02:00
|
|
|
unset DEBUG
|
2013-04-29 16:57:46 +02:00
|
|
|
|
2014-04-14 00:22:22 +02:00
|
|
|
while [ ! -z "$1" ]; do
|
2020-01-05 17:29:59 +01:00
|
|
|
case $1 in
|
|
|
|
-b )
|
2013-04-29 16:57:46 +02:00
|
|
|
shift
|
2020-01-05 17:29:59 +01:00
|
|
|
BUILD="-b ${1}"
|
|
|
|
;;
|
|
|
|
-d )
|
|
|
|
set -x
|
|
|
|
DEBUG=-d
|
|
|
|
;;
|
2020-04-07 04:35:38 +02:00
|
|
|
-e )
|
|
|
|
shift
|
|
|
|
EXCLPAT+=${1}
|
|
|
|
;;
|
2020-04-09 01:31:22 +02:00
|
|
|
-v )
|
|
|
|
verbose=1
|
|
|
|
;;
|
2020-04-07 04:35:38 +02:00
|
|
|
-s )
|
2020-04-09 01:31:22 +02:00
|
|
|
sign=1
|
|
|
|
;;
|
|
|
|
-k )
|
|
|
|
shift
|
|
|
|
GPG+=" --default-key $1"
|
2020-04-07 04:35:38 +02:00
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-h )
|
|
|
|
echo "$0 is a tool for generation of release versions of NuttX"
|
|
|
|
echo ""
|
|
|
|
echo $USAGE
|
|
|
|
echo ""
|
|
|
|
echo "Where:"
|
|
|
|
echo " -b <build>"
|
|
|
|
echo " Use this build identification string. Default: use GIT build ID"
|
|
|
|
echo " NOTE: GIT build information may not be available in a snapshot"
|
|
|
|
echo " -d"
|
|
|
|
echo " Enable script debug"
|
|
|
|
echo " -h"
|
|
|
|
echo " show this help message and exit"
|
2020-04-21 06:22:56 +02:00
|
|
|
echo " -e"
|
2020-04-09 01:31:22 +02:00
|
|
|
echo " Exclude a list of files or folders"
|
2020-04-07 04:35:38 +02:00
|
|
|
echo " NOTE: The list must be quoted, example -e \"*.out tmp\""
|
2020-04-21 06:22:56 +02:00
|
|
|
echo " -v"
|
2020-04-09 01:31:22 +02:00
|
|
|
echo " Be verbose. The output could be more than you care to see."
|
2020-04-21 06:22:56 +02:00
|
|
|
echo " -s"
|
2020-04-09 01:31:22 +02:00
|
|
|
echo " PGP sign the final tarballs and create digests."
|
2020-04-21 06:22:56 +02:00
|
|
|
echo " -k"
|
2020-04-09 01:31:22 +02:00
|
|
|
echo " PGP key ID. If not provided the default ID will be used."
|
2020-04-18 20:47:04 +02:00
|
|
|
echo " <major.minor.patch>"
|
|
|
|
echo " The NuttX version number expressed as a major, minor and patch number separated"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " by a period"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
* )
|
2020-03-21 14:23:44 +01:00
|
|
|
break
|
2020-01-05 17:29:59 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2013-04-29 16:57:46 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# The last thing on the command line is the version number
|
|
|
|
|
|
|
|
VERSION=$1
|
2020-04-21 06:22:56 +02:00
|
|
|
if [ -n ${VERSION} ] ; then
|
|
|
|
VERSIONOPT="-v ${VERSION}"
|
|
|
|
if
|
2013-04-29 16:57:46 +02:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
# Full tar options
|
|
|
|
|
|
|
|
for pat in ${EXCLPAT} ; do
|
|
|
|
TAR+=" --exclude=${pat}"
|
|
|
|
done
|
|
|
|
|
|
|
|
TAR+=" --exclude-vcs-ignores --exclude-vcs"
|
|
|
|
|
2020-04-09 01:31:22 +02:00
|
|
|
if [ $verbose != 0 ] ; then
|
2020-04-07 04:35:38 +02:00
|
|
|
TAR+=" -czvf"
|
2020-04-09 01:31:22 +02:00
|
|
|
else
|
|
|
|
TAR+=" -czf"
|
2020-04-07 04:35:38 +02:00
|
|
|
fi
|
|
|
|
|
2007-06-10 04:24:53 +02:00
|
|
|
# Find the directory we were executed from and were we expect to
|
2011-03-12 23:09:14 +01:00
|
|
|
# see the directories to tar up
|
2007-06-10 04:24:53 +02:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
MYNAME=`basename $0`
|
|
|
|
|
|
|
|
if [ -x ${WD}/${MYNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
TRUNKDIR="${WD}/../.."
|
2007-02-18 00:21:28 +01:00
|
|
|
else
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ -x ${WD}/tools/${MYNAME} ] ; then
|
|
|
|
TRUNKDIR="${WD}/.."
|
|
|
|
else
|
2020-04-07 04:35:38 +02:00
|
|
|
if [ -x ${WD}/nuttx/tools/${MYNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
TRUNKDIR="${WD}"
|
|
|
|
else
|
|
|
|
echo "You must cd into the NUTTX directory to execute this script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2007-02-18 00:21:28 +01:00
|
|
|
fi
|
2007-03-02 00:07:52 +01:00
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
# Get the NuttX directory names and the path to the parent directory
|
2007-06-10 04:24:53 +02:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
NUTTXDIR=${TRUNKDIR}/nuttx
|
|
|
|
APPSDIR=${TRUNKDIR}/apps
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
# Make sure that the directories exists
|
2007-06-10 04:24:53 +02:00
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
if [ ! -d ${TRUNKDIR} ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Directory ${TRUNKDIR} does not exist"
|
|
|
|
exit 1
|
2007-06-10 04:24:53 +02:00
|
|
|
fi
|
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
cd ${TRUNKDIR} || \
|
2020-01-05 17:29:59 +01:00
|
|
|
{ echo "Failed to cd to ${TRUNKDIR}" ; exit 1 ; }
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
if [ ! -d ${NUTTXDIR} ] ; then
|
|
|
|
echo "Directory ${TRUNKDIR}/${NUTTXDIR} does not exist!"
|
2020-01-05 17:29:59 +01:00
|
|
|
exit 1
|
2011-03-12 23:09:14 +01:00
|
|
|
fi
|
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
if [ ! -d ${APPSDIR} ] ; then
|
|
|
|
echo "Directory ${TRUNKDIR}/${APPSDIR} does not exist!"
|
2020-01-05 17:29:59 +01:00
|
|
|
exit 1
|
2007-02-18 00:21:28 +01:00
|
|
|
fi
|
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
# Perform a full clean for the distribution
|
2011-03-21 22:59:35 +01:00
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
cd ${TRUNKDIR} || \
|
|
|
|
{ echo "Failed to cd to ${TRUNKDIR}" ; exit 1 ; }
|
|
|
|
|
|
|
|
echo "Cleaning the repositories"
|
|
|
|
|
|
|
|
if [ $verbose != 0 ] ; then
|
|
|
|
make -C ${NUTTXDIR} distclean
|
|
|
|
else
|
|
|
|
make -C ${NUTTXDIR} distclean 1>/dev/null
|
|
|
|
fi
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
# Prepare the nuttx directory
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
# Make sure that versioned copies of certain files are in place
|
2007-12-13 17:52:37 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
cd ${NUTTXDIR}/Documentation || \
|
|
|
|
{ echo "Failed to cd to ${NUTTXDIR}/Documentation" ; exit 1 ; }
|
2007-12-13 17:52:37 +01:00
|
|
|
|
2013-04-29 17:12:15 +02:00
|
|
|
# Write a version file into the NuttX directory. The syntax of file is such that it
|
2011-03-21 22:59:35 +01:00
|
|
|
# may be sourced by a bash script or included by a Makefile.
|
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
VERSIONSH=${NUTTXDIR}/tools/version.sh
|
2011-04-14 18:46:17 +02:00
|
|
|
if [ ! -x "${VERSIONSH}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "No executable script was found at: ${VERSIONSH}"
|
|
|
|
exit 1
|
2011-04-14 18:46:17 +02:00
|
|
|
fi
|
2013-04-29 16:57:46 +02:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
${VERSIONSH} ${DEBUG} ${BUILD} ${VERSIONOPT} ${NUTTXDIR}/.version || \
|
|
|
|
{ echo "${VERSIONSH} failed"; cat ${NUTTXDIR}/.version; exit 1; }
|
|
|
|
chmod 755 ${NUTTXDIR}/.version || \
|
|
|
|
{ echo "'chmod 755 ${NUTTXDIR}/.version' failed"; exit 1; }
|
2013-04-29 17:12:15 +02:00
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
if [ -z ${VERSION} ] ; then
|
|
|
|
source ${NUTTXDIR}/.version
|
|
|
|
VERSION=${CONFIG_VERSION_STRING}
|
|
|
|
VERSIONOPT="-v ${VERSION}"
|
|
|
|
fi
|
|
|
|
|
2013-04-29 17:12:15 +02:00
|
|
|
# Update the configuration variable documentation
|
2014-03-15 17:05:18 +01:00
|
|
|
#
|
2020-04-07 04:35:38 +02:00
|
|
|
# MKCONFIGVARS=${NUTTXDIR}/tools/mkconfigvars.sh
|
|
|
|
# CONFIGVARHTML=${NUTTXDIR}/Documentation/NuttXConfigVariables.html
|
2014-03-15 17:05:18 +01:00
|
|
|
#
|
|
|
|
# if [ ! -x "${MKCONFIGVARS}" ]; then
|
|
|
|
# echo "No executable script was found at: ${MKCONFIGVARS}"
|
|
|
|
# exit 1
|
|
|
|
# fi
|
|
|
|
#
|
2020-04-07 04:35:38 +02:00
|
|
|
# cd ${NUTTXDIR} || \
|
|
|
|
# { echo "Failed to cd to ${NUTTXDIR}" ; exit 1 ; }
|
2014-03-15 17:05:18 +01:00
|
|
|
#
|
|
|
|
# ${MKCONFIGVARS} ${DEBUG} ${VERSIONOPT} || \
|
|
|
|
# { echo "${MKCONFIGVARS} failed"; exit 1; }
|
|
|
|
# chmod 644 ${CONFIGVARHTML} || \
|
|
|
|
# { echo "'chmod 644 ${CONFIGVARHTML}' failed"; exit 1; }
|
|
|
|
#
|
2020-04-07 04:35:38 +02:00
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
# Create the versioned tarball names
|
2020-04-07 04:35:38 +02:00
|
|
|
|
2020-04-21 06:22:56 +02:00
|
|
|
NUTTX_TARNAME=apache-nuttx-${VERSION}-incubating.tar
|
|
|
|
APPS_TARNAME=apache-nuttx-apps-${VERSION}-incubating.tar
|
|
|
|
NUTTX_ZIPNAME=${NUTTX_TARNAME}.gz
|
|
|
|
APPS_ZIPNAME=${APPS_TARNAME}.gz
|
|
|
|
NUTTX_ASCNAME=${NUTTX_ZIPNAME}.asc
|
|
|
|
APPS_ASCNAME=${APPS_ZIPNAME}.asc
|
|
|
|
NUTTX_SHANAME=${NUTTX_ZIPNAME}.sha512
|
|
|
|
APPS_SHANAME=${APPS_ZIPNAME}.sha512
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
# Remove any previous tarballs
|
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
if [ -f ${NUTTX_TARNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Removing ${TRUNKDIR}/${NUTTX_TARNAME}"
|
|
|
|
rm -f ${NUTTX_TARNAME} || \
|
|
|
|
{ echo "rm ${NUTTX_TARNAME} failed!" ; exit 1 ; }
|
2007-02-18 00:21:28 +01:00
|
|
|
fi
|
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
if [ -f ${NUTTX_ZIPNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Removing ${TRUNKDIR}/${NUTTX_ZIPNAME}"
|
|
|
|
rm -f ${NUTTX_ZIPNAME} || \
|
|
|
|
{ echo "rm ${NUTTX_ZIPNAME} failed!" ; exit 1 ; }
|
2007-02-18 00:21:28 +01:00
|
|
|
fi
|
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
if [ -f ${APPS_TARNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Removing ${TRUNKDIR}/${APPS_TARNAME}"
|
|
|
|
rm -f ${APPS_TARNAME} || \
|
|
|
|
{ echo "rm ${APPS_TARNAME} failed!" ; exit 1 ; }
|
2011-03-21 22:59:35 +01:00
|
|
|
fi
|
2011-03-20 20:30:39 +01:00
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
if [ -f ${APPS_ZIPNAME} ] ; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Removing ${TRUNKDIR}/${APPS_ZIPNAME}"
|
|
|
|
rm -f ${APPS_ZIPNAME} || \
|
|
|
|
{ echo "rm ${APPS_ZIPNAME} failed!" ; exit 1 ; }
|
2011-03-21 22:59:35 +01:00
|
|
|
fi
|
|
|
|
|
2020-04-09 01:31:22 +02:00
|
|
|
# Remove any previous signatures or digests
|
|
|
|
|
|
|
|
if [ -f ${NUTTX_ASCNAME} ] ; then
|
|
|
|
echo "Removing ${TRUNKDIR}/${NUTTX_ASCNAME}"
|
|
|
|
rm -f ${NUTTX_ASCNAME} || \
|
|
|
|
{ echo "rm ${NUTTX_ASCNAME} failed!" ; exit 1; }
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f ${APPS_ASCNAME} ] ; then
|
|
|
|
echo "Removing ${TRUNKDIR}/${APPS_ASCNAME}"
|
|
|
|
rm -f ${APPS_ASCNAME} || \
|
|
|
|
{ echo "rm ${APPS_ASCNAME} failed!" ; exit 1; }
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f ${NUTTX_SHANAME} ] ; then
|
|
|
|
echo "Removing ${TRUNKDIR}/${NUTTX_SHANAME}"
|
|
|
|
rm -f ${NUTTX_SHANAME} || \
|
|
|
|
{ echo "rm ${NUTTX_SHANAME} failed!" ; exit 1; }
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f ${APPS_SHANAME} ] ; then
|
|
|
|
echo "Removing ${TRUNKDIR}/${APPS_SHANAME}"
|
|
|
|
rm -f ${APPS_SHANAME} || \
|
|
|
|
{ echo "rm ${APPS_SHANAME} failed!" ; exit 1; }
|
|
|
|
fi
|
|
|
|
|
2011-03-21 22:59:35 +01:00
|
|
|
# Then tar and zip-up the directories
|
2011-03-20 20:30:39 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
echo "Archiving and zipping nuttx/"
|
|
|
|
${TAR} ${NUTTX_ZIPNAME} `basename ${NUTTXDIR}` || \
|
|
|
|
{ echo "tar of ${NUTTX_ZIPNAME} failed!" ; exit 1 ; }
|
2011-03-21 22:59:35 +01:00
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
echo "Archiving and zipping apps/"
|
|
|
|
${TAR} ${APPS_ZIPNAME} `basename ${APPSDIR}` || \
|
|
|
|
{ echo "tar of ${APPS_ZIPNAME} failed!" ; exit 1 ; }
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-04-12 15:58:20 +02:00
|
|
|
# Create the hashes for the two tarballs
|
|
|
|
|
|
|
|
echo "Creating the hashes"
|
|
|
|
${SHASUM} ${NUTTX_ZIPNAME} > ${NUTTX_SHANAME} || \
|
|
|
|
{ echo "Digest of ${NUTTX_ZIPNAME} failed!" ; exit 1 ; }
|
|
|
|
|
|
|
|
${SHASUM} ${APPS_ZIPNAME} > ${APPS_SHANAME} || \
|
|
|
|
{ echo "Digest of ${APPS_ZIPNAME} failed!" ; exit 1 ; }
|
|
|
|
|
|
|
|
# Finally sign the tarballs
|
2020-04-09 01:31:22 +02:00
|
|
|
|
|
|
|
if [ $sign != 0 ] ; then
|
|
|
|
echo "Signing the tarballs"
|
|
|
|
${GPG} ${NUTTX_ZIPNAME} || \
|
|
|
|
{ echo "Signing ${NUTTX_ZIPNAME} failed!" ; exit 1 ; }
|
|
|
|
|
|
|
|
${GPG} ${APPS_ZIPNAME} || \
|
|
|
|
{ echo "Signing ${APPS_ZIPNAME} failed!" ; exit 1 ; }
|
|
|
|
fi
|
|
|
|
|
2020-04-07 04:35:38 +02:00
|
|
|
cd ${NUTTXDIR}
|