#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) # Copyright 2015-2016 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. # # # This script packages a package in a tar file. # echo "RTEMS Release Package, v0.1" # # Defaults. # . ${release_top}/rtems-release-defaults # # Common package start. # . ./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 git_submodules=$(git submodule | cut -w -f 2) if [ -n "${git_submodules}" ]; then echo "git submodules found ...." git submodule init 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 origin/${version} ${s} | cut -w -f 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 fi echo "git archive --format=tar --prefix=${prefix}/ origin/${version}" git archive --format=tar --prefix=${prefix}/ origin/${version} > \ ../${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 Jxf ${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 Jxf ${stamped_tar}-${s}.tar fi done fi cd ${prefix} echo "Creating VERSION: ${release}" echo "[version]" > VERSION echo "release = ${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 ${worker} ${package} ${version} ${revision} ${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