1#!/bin/sh 2 3# Copyright (c) 2013, StrongLoop, Inc. <callback@strongloop.com> 4# 5# Permission to use, copy, modify, and/or distribute this software for any 6# purpose with or without fee is hereby granted, provided that the above 7# copyright notice and this permission notice appear in all copies. 8# 9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 17set -e 18 19TOOLSDIR=`dirname "$0"` 20TOPLEVELDIR="$TOOLSDIR/../.." 21 22RPMBUILD_PATH="${RPMBUILD_PATH:-$HOME/rpmbuild}" 23if [ ! -d "$RPMBUILD_PATH" ]; then 24 echo "Run rpmdev-setuptree first." 25 exit 1 26fi 27 28if [ $# -ge 1 ]; then 29 VERSION=$1 30else 31 FILE="$TOPLEVELDIR/src/node_version.h" 32 MAJOR=`sed -nre 's/#define NODE_MAJOR_VERSION ([0-9]+)/\1/p' "$FILE"` 33 MINOR=`sed -nre 's/#define NODE_MINOR_VERSION ([0-9]+)/\1/p' "$FILE"` 34 PATCH=`sed -nre 's/#define NODE_PATCH_VERSION ([0-9]+)/\1/p' "$FILE"` 35 VERSION="$MAJOR.$MINOR.$PATCH" 36fi 37 38set -x 39 40sed -re "s/%define _version .+/%define _version ${VERSION}/" \ 41 "$TOOLSDIR/node.spec" > "$RPMBUILD_PATH/SPECS/node.spec" 42tar --exclude-vcs --transform="s|^|node-${VERSION}/|" \ 43 -czf "$RPMBUILD_PATH/SOURCES/node-v${VERSION}.tar.gz" . 44rpmbuild "$*" -ba "$RPMBUILD_PATH/SPECS/node.spec" 45