Formatting & comments

This commit is contained in:
Alec Leamas 2010-10-08 12:15:30 +02:00
parent 93a43e09b7
commit 40dabffacc

View file

@ -1,15 +1,10 @@
#!/bin/bash #!/bin/bash
#Usage: See function usage() at bottom.
#
#
# Create a diaspora distribution # Create a diaspora distribution
# #
# Builds a diaspora distribution containing the application and bundled # Usage: See function usage() at bottom.
# libraries. Normally checks out latest version of the master branch.
# #
GIT_REPO='http://github.com/diaspora/diaspora.git' GIT_REPO='http://github.com/diaspora/diaspora.git'
RELEASE='HEAD'
VERSION='0.0' VERSION='0.0'
function git_id function git_id
@ -52,8 +47,9 @@ function git_id
function fix_alphatag() function fix_alphatag()
# Patch version on top comment first id line: # Patch version on top comment first id line:
# Usage: fix_alphatag <file> <version> <commi_id> # Usage: fix_alphatag <file> <version> <commit_id>
#* Fri Sep 24 2010 name surname <email@com> 1.20100925_faf234320 # Patches:\
# * Fri Sep 24 2010 name surname <email@com> 1.20100925_faf23207
{ {
dist=$(rpm --eval %dist) dist=$(rpm --eval %dist)
awk -v dist="$dist" -v version="$2" -v release="$3" \ awk -v dist="$dist" -v version="$2" -v release="$3" \
@ -74,36 +70,36 @@ function fix_alphatag()
} }
function fix_bundle_deps function fix_bundle_deps
# usage: fix_bundle_deps <specfile> <version> release # usage: fix_bundle_deps <specfile> <version> <release>
# Patches Requires: diaspora-bundle = 0.0-20101021-aefsf323148 # Patches: Requires: diaspora-bundle = 0.0-20101021-aefsf323148
{ {
awk -v vers="$2-$3" \ awk -v vers="$2-$3" \
' /Requires:/ { if ($2 == "diaspora-bundle") ' /Requires:/ { if ($2 == "diaspora-bundle")
printf( "%s %s = %s\n", $1,$2,vers) printf( "%s %s = %s\n", $1,$2,vers)
else else
print print
next next
} }
{ print}' \ { print}' \
< $1 > $1.tmp && cp $1.tmp $1 && rm $1.tmp < $1 > $1.tmp && cp $1.tmp $1 && rm $1.tmp
} }
function patch() function patch()
# Patch git_release, Requires: diaspora-bundle and top comment version. # Patch spec-files with current version-release
# Usage: patch VERSION RELEASE # Usage: patch VERSION RELEASE
{ {
sed -e "/^%define/s|HEAD|$2|" \ sed -e "/^%define/s|HEAD|$2|" \
-e '/^Version:/s|.*|Version: '$1'|' \ -e '/^Version:/s|.*|Version: '$1'|' \
<diaspora.spec >dist/diaspora.spec <diaspora.spec >dist/diaspora.spec
fix_alphatag dist/diaspora.spec $1 $2 fix_alphatag dist/diaspora.spec $1 $2
#mkdir dist/diaspora/tmp || : #mkdir dist/diaspora/tmp || :
bundle_id=$(git_id dist/diaspora/Gemfile) bundle_id=$(git_id dist/diaspora/Gemfile)
fix_bundle_deps dist/diaspora.spec $1 "1.$bundle_id.fc13" fix_bundle_deps dist/diaspora.spec $1 "1.$bundle_id.fc13"
sed -e "/^%define/s|HEAD|$bundle_deps|" \ sed -e "/^%define/s|HEAD|$bundle_deps|" \
-e '/^Version:/s|.*|Version: '$1'|' \ -e '/^Version:/s|.*|Version: '$1'|' \
< diaspora-bundle.spec > dist/diaspora-bundle.spec < diaspora-bundle.spec > dist/diaspora-bundle.spec
cp dist/diaspora.spec dist/diaspora/diaspora.spec cp dist/diaspora.spec dist/diaspora/diaspora.spec
} }
function checkout() function checkout()
@ -137,6 +133,7 @@ function checkout()
function make_dist function make_dist
# Create a distribution tarball # Create a distribution tarball
# Usage: make dist [ commit, defaults to HEAD]
{ {
commit=$(checkout ${1:-'HEAD'}) commit=$(checkout ${1:-'HEAD'})
echo "Creating source tarball for $commit" echo "Creating source tarball for $commit"
@ -160,25 +157,30 @@ function make_dist
} }
function make_bundle() function make_bundle()
# Create the bundle tarball
# Usage: make_bundle [ commit, defaults to HEAD]
#
{ {
checkout ${1:-'HEAD'} >/dev/null checkout ${1:-'HEAD'} >/dev/null
bundle_id=$(git_id dist/diaspora/Gemfile) bundle_id=$(git_id dist/diaspora/Gemfile)
bundle_name="diaspora-bundle-$VERSION-$bundle_id" bundle_name="diaspora-bundle-$VERSION-$bundle_id"
test -e "dist/$bundle_name.tar.gz" || { test -e "dist/$bundle_name.tar.gz" || {
echo "Creating bundle $bundle_name" echo "Creating bundle $bundle_name"
cd dist cd dist
rm -rf $bundle_name rm -rf $bundle_name
mkdir -p $bundle_name/bundle mkdir -p $bundle_name/bundle
pushd diaspora > /dev/null pushd diaspora > /dev/null
test -e ../../Gemfile.lock.patch && test -e ../../Gemfile.lock.patch &&
git apply ../../Gemfile.lock.patch > /dev/null 2>&1 git apply ../../Gemfile.lock.patch > /dev/null 2>&1
bundle install --deployment \ bundle install --deployment \
--path="../$bundle_name/bundle" \ --path="../$bundle_name/bundle" \
--without=test rdoc --without=test rdoc
cp -ar AUTHORS Gemfile GNU-AGPL-3.0 COPYRIGHT "../$bundle_name" cp -ar AUTHORS Gemfile GNU-AGPL-3.0 COPYRIGHT \
"../$bundle_name"
popd popd
tar czf $bundle_name.tar.gz $bundle_name tar czf $bundle_name.tar.gz $bundle_name
cd ..
} }
echo echo
echo "Bundle: dist/$bundle_name.tar.gz" echo "Bundle: dist/$bundle_name.tar.gz"
@ -213,16 +215,16 @@ function make_links()
function usage() function usage()
{ {
cat <<- EOF cat <<- EOF
Usage: make-dist [-c commit] <dist|bundle|links> Usage: make-dist [-c commit] <dist|bundle|links>
-c Use a given commit, defaults to last checked in. -c Use a given commit, defaults to last checked in.
dist Build a diaspora application tarball. dist Build a diaspora application tarball.
bundle Build a bundler(1) bundle for diaspora. bundle Build a bundler(1) bundle for diaspora.
links Symlink bundle and source tarballs to rpm source dir. links Symlink bundle and source tarballs to rpm source dir.
All results are stored in dist/ All results are stored in dist/
EOF EOF
} }
@ -242,25 +244,25 @@ test "$1" = "-c" && {
} }
case $1 in case $1 in
"bundle") make_bundle $commit "bundle") make_bundle $commit
;; ;;
'source') make_dist $commit 'source') make_dist $commit
;; ;;
'links') make_links $commit 'links') make_links $commit
;; ;;
"fix_gemfile") "fix_gemfile")
fix_gemfile fix_gemfile
;; ;;
*) usage *) usage
exit 1 exit 1
;; ;;
esac esac