#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) # Copyright 2015,2016,2019 Chris Johns (chrisj@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. # # 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. # # 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 HOLDER 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. # set -e # # This script packages a package in a tar file. # # # Defaults. # . ${release_top}/rtems-release-defaults # # Common package start. # title="RTEMS Release Package" . ./rtems-release-package-start # # Work in a package specific directory in the release directory. # echo "git clone ${git_remote} ${git_local}" git clone ${git_remote} ${git_local} stamped_tar=${prefix}-unstamped # # Clone the repo and then check if there are any submodules. # # If there are submodules, exclude the ones we do not wish to package, eg the # whole of the FreeBSD source tree. For the ones to package get the commit # (treeish) for the branch we releasing and then create an archive. The # submodule archives are merged into the main archive once we have collected # them all. # # cd ${git_local} echo "git fetch origin" git fetch origin # Map the branch name to a specific package and release branch name remote_branch=$(rtems_map_branch ${package} ${version}) echo "] Package ${package} ${version}: ${remote_branch}" git_submodules=$(git submodule | awk '{print $2}') if [ -n "${git_submodules}" ]; then echo "] git submodules found ...." echo "git submodules init" git submodule init echo "git checkout ${remote_branch}" git checkout ${remote_branch} for s in ${git_submodules} do ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g") if [ "${ok}" != "no" ]; then echo "git submodule update ${s}" git submodule update ${s} treeish=$(git ls-tree HEAD ${s} | awk '{print $3}') cd ${s} echo "git archive --format=tar --prefix=${prefix}/${s}/ ${treeish}" git archive --format=tar --prefix=${prefix}/${s}/ ${treeish} > \ ../../${stamped_tar}-${s}.tar cd .. # ${s} else echo "git submodule ${s} excluded" fi done echo "git checkout master" git checkout master fi echo "git archive --format=tar --prefix=${prefix}/ ${remote_branch}" git archive --format=tar --prefix=${prefix}/ ${remote_branch} > \ ../${stamped_tar}.tar cd .. # ${git_local} if [ ! -f ${stamped_tar}.tar ]; then echo "error: git archive failed, no tar file" exit 1 fi echo "tar xf ${stamped_tar}.tar" tar xf ${stamped_tar}.tar if [ -n "${git_submodules}" ]; then for s in ${git_submodules} do ok=$(echo ${git_submodules_excludes} | sed -e "s/.*${s}.*/no/g") if [ "${ok}" != "no" ]; then echo "tar xf ${stamped_tar}-${s}.tar" tar xf ${stamped_tar}-${s}.tar fi done fi cd ${prefix} echo "] Creating VERSION: ${release}" echo "[version]" > VERSION echo "revision = ${release}" >> VERSION cd .. # ${prefix} # # Run the worker script if provided. It can perform any package # specific set up functions. This is done before we finally # package the release. # if [ -n "${worker}" ]; then wk_name=$(basename ${worker}) echo "] Worker: ${wk_name}" ${worker} ${package} ${version} ${revision} ${release_url} ${top} fi # # The '..' is the release directory. # echo "tar cf - ${prefix}" tar cf - ${prefix} | ${comp} > ../${prefix}.tar.${comp_ext} echo "] Created: ${release}/${prefix}.tar.${comp_ext}" # # Comman package end. # . ${top}/rtems-release-package-end exit 0