make-dist handles commit arg, links handles all sources

This commit is contained in:
Alec Leamas 2010-10-07 01:48:44 +02:00
parent 5bd5aea484
commit 876a32d64b
4 changed files with 37 additions and 301 deletions

View file

@ -12,11 +12,11 @@ http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora
Create source tarballs like dist/diaspora-0.0-1010041233_fade4231.tar.gz
and dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz
% ./make_dist.sh source
% ./make_dist.sh bundle
% ./make-dist.sh source
% ./make-dist.sh bundle
Setup links to tarballs from RPM source directory:
% ./make_dist.sh links
% ./make-dist.sh links
Build rpms:
rpmbuild -ba dist/diaspora.spec
@ -47,9 +47,8 @@ Routines uses last available version from master branch at github. The
version contains a time stamp and an abbreviated git commit id. If listed
in filename order, like ls does, latest version will be the last one.
You need to copy all patches and secondary sources in this dir to
the rpm source directory a. k. a. $(rpm --eval %_sourcedir). This
includes some hidden .* files.
*make-dist links* creates links also for all files listed in SOURCES.
Typically, this is patches and secondary sources.
The spec-files in dist/ are patched by ./make_dist.sh source to reference
correct versions of diaspora and diaspora-bundle. The diaspora-bundle

View file

@ -37,8 +37,7 @@ while : ; do
read new_hostname garbage
echo -n "Use hostname \"$new_hostname\" (Yes/No) [Yes]? :"
read yesno garbage
test -z "$yesno" && yesno='yes'
test ${yesno:0:1} = 'y' -o ${yesno:0:1} = 'Y' && {
test ${yesno:0:1} = 'y' -o ${yesno:0:1} = 'Y' -o -z "$yesno" && {
sed -i "/pod_url:/s/$hostname/$new_hostname/g" config/app_config.yml &&
echo "config/app_config.yml updated."
break

View file

@ -1,12 +1,7 @@
#!/bin/bash
#Usage: make_dist [-b] [-d] [s] [-c <commit>]
#Usage: See function usage() at bottom.
#
# -b create a bundler bundle for diaspora
# -d create a diaspora source tarball
# -s synchronize Gemfile.lock VERY INTRUSIVE to RUBY ENVIRONMENT
# -c Use a given commit instead of last available
#
# Create a diaspora distribution
#
@ -41,8 +36,9 @@ function git_id
cd $dir
git log -1 --abbrev-commit --date=iso $file |
awk -v nl="$nl" \
' /commit/ { commit = $2 }
/Date/ { split( $2, d, "-")
' BEGIN { commit = "" }
/^commit/ { if ( commit == "") commit = $2 }
/^Date:/ { split( $2, d, "-")
split( $3, t, ":")
}
END { printf( "%s%s%s%s%s_%s%s",
@ -130,7 +126,7 @@ function checkout()
cd diaspora;
git fetch --quiet upstream
git merge --quiet upstream/master
git checkout --quiet -b dist ${1:-'HEAD'}
git checkout --quiet ${1:-'HEAD'}
git_id -n
)
}
@ -140,6 +136,7 @@ function make_dist
# Create a distribution tarball
{
commit=$(checkout ${1:-'HEAD'})
echo "Creating source tarball for $commit"
patch $VERSION $commit
RELEASE_DIR="diaspora-$VERSION-$commit"
@ -152,19 +149,27 @@ function make_dist
cp -r ../.bundle ${RELEASE_DIR}/master
mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR}
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && rm -rf ${RELEASE_DIR}
cd ..
bundle_id=$(git_id dist/diaspora/Gemfile)
echo "Source: dist/${RELEASE_DIR}.tar.gz"
echo "Required bundle: $bundle_id"
echo "Source specfile: dist/diaspora.spec"
echo "Bundle specfile: dist/diaspora-bundle.spec"
}
function make_bundle()
{
checkout 'HEAD'
checkout ${1:-'HEAD'} >/dev/null
bundle_id=$(git_id dist/diaspora/Gemfile)
bundle_name="diaspora-bundle-$VERSION-$bundle_id"
test -e "$bundle_name" || {
test -e "dist/$bundle_name.tar.gz" || {
echo "Creating bundle $bundle_name"
cd dist
rm -rf $bundle_name
mkdir -p $bundle_name/bundle
pushd diaspora > /dev/null
set -x
test -e ../../Gemfile.lock.patch &&
git apply ../../Gemfile.lock.patch > /dev/null 2>&1
rm -rf devise.tmp
git clone http://github.com/BadMinus/devise.git devise.tmp
( cd devise.tmp; gem build devise.gemspec)
@ -182,6 +187,8 @@ set -x
popd
tar czf $bundle_name.tar.gz $bundle_name
}
echo
echo "Bundle: dist/$bundle_name.tar.gz"
}
function make_links()
@ -192,6 +199,7 @@ function make_links()
echo "Can't find RPM source directory, giving up."
exit 2
}
echo "Linking sources to $dest"
src_commit="$1"
test -z "$src_commit" && {
@ -203,15 +211,15 @@ function make_links()
bundle_commit=$(git_id dist/diaspora/Gemfile)
bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz"
ln -sf $PWD/$bundle $dest
for file in $( egrep -v '^#' SOURCES); do
ln -sf $PWD/$file $dest/$file
done
cd $dest
find . -type l -not -readable -exec rm {} \;
}
function usage()
{
cat <<- EOF
@ -221,18 +229,20 @@ function usage()
-c Use a given commit, defaults to last checked in.
dist Build a diaspora application tarball.
bundle Build a bundler(1) bundle for diaspora.
links Symlink bundle and source tarballs to rpm sourde dir.
links Symlink bundle and source tarballs to rpm source dir.
All results are stored in dist/
EOF
}
test "$1" = "-h" -o $# = 0 && {
usage;
exit 0
}
test "$1" = "-c" && {
test-z "$2" && {
test -z "$2" && {
usage;
exit 1
}
@ -245,7 +255,8 @@ test "$1" = "-c" && {
"bundle") make_bundle $commit
;;
'source') make_dist $commit
'source') make_dist $commit
;;
'links') make_links $commit

View file

@ -1,273 +0,0 @@
#!/bin/bash
#Usage: make_dist [-b] [-d] [s] [-c <commit>]
#
# -b create a bundler bundle for diaspora
# -d create a diaspora source tarball
# -s synchronize Gemfile.lock VERY INTRUSIVE to RUBY ENVIRONMENT
# -c Use a given commit instead of last available
#
# Create a diaspora distribution
#
# Builds a diaspora distribution containing the application and bundled
# libraries. Normally checks out latest version of the master branch.
#
GIT_REPO='http://github.com/diaspora/diaspora.git'
RELEASE='HEAD'
VERSION='0.0'
function git_id
#
# Echo package-friendly source id.
#
# Usage: git_id [-n] [file or directory]
#
{
nl="\n"
file_or_dir="$PWD"
test "$1" = '-n' && { nl=""; shift; }
test -n "$1" && file_or_dir="$1"
if [ -d $file_or_dir ]; then
file=""
dir=$file_or_dir
else
file=$(basename $file_or_dir)
dir=$(dirname $file_or_dir)
fi
export LANG=C
(
cd $dir
git log -1 --abbrev-commit --date=iso $file |
awk -v nl="$nl" \
' /commit/ { commit = $2 }
/Date/ { split( $2, d, "-")
split( $3, t, ":")
}
END { printf( "%s%s%s%s%s_%s%s",
substr( d[1],3), d[2], d[3],
t[1], t[2],
commit, nl)
}'
)
}
function fix_alphatag()
# Patch version on top comment first id line:
# Uses %define git_release to get release.
#* Fri Sep 24 2010 name surname <email@com> 1.20100925_faf234320
{
dist=$(rpm --eval %dist)
awk -v dist="$dist" -v version="$2" \
' BEGIN { done = 0 }
/%define/ { if ($2 = "git_release") release = $3 }
/^[*]/ { if (done)
print
else
{
gsub( "1[.].*", "")
printf( "%s%s-1.%s%s\n",
$0, version, release,dist)
done = 1
}
next
}
{ print }' \
< $1 > $1.tmp && cp $1.tmp $1 && rm $1.tmp
}
function fix_bundle_deps
# usage: fix_bundle_deps <specfile> <version> release
# Patches Requires: diaspora-bundle = 0.0-20101021-aefsf323148
{
awk -v vers="$2-$3" \
' /Requires:/ { if ($2 == "diaspora-bundle")
printf( "%s %s = %s\n", $1,$2,vers)
else
print
next
}
{ print}' \
< $1 > $1.tmp && cp $1.tmp $1 && rm $1.tmp
}
function patch()
# Patch git_release, Requires: diaspora-bundle and top comment version.
# Usage: patch VERSION RELEASE
{
sed -e "/^%define/s|HEAD|$2|" \
-e '/^Version:/s|.*|Version: '$1'|' \
<diaspora.spec >dist/diaspora.spec
fix_alphatag dist/diaspora.spec $1
#mkdir dist/diaspora/tmp || :
bundle_id=$(git_id dist/diaspora/Gemfile)
fix_bundle_deps dist/diaspora.spec $1 "1.$bundle_id.fc13"
sed -e "/^%define/s|HEAD|$bundle_deps|" \
-e '/^Version:/s|.*|Version: '$1'|' \
< diaspora-bundle.spec > dist/diaspora-bundle.spec
cp dist/diaspora.spec dist/diaspora/diaspora.spec
}
function checkout()
# Checkout last version of diaspora unless it's already there.
# Returns: commit for current branch's HEAD.
{
mkdir dist >/dev/null 2>&1 || :
(
cd dist
test -d diaspora && {
( cd diaspora; git_id -n)
return
}
git clone --quiet $GIT_REPO; \
cd diaspora;
git checkout --quiet -b dist $GIT_VERSION;
git_id -n
)
}
function make_dist
# Create a distribution tarball
{
commit=$(checkout)
patch $VERSION $commit
RELEASE_DIR="diaspora-$VERSION-$commit"
rm -rf dist/${RELEASE_DIR}
mkdir dist/${RELEASE_DIR}
cp diaspora-ws diaspora-setup diaspora.logconf dist/${RELEASE_DIR}
cd dist
mkdir ${RELEASE_DIR}/master
cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master
cp -r ../.bundle ${RELEASE_DIR}/master
mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR}
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && rm -rf ${RELEASE_DIR}
}
#set -x
#mkdir dist || :
#pushd dist
# test -d diaspora || {
## git clone $GIT_REPO;
# pushd diaspora
# git checkout -b dist $RELEASE;
# git add upstream $GIT_REPO#
# popd
# }
# pushd diaspora
# git fetch upstream
# git merge upstream/master
# popd
#popd
function make_bundle()
{
bundle_id=$(git_id dist/diaspora/Gemfile)
bundle_name="diaspora-bundle-$VERSION-$bundle_id"
test -e "$bundle_name" || {
cd dist
rm -rf $bundle_name
mkdir -p $bundle_name/bundle
pushd diaspora > /dev/null
set -x
rm -rf devise.tmp
git clone http://github.com/BadMinus/devise.git devise.tmp
( cd devise.tmp; gem build devise.gemspec)
gem install --install-dir "../$bundle_name/bundle/ruby/1.8" \
--no-rdoc --no-ri \
--ignore-dependencies \
devise.tmp/devise-1.1.rc1.gem &&
rm -rf devise.tmp
bundle install --deployment \
--path="../$bundle_name/bundle" \
--without=test rdoc
cp AUTHORS Gemfile GNU-AGPL-3.0 COPYRIGHT "../$bundle_name"
popd
tar czf $bundle_name.tar.gz $bundle_name
}
}
function make_links()
# Usage: make_links [source commit]
{
dest=$(rpm --eval %_sourcedir)
test -z "$dest" && {
echo "Can't find RPM source directory, giving up."
exit 2
}
src_commit="$1"
test -z "$src_commit" && {
src_commit=$(checkout)
}
src="dist/diaspora-$VERSION-$src_commit.tar.gz"
ln -sf $PWD/$src $dest
bundle_commit=$(git_id dist/diaspora/Gemfile)
bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz"
ln -sf $PWD/$bundle $dest
cd $dest
find . -type l -not -readable -exec rm {} \;
}
function usage()
{
cat <<- EOF
Usage: make_dist [-c commit] <dist|bundle|links>
-c Use a given commit, defaults to last checked in.
dist Build a diaspora application tarball.
bundle Build a bundler(1) bundle for diaspora.
links Symlink bundle and source tarballs to rpm sourde dir.
All results are stored in dist/
EOF
}
test "$1" = "-h" -o $# = 0 && {
usage;
exit 0
}
test "$1" = "-c" && {
test-z "$2" && {
usage;
exit 1
}
commit="$2"
shift; shift
}
case $1 in
"bundle") make_bundle $commit
;;
'source') make_dist $commit
;;
'links') make_links $commit
;;
"fix_gemfile")
fix_gemfile
;;
*) usage
exit 1
;;
esac