From ee1f2063b4bdcc82d95e9f2ff89a9e2390a6ad56 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 00:11:13 +0200 Subject: [PATCH 01/19] Initial, buggy file check in --- pkg/fedora/README.fedora | 27 ++++ pkg/fedora/diaspora-bundle.spec | 213 ++++++++++++++++++++++++++++++ pkg/fedora/diaspora-ws | 102 +++++++++++++++ pkg/fedora/diaspora.logconf | 12 ++ pkg/fedora/diaspora.spec | 110 ++++++++++++++++ pkg/fedora/make_dist.sh | 223 ++++++++++++++++++++++++++++++++ 6 files changed, 687 insertions(+) create mode 100755 pkg/fedora/README.fedora create mode 100644 pkg/fedora/diaspora-bundle.spec create mode 100755 pkg/fedora/diaspora-ws create mode 100644 pkg/fedora/diaspora.logconf create mode 100644 pkg/fedora/diaspora.spec create mode 100755 pkg/fedora/make_dist.sh diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora new file mode 100755 index 000000000..851a5b330 --- /dev/null +++ b/pkg/fedora/README.fedora @@ -0,0 +1,27 @@ +#Build ruby-1.8.7 on Fedora 13 +#============================ +set -x + + + +rpmdir=$(rpm --showrc | grep _rpmdir | cut -f2) +echo "Building rpms in $rpmdir" + +sudo yum install yum-utils fedora-release-rawhide + +yumdownloader --enablerepo=rawhide --source ruby +vers=$( ls ruby-*src.rpm) +vers=$(echo ${vers%.fc*}) +vers=$(echo ${vers#ruby-}) +echo "Downloaded and uding version $vers" + +sudo yum install $( rpm -q --requires -p ruby*src.rpm | grep -v rpmlib) +rpmbuild --rebuild ruby-1.8.7.302-1.fc15.src.rpm +sudo rpm -i $rpmdir/i686/ruby-$vers.i686.rpm +sudo rpm -i $rpmdir/i686/ruby-libs-$vers.i686.rpm +sudo rpm -i $rpmdir/i686/ruby-irb-$vers.i686.rpm +sudo rpm -i $rpmdir/noarch/ruby-rdoc-$rdoc.noarch.rpm + +rpmbuild --rebuild rubygems-*.src.rpm +sudo rpm -i $rpmdir/noarch/rubygems-*.noarch.rpm + diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec new file mode 100644 index 000000000..ccf7018c2 --- /dev/null +++ b/pkg/fedora/diaspora-bundle.spec @@ -0,0 +1,213 @@ +%define git_release 1010040945_a09a6d8 +# Turn off the brp-python-bytecompile script +%global __os_install_post %(echo '%{__os_install_post}' | + sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') + +Summary: Rubygem bundle for diaspora +Name: diaspora-bundle +Version: 0.0 +Release: 1.%{git_release}%{?dist} +License: AGPLv3 +Group: Applications/Communications +URL: http://www.joindiaspora.com/ +Vendor: joindiaspora.com +Source: %{name}-%{version}-%{git_release}.tar.gz +Prefix: %{_prefix} +BuildRequires: git +Requires: ruby(abi) = 1.8 + +%description +The ruby apps bundled with diaspora, as provided by +bundle install --deployment and patched for Fedora use. + +%package devel +Summary: Development files (i. e., sources) for diaspora-bundle +Group: Development/Libraries +Requires: %{name} = %{version} + +%description devel +Source file usede to compile native libraries in diaspora-bundle. + + + +%prep +%setup -q -n %{name}-%{version}-%{git_release} + +pushd bundle/ruby/1.8/ + find . -name \*.css -exec chmod 644 {} \; + find . -name \*.js -exec chmod 644 {} \; + find . -name \*.treetop -exec chmod 644 {} \; + find . -name \*.rdoc -exec chmod 644 {} \; + chmod 644 gems/term-ansicolor-1.0.5/CHANGES || : + chmod 755 gems/cucumber-rails-0.3.2/templates/install/script/cucumber || : + chmod 755 gems/ruby-debug-base-0.10.3/Rakefile || : + chmod 644 gems/cucumber-rails-0.3.2/History.txt || : + chmod 644 gems/cucumber-rails-0.3.2/templates/install/step_definitions/capybara_steps.rb.erb || : + chmod 644 gems/rack-1.2.1/test/cgi/lighttpd.conf || : + chmod 644 gems/term-ansicolor-1.0.5/VERSION || : + chmod 644 gems/mini_magick-2.1/Rakefile || : + chmod 755 gems/linecache-0.43/Rakefile || : + chmod 644 gems/ffi-0.6.3/ext/ffi_c/libffi/ltmain.sh || : + chmod 644 gems/term-ansicolor-1.0.5/README || : + chmod 755 gems/mini_magick-2.1/test/not_an_image.php || : + chmod 755 gems/rake-0.8.7/test/data/statusreturn/Rakefile || : + chmod 755 gems/ruby-debug-0.10.3/Rakefile || : + chmod 644 gems/gherkin-2.2.4/tasks/compile.rake || : + chmod 755 gems/rake-0.8.7/test/data/file_creation_task/Rakefile || : + chmod 644 gems/term-ansicolor-1.0.5/Rakefile || : + chmod 755 gems/mime-types-1.16/Rakefile || : + for f in $(find . -name \*.rb); do + sed -i -e '/^#!/d' $f + chmod 0644 $f + done > /dev/null 2>&1 + find . -type f -print0 | + xargs --null sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' + + chmod 755 gems/thin-1.2.7/example/async_chat.ru + chmod 755 gems/thin-1.2.7/example/async_tailer.ru + #chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html + chmod 644 gems/i18n-0.4.1/MIT-LICENSE + chmod 755 gems/abstract-1.0.0/abstract.gemspec + chmod 644 gems/mini_magick-2.1/MIT-LICENSE + #chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg + chmod 755 gems/thin-1.2.7/lib/thin/controllers/service.sh.erb + chmod 644 gems/treetop-1.4.8/spec/compiler/test_grammar.tt + + #sed -i -e "s|\r||" master/public/javascripts/jquery.cycle/src/jquery.cycle.lite.js + #sed -i -e "s|\r||" master/public/javascripts/fancybox/jquery.fancybox-1.3.1.js +popd + + +%build + +pushd bundle/ruby/1.8/ + test -d gems/gherkin-*/ext && { + pushd gems/gherkin-*/ext + # Recompile all shared libraries using -O2 optimalization flagcd + for lexer_dir in */ ; do + pushd $lexer_dir + sed -i 's/ -O0 / -O2 /' extconf.rb + # Remove #line lines from C sources + sed -i '/^#line/d' *.c + CONFIGURE_ARGS="--with-cflags='%{optflags}'" ruby extconf.rb + make clean && make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" + make install RUBYARCHDIR="../../lib" + mv ../../lib/${lexer_dir%/}.so . + pushd ../../lib + ln -sf ../ext/${lexer_dir%/}/${lexer_dir%/}.so . + popd + popd + done + popd + } + + test -d gems/ffi-0.6.3/lib && { + pushd gems/ffi-0.6.3/lib + rm ffi_c.so + ln -s ../ext/ffi_c/ffi_c.so . + popd + } + + pushd gems/thin-1.2.7/lib + rm thin_parser.so + ln -s ../ext/thin_parser/thin_parser.so . + popd + + pushd gems/bson_ext-1.0.7/ext/bson_ext + rm cbson.so + ln -s ../cbson/cbson.so . + popd + + pushd gems/ruby-debug-base-0.10.3/lib + rm ruby_debug.so + ln -s ../ext/ruby_debug.so . + popd + + #in repo + pushd gems/eventmachine-0.12.10/lib + rm rubyeventmachine.so + rm fastfilereaderext.so + ln -s ../ext/rubyeventmachine.so . + ln -s ../ext/fastfilereader/fastfilereaderext.so . + popd + + pushd gems/bcrypt-ruby-2.1.2/lib + rm bcrypt_ext.so + ln -s ../ext/mri/bcrypt_ext.so . + popd + + # in repo + pushd gems/nokogiri-1.4.3.1/lib/nokogiri + rm nokogiri.so + ln -sf ../../ext/nokogiri/nokogiri.so . + popd + + pushd gems/json-1.4.6/ext/json/ext/json/ext + rm generator.so + ln -s ../../generator/generator.so + rm parser.so + ln -s ../../parser/parser.so . + popd + + #in repo + pushd gems/linecache-0.43/lib/ + rm trace_nums.so + ln -s ../ext/trace_nums.so . + popd + + pushd bundler/gems/em-http-request-6f66010cda90/lib + rm em_buffer.so + ln -s ../ext/buffer/em_buffer.so . + rm http11_client.so + ln -s ../ext/http11_client/http11_client.so . + popd +popd + + +%install +find . -name .git | xargs rm -rf +find . -name .gitignore -delete +find . -name \*.o -delete || : + +test -d bundle/ruby/1.8/gems/selenium-webdriver-0.0.28 && { +pushd bundle/ruby/1.8/gems/selenium-webdriver-0.0.28/lib/selenium/webdriver/ +%ifarch %ix86 x86_64 +%ifarch %ix86 + rm -rf firefox/native/linux/amd64 +%else + rm -rf firefox/native/linux/i386 +%endif +%else + rm -rf firefox/native/linux/i386 + rm -rf firefox/native/linux/amd64 +%endif +popd +} + +[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor + +cp -ar bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor +find %{buildroot}/%{_libdir}/diaspora-bundle \ + -type d -fprintf dirs '%%%dir "%%p"\n' +find -L %{buildroot}/%{_libdir}/diaspora-bundle \ + -regextype posix-awk -type f -not -regex '.*[.]c$|.*[.]h$|.*[.]cpp$' -fprintf files '"%%p"\n' +find %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \ + -type f -regex '.*[.]c$|.*[.]h$|.*[.]cpp$' -fprintf dev-files '"%%p"\n' +sed -i -e 's|%{buildroot}||' -e 's|//|/|' files dev-files dirs +cat files >> dirs && cp dirs files + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT + +%files -f files +%defattr(-, root, root, 0755) +%doc COPYRIGHT Gemfile AUTHORS GNU-AGPL-3.0 + +%files -f dev-files devel +%defattr(-, root, root, 0644) +%doc COPYRIGHT AUTHORS GNU-AGPL-3.0 + +%changelog +* Sat Oct 02 2010 Alec Leamas 1.1009271539_08b9aa8 + - Initial attempt to create a spec file diff --git a/pkg/fedora/diaspora-ws b/pkg/fedora/diaspora-ws new file mode 100755 index 000000000..6208acc1c --- /dev/null +++ b/pkg/fedora/diaspora-ws @@ -0,0 +1,102 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/diaspora-ws +# +# Starts the diaspora websocket server +# +# chkconfig: - 80 80 +# description: Diaspora websocket server + +### BEGIN INIT INFO +# Provides: diaspora-ws +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Should-Start: $remote_fs +# Should-Stop: $remote_fs +# Default-Start: +# Default-Stop: 0 1 2 3 4 5 6 +# Short-Description: start and stop Diaspora websocket server +# Description: The websocket server provides websocket services for +# diaspora. +### END INIT INFO + +# Source function library. +. /etc/init.d/functions + +if [ -f /etc/sysconfig/diaspora-ws -a $UID -eq 0 ]; then + . /etc/sysconfig/diaspora-ws +fi + +cd /usr/share/diaspora + +RETVAL=0 +prog="Diaspora websocket server" +exec="script/websocket_server.rb" +pidfile="/var/run/diaspora-ws" +lockfile="/var/lock/subsys/diaspora-ws" +logfile=/var/log/diaspora-ws.log + +[ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS" +ruby_cmd="ruby -C $PWD $exec$OPTIONS" + +start() { + [ $UID -eq 0 ] || exit 4 + [ -f $exec ] || exit 5 + + echo -n $"Starting $prog: " + daemon --pidfile $pidfile "$ruby_cmd >>$logfile 2>&1 &" + RETVAL=$? + echo + if test $RETVAL = 0; then + touch $lockfile + pgrep -f "$ruby_cmd" > $pidfile || { + echo "Warning: cannot find running diaspora-webserver" + exit 7 + } + fi +} + +stop() { + [ $UID -eq 0 ] || exit 4 + echo -n $"Stopping $prog: " + killproc -p $pidfile $exec + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $lockfile + echo +} + +# +# See how we were called. +# +case "$1" in + start) + start + ;; + stop) + stop + ;; + force-reload|restart) + stop + sleep 1 + start + RETVAL=$? + ;; + condrestart|try-restart) + if [ -f $lockfile ]; then + stop + sleep 3 + start + fi + ;; + status) + status -p $pidfile $exec + RETVAL=$? + ;; + *) + echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|force-reload|status}" + RETVAL=2 + [ "$1" = 'usage' ] && RETVAL=0 +esac + +exit $RETVAL + diff --git a/pkg/fedora/diaspora.logconf b/pkg/fedora/diaspora.logconf new file mode 100644 index 000000000..e51c705ed --- /dev/null +++ b/pkg/fedora/diaspora.logconf @@ -0,0 +1,12 @@ +/var/log/diaspora/*.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok + postrotate + (/sbin/service diaspora-ws status | grep running /sbin/servive diaspora-ws restart || :) >/dev/null 2>&1 + endscript +} diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec new file mode 100644 index 000000000..5aaa5a544 --- /dev/null +++ b/pkg/fedora/diaspora.spec @@ -0,0 +1,110 @@ +# +# Build diaspora RPM package. +# +# Packages current HEAD if the diaspora master branch +# to a reasonable Fedora RPM. +# +# If the environment variable GIT_VERSION is set, builds an rpm +# from this version (i. e., uses this commit). +# +%define git_release HEAD + +Summary: A social network server +Name: diaspora +Version: 0.0.1 +Release: 1.%{git_release}%{?dist} +License: AGPLv3 +Group: Applications/Communications +URL: http://www.joindiaspora.com/ +Vendor: joindiaspora.com +Source: %{name}-%{version}-%{git_release}.tar.gz +Source1: diaspora-ws +#BuildRoot: %{_tmppath}/root-%{name}-%{version} +#Prefix: %{_prefix} + +BuildRequires: git +Requires(pre): shadow-utils +Requires: mongodb-server +Requires: ruby(abi) = 1.8 +Requires: diaspora-bundle = %{version} + +%description +A privacy aware, personally controlled, do-it-all and +open source social network server. + +%pre +getent group diaspora >/dev/null || groupadd -r diaspora +getent passwd diaspora >/dev/null || \ + useradd -r -g diaspora \ + -md /var/diaspora -s /sbin/nologin \ + -c "Diaspora daemon" diaspora +exit 0 + +%prep +%setup -q -n %{name}-%{version}-%{git_release} +mkdir diaspora/tmp || : + +%build +find . -name .git* -execdir rm -rf {} \; || : +#find . -name test -execdir rm -rf {} \; || : > /dev/null 2>&1 +find . -name \*.css -exec chmod 644 {} \; +find . -name \*.js -exec chmod 644 {} \; +#find . -name \*.treetop -exec chmod 644 {} \; +find . -name \*.rdoc -exec chmod 644 {} \; +#find . -name Rakefile -exec chmod 755 {} \; +#for f in $(find . -name \*.rb); do +# sed -i -e '/^#!/d' $f +# chmod 0644 $f +#done > /dev/null 2>&1 +find . -type f -exec \ + sed -i 's/^#!\/usr\/local\/bin\/ruby/#!\/usr\/bin\/ruby/g' {} \; > /dev/null + +chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html +chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg +sed -i -e "s|\r||" master/public/javascripts/jquery.cycle/src/jquery.cycle.lite.js +sed -i -e "s|\r||" master/public/javascripts/fancybox/jquery.fancybox-1.3.1.js + + +%install +[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora +mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora/master/vendor +cp master/README.md . +mv master/GNU-AGPL-3.0 . + +sed -i '/^cd /s|.*|cd %{_datadir}/diaspora/master|' diaspora-ws +mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora +mkdir -p $RPM_BUILD_ROOT/etc/init.d +cp diaspora-ws $RPM_BUILD_ROOT/etc/init.d +mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d +cp diaspora $RPM_BUILD_ROOT/etc/logrotate.d + +%post +/bin/chown diaspora:diaspora %{_localstatedir}/log/diaspora +ln -sf %{_localstatedir}/log/diaspora \ + %{_datadir}/diaspora/master/log || : +ln -sf %{_libdir}/diaspora/master/vendor/bundle \ + %{_datadir}/diaspora/master/vendor || : +/sbin/chkconfig --add diaspora-ws + +%preun +if [ $1 -eq 0 ] ; then + service diaspora-ws stop >/dev/null 2>&1 || : + /sbin/chkconfig --del diaspora-ws +fi + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT + +%files +%defattr(-, root, root, 0755) +%doc README.md GNU-AGPL-3.0 +%{_datadir}/diaspora +%{_libdir}/diaspora +%{_localstatedir}/log/diaspora +%config(noreplace) %{_sysconfdir}/logrotate.d/diaspora +%{_sysconfdir}/init.d/diaspora-ws + +%changelog +* Fri Sep 24 2010 Alec Leamas 1.1009280542_859ec2d + - Initial attempt to create a spec file diff --git a/pkg/fedora/make_dist.sh b/pkg/fedora/make_dist.sh new file mode 100755 index 000000000..3c9085b3c --- /dev/null +++ b/pkg/fedora/make_dist.sh @@ -0,0 +1,223 @@ +#!/bin/bash + +#Usage: make_dist [-b] [-d] [s] [-c ] +# +# -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 1.20100925_faf234320 +{ +set -x + 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 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'|' \ + 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 $bundle_id + 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 dispora unless it's already there. +{ + mkdir dist || : + ( + cd dist + rm -rf diaspora; 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 dist/${RELEASE_DIR} + cp diaspora.logconf dist/${RELEASE_DIR}/diaspora + cd dist + mkdir ${RELEASE_DIR}/master + cp -ar diaspora/* ${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 + 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 usage() +{ + cat <<- EOF + Usage: make_dist [-c commit] + -c Use a given commit, defaults to last checked in. + dist Build a diaspora application tarball. + bundle Build a bundler(1) bundle for diaspora. + fix_gemlock Try to fix out-of order gemlock, VERY INTRUSIVE. + + All results are stored in dist/ + EOF +} +set -x +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 + ;; + "dist") make_dist $commit + ;; + "fix_gemfile") + fix_gemfile + ;; + + *) usage + exit 1 + ;; + esac + + + From b0abe9db079bf95fdc28a7b4d816a682f97d9f95 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 00:12:00 +0200 Subject: [PATCH 02/19] bugfix --- pkg/fedora/README.fedora | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pkg/fedora/README.fedora diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora old mode 100755 new mode 100644 From ff48b6cd7b36dc0393c8cc17486e28e600e8214d Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 15:19:21 +0200 Subject: [PATCH 03/19] provisionary, passes rpmbuild and rpmplint (more or less) --- pkg/fedora/README.fedora | 28 +------------------- pkg/fedora/diaspora.spec | 53 ++++++++++++++++++-------------------- pkg/fedora/make_dist.sh | 55 ++++++++++++++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora index 851a5b330..a0990367e 100644 --- a/pkg/fedora/README.fedora +++ b/pkg/fedora/README.fedora @@ -1,27 +1 @@ -#Build ruby-1.8.7 on Fedora 13 -#============================ -set -x - - - -rpmdir=$(rpm --showrc | grep _rpmdir | cut -f2) -echo "Building rpms in $rpmdir" - -sudo yum install yum-utils fedora-release-rawhide - -yumdownloader --enablerepo=rawhide --source ruby -vers=$( ls ruby-*src.rpm) -vers=$(echo ${vers%.fc*}) -vers=$(echo ${vers#ruby-}) -echo "Downloaded and uding version $vers" - -sudo yum install $( rpm -q --requires -p ruby*src.rpm | grep -v rpmlib) -rpmbuild --rebuild ruby-1.8.7.302-1.fc15.src.rpm -sudo rpm -i $rpmdir/i686/ruby-$vers.i686.rpm -sudo rpm -i $rpmdir/i686/ruby-libs-$vers.i686.rpm -sudo rpm -i $rpmdir/i686/ruby-irb-$vers.i686.rpm -sudo rpm -i $rpmdir/noarch/ruby-rdoc-$rdoc.noarch.rpm - -rpmbuild --rebuild rubygems-*.src.rpm -sudo rpm -i $rpmdir/noarch/rubygems-*.noarch.rpm - +TBD diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 5aaa5a544..8e7a2ef39 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -7,6 +7,8 @@ # If the environment variable GIT_VERSION is set, builds an rpm # from this version (i. e., uses this commit). # + +%global debug_package %{nil} %define git_release HEAD Summary: A social network server @@ -19,10 +21,10 @@ URL: http://www.joindiaspora.com/ Vendor: joindiaspora.com Source: %{name}-%{version}-%{git_release}.tar.gz Source1: diaspora-ws -#BuildRoot: %{_tmppath}/root-%{name}-%{version} -#Prefix: %{_prefix} +BuildArch: noarch BuildRequires: git + Requires(pre): shadow-utils Requires: mongodb-server Requires: ruby(abi) = 1.8 @@ -34,56 +36,50 @@ open source social network server. %pre getent group diaspora >/dev/null || groupadd -r diaspora -getent passwd diaspora >/dev/null || \ - useradd -r -g diaspora \ - -md /var/diaspora -s /sbin/nologin \ +getent passwd diaspora >/dev/null || \ + useradd -r -g diaspora \ + -md /var/lib/diaspora -s /sbin/nologin \ -c "Diaspora daemon" diaspora exit 0 %prep %setup -q -n %{name}-%{version}-%{git_release} + mkdir diaspora/tmp || : +find . -name .git | xargs rm -rf || : +find . -type f -exec \ + sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null + +# Patch request: http://github.com/diaspora/diaspora/issues/issue/392 +find . -name \*.css -print0 | xargs --null chmod 644 +find . -name \*.js -print0 | xargs --null chmod 644 +chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg +chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html %build -find . -name .git* -execdir rm -rf {} \; || : -#find . -name test -execdir rm -rf {} \; || : > /dev/null 2>&1 -find . -name \*.css -exec chmod 644 {} \; -find . -name \*.js -exec chmod 644 {} \; -#find . -name \*.treetop -exec chmod 644 {} \; -find . -name \*.rdoc -exec chmod 644 {} \; -#find . -name Rakefile -exec chmod 755 {} \; -#for f in $(find . -name \*.rb); do -# sed -i -e '/^#!/d' $f -# chmod 0644 $f -#done > /dev/null 2>&1 -find . -type f -exec \ - sed -i 's/^#!\/usr\/local\/bin\/ruby/#!\/usr\/bin\/ruby/g' {} \; > /dev/null - -chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html -chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg -sed -i -e "s|\r||" master/public/javascripts/jquery.cycle/src/jquery.cycle.lite.js -sed -i -e "s|\r||" master/public/javascripts/fancybox/jquery.fancybox-1.3.1.js - +rm -rf master/vendor/bundle %install + [ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora -mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora/master/vendor cp master/README.md . mv master/GNU-AGPL-3.0 . -sed -i '/^cd /s|.*|cd %{_datadir}/diaspora/master|' diaspora-ws mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora mkdir -p $RPM_BUILD_ROOT/etc/init.d +sed -i '/^cd /s|.*|cd %{_datadir}/diaspora/master|' diaspora-ws cp diaspora-ws $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d -cp diaspora $RPM_BUILD_ROOT/etc/logrotate.d +cp diaspora.logconf $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora +cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora %post /bin/chown diaspora:diaspora %{_localstatedir}/log/diaspora ln -sf %{_localstatedir}/log/diaspora \ %{_datadir}/diaspora/master/log || : -ln -sf %{_libdir}/diaspora/master/vendor/bundle \ +ln -sf %{_libdir}/diaspora-bundle/master/vendor/bundle \ %{_datadir}/diaspora/master/vendor || : /sbin/chkconfig --add diaspora-ws @@ -100,7 +96,6 @@ fi %defattr(-, root, root, 0755) %doc README.md GNU-AGPL-3.0 %{_datadir}/diaspora -%{_libdir}/diaspora %{_localstatedir}/log/diaspora %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-ws diff --git a/pkg/fedora/make_dist.sh b/pkg/fedora/make_dist.sh index 3c9085b3c..b2ca4695e 100755 --- a/pkg/fedora/make_dist.sh +++ b/pkg/fedora/make_dist.sh @@ -59,7 +59,6 @@ function fix_alphatag() # Uses %define git_release to get release. #* Fri Sep 24 2010 name surname 1.20100925_faf234320 { -set -x dist=$(rpm --eval %dist) awk -v dist="$dist" -v version="$2" \ ' BEGIN { done = 0 } @@ -98,14 +97,14 @@ function patch() # Patch git_release, Requires: diaspora-bundle and top comment version. # Usage: patch VERSION RELEASE { - sed -e "/^%%define/s|HEAD|$2|" \ + sed -e "/^%define/s|HEAD|$2|" \ -e '/^Version:/s|.*|Version: '$1'|' \ dist/diaspora.spec fix_alphatag dist/diaspora.spec $1 - mkdir dist/diaspora/tmp + #mkdir dist/diaspora/tmp || : bundle_id=$(git_id dist/diaspora/Gemfile) - fix_bundle_deps dist/diaspora.spec $1 $bundle_id - sed -e "/^%%define/s|HEAD|$bundle_deps|" \ + 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 @@ -113,12 +112,17 @@ function patch() } function checkout() -# Checkout last version of dispora unless it's already there. +# Checkout last version of diaspora unless it's already there. +# Returns: commit for current branch's HEAD. { mkdir dist || : ( cd dist - rm -rf diaspora; git clone --quiet $GIT_REPO; \ + 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 @@ -136,7 +140,7 @@ function make_dist rm -rf dist/${RELEASE_DIR} mkdir dist/${RELEASE_DIR} cp diaspora-ws dist/${RELEASE_DIR} - cp diaspora.logconf dist/${RELEASE_DIR}/diaspora + cp diaspora.logconf dist/${RELEASE_DIR} cd dist mkdir ${RELEASE_DIR}/master cp -ar diaspora/* ${RELEASE_DIR}/master @@ -176,6 +180,34 @@ function make_bundle() } } +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 @@ -188,7 +220,6 @@ function usage() All results are stored in dist/ EOF } -set -x test "$1" = "-h" -o $# = 0 && { usage; exit 0 @@ -208,8 +239,12 @@ test "$1" = "-c" && { "bundle") make_bundle $commit ;; - "dist") make_dist $commit + 'source') make_dist $commit ;; + + 'links') make_links $commit + ;; + "fix_gemfile") fix_gemfile ;; From 735bb847c2a9a75921f6ad5eb60e6c2b68da3028 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 16:00:09 +0200 Subject: [PATCH 04/19] provisionary --- pkg/fedora/diaspora.spec | 1 + pkg/fedora/make_dist.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 8e7a2ef39..9a409f526 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -74,6 +74,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d cp diaspora.logconf $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora +cp master/.gitignore $RPM_BUILD_ROOT/%{_datadir}/diaspora/master %post /bin/chown diaspora:diaspora %{_localstatedir}/log/diaspora diff --git a/pkg/fedora/make_dist.sh b/pkg/fedora/make_dist.sh index b2ca4695e..3d5828e30 100755 --- a/pkg/fedora/make_dist.sh +++ b/pkg/fedora/make_dist.sh @@ -115,7 +115,7 @@ function checkout() # Checkout last version of diaspora unless it's already there. # Returns: commit for current branch's HEAD. { - mkdir dist || : + mkdir dist >/dev/null 2>&1 || : ( cd dist test -d diaspora && { @@ -143,7 +143,7 @@ function make_dist cp diaspora.logconf dist/${RELEASE_DIR} cd dist mkdir ${RELEASE_DIR}/master - cp -ar diaspora/* ${RELEASE_DIR}/master + cp -ar diaspora/* diaspora/.gitignore ${RELEASE_DIR}/master mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR} tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && rm -rf ${RELEASE_DIR} } From 55dd35dcc13ef9dc9241e760538eaa792500cddf Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 17:29:40 +0200 Subject: [PATCH 05/19] provisionary --- pkg/fedora/diaspora.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 9a409f526..83355b87e 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -58,6 +58,9 @@ chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html %build rm -rf master/vendor/bundle +pushd master + tar cf public/source.tar --exclude='source.tar' -X .gitignore * +popd %install From 9f21b9383dd17b9f54110e91d1d1458628819a40 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 5 Oct 2010 21:47:17 +0200 Subject: [PATCH 06/19] Server start, but fails on missing .git dirs (!) --- pkg/fedora/.bundle/config | 5 +++++ pkg/fedora/source-fix.patch | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 pkg/fedora/.bundle/config create mode 100644 pkg/fedora/source-fix.patch diff --git a/pkg/fedora/.bundle/config b/pkg/fedora/.bundle/config new file mode 100644 index 000000000..1c3e2cedf --- /dev/null +++ b/pkg/fedora/.bundle/config @@ -0,0 +1,5 @@ +--- +BUNDLE_FROZEN: "1" +BUNDLE_DISABLE_SHARED_GEMS: "1" +BUNDLE_WITHOUT: test:rdoc +BUNDLE_PATH: vendor/bundle diff --git a/pkg/fedora/source-fix.patch b/pkg/fedora/source-fix.patch new file mode 100644 index 000000000..55dffae43 --- /dev/null +++ b/pkg/fedora/source-fix.patch @@ -0,0 +1,21 @@ +diff --git a/script/server b/script/server +index da43895..c5357a3 100755 +--- a/script/server ++++ b/script/server +@@ -7,9 +7,13 @@ then + echo "Mongod not started" + else + mkdir -p -v log/thin/ +- #force AGPL +- tar cf ../_source.tar -X .gitignore * +- mv ../_source.tar public/source.tar ++ #force AGPL ++ test -w public -a ! -e public/source.tar && ++ tar cf public/source.tar --exclude='source.tar' -X .gitignore * ++ test -e public/source.tar || { ++ echo "Can't find, or even create, public/source.tar. Giving up" ++ exit 2 ++ } + bundle exec ruby ./script/websocket_server.rb& + bundle exec thin start $@ + fi From 995dc4ee6af6d0ec862ffc3888aa3a3eb3ab23de Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 04:21:44 +0200 Subject: [PATCH 07/19] Server starts OK. --- pkg/fedora/diaspora-bundle.spec | 4 ---- pkg/fedora/diaspora.spec | 11 +++++++++-- pkg/fedora/make_dist.sh | 28 ++++++++++++++++++++++------ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index ccf7018c2..87656f110 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -65,16 +65,12 @@ pushd bundle/ruby/1.8/ chmod 755 gems/thin-1.2.7/example/async_chat.ru chmod 755 gems/thin-1.2.7/example/async_tailer.ru - #chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html chmod 644 gems/i18n-0.4.1/MIT-LICENSE chmod 755 gems/abstract-1.0.0/abstract.gemspec chmod 644 gems/mini_magick-2.1/MIT-LICENSE - #chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg chmod 755 gems/thin-1.2.7/lib/thin/controllers/service.sh.erb chmod 644 gems/treetop-1.4.8/spec/compiler/test_grammar.tt - #sed -i -e "s|\r||" master/public/javascripts/jquery.cycle/src/jquery.cycle.lite.js - #sed -i -e "s|\r||" master/public/javascripts/fancybox/jquery.fancybox-1.3.1.js popd diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 83355b87e..6adab3db1 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -23,6 +23,9 @@ Source: %{name}-%{version}-%{git_release}.tar.gz Source1: diaspora-ws BuildArch: noarch +# See http://github.com/diaspora/diaspora/issues/issue/393 +Patch0: source-fix.patch + BuildRequires: git Requires(pre): shadow-utils @@ -44,9 +47,13 @@ exit 0 %prep %setup -q -n %{name}-%{version}-%{git_release} +pushd master +%patch0 -p1 +popd -mkdir diaspora/tmp || : -find . -name .git | xargs rm -rf || : + +mkdir master/tmp || : +#find . -name .git | xargs rm -rf || : find . -type f -exec \ sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null diff --git a/pkg/fedora/make_dist.sh b/pkg/fedora/make_dist.sh index 3d5828e30..7fbaea2aa 100755 --- a/pkg/fedora/make_dist.sh +++ b/pkg/fedora/make_dist.sh @@ -143,7 +143,8 @@ function make_dist cp diaspora.logconf dist/${RELEASE_DIR} cd dist mkdir ${RELEASE_DIR}/master - cp -ar diaspora/* diaspora/.gitignore ${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} } @@ -172,9 +173,22 @@ function make_bundle() cd dist rm -rf $bundle_name mkdir -p $bundle_name/bundle - pushd diaspora - bundle install --deployment --path="../$bundle_name/bundle" --without=test rdoc - cp AUTHORS Gemfile GNU-AGPL-3.0 COPYRIGHT "../$bundle_name" + 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 } @@ -211,11 +225,13 @@ function make_links() function usage() { cat <<- EOF - Usage: make_dist [-c commit] + + Usage: make_dist [-c commit] + -c Use a given commit, defaults to last checked in. dist Build a diaspora application tarball. bundle Build a bundler(1) bundle for diaspora. - fix_gemlock Try to fix out-of order gemlock, VERY INTRUSIVE. + links Symlink bundle and source tarballs to rpm sourde dir. All results are stored in dist/ EOF From ec9580aaf7553341a07743210d9bfd0aee19f4f3 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 04:37:03 +0200 Subject: [PATCH 08/19] provisionary --- pkg/fedora/README.fedora | 19 ++++++++++++++++++- pkg/fedora/diaspora.spec | 12 +----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora index a0990367e..fc3c8b61e 100644 --- a/pkg/fedora/README.fedora +++ b/pkg/fedora/README.fedora @@ -1 +1,18 @@ -TBD +Here is tools to package diaspora as a RPM package. + +Synopsis: + +# Create dist/diaspora-0.0-1010041233_faded4231.tar.gz +% ./make_dist.sh source + +# Create dist/diaspora-bundle-0.0-1010041233_faded4231.tar.gz +% ./make_dist.sh bundle + +# Setup links to tarballs from RPM source directory: +% ./make_dist.sh links + +# Build rpms: +rpmbuild -ba dist/diaspora.spec +rpmbuild-ba dist/diaspora-bundle.spec + +Routines uses last available version from master branch at github. diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 6adab3db1..8ef7ba5eb 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -1,13 +1,3 @@ -# -# Build diaspora RPM package. -# -# Packages current HEAD if the diaspora master branch -# to a reasonable Fedora RPM. -# -# If the environment variable GIT_VERSION is set, builds an rpm -# from this version (i. e., uses this commit). -# - %global debug_package %{nil} %define git_release HEAD @@ -41,7 +31,7 @@ open source social network server. getent group diaspora >/dev/null || groupadd -r diaspora getent passwd diaspora >/dev/null || \ useradd -r -g diaspora \ - -md /var/lib/diaspora -s /sbin/nologin \ + -md /usr/share/diaspora -s /sbin/nologin \ -c "Diaspora daemon" diaspora exit 0 From d172a8ff7f7142520b581b843c4ce93a49461792 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 05:01:32 +0200 Subject: [PATCH 09/19] provisionary --- pkg/fedora/diaspora.spec | 15 ++--- pkg/fedora/perm-fix.patch | 120 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 pkg/fedora/perm-fix.patch diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 8ef7ba5eb..34c221a0f 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -16,6 +16,9 @@ BuildArch: noarch # See http://github.com/diaspora/diaspora/issues/issue/393 Patch0: source-fix.patch +# See: http://github.com/diaspora/diaspora/issues/issue/392 +Patch1: perm-fix.patch + BuildRequires: git Requires(pre): shadow-utils @@ -39,20 +42,12 @@ exit 0 %setup -q -n %{name}-%{version}-%{git_release} pushd master %patch0 -p1 +git apply %{_sourcedir}/perm-fix.patch popd - - mkdir master/tmp || : -#find . -name .git | xargs rm -rf || : -find . -type f -exec \ +find . -perm /u+x -type f -exec \ sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null -# Patch request: http://github.com/diaspora/diaspora/issues/issue/392 -find . -name \*.css -print0 | xargs --null chmod 644 -find . -name \*.js -print0 | xargs --null chmod 644 -chmod 644 master/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg -chmod 644 master/public/stylesheets/brandongrotesque_light/demo.html - %build rm -rf master/vendor/bundle pushd master diff --git a/pkg/fedora/perm-fix.patch b/pkg/fedora/perm-fix.patch new file mode 100644 index 000000000..b6fabed52 --- /dev/null +++ b/pkg/fedora/perm-fix.patch @@ -0,0 +1,120 @@ +diff --git a/public/javascripts/fancybox/blank.gif b/public/javascripts/fancybox/blank.gif +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_close.png b/public/javascripts/fancybox/fancy_close.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_loading.png b/public/javascripts/fancybox/fancy_loading.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_nav_left.png b/public/javascripts/fancybox/fancy_nav_left.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_nav_right.png b/public/javascripts/fancybox/fancy_nav_right.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_e.png b/public/javascripts/fancybox/fancy_shadow_e.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_n.png b/public/javascripts/fancybox/fancy_shadow_n.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_ne.png b/public/javascripts/fancybox/fancy_shadow_ne.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_nw.png b/public/javascripts/fancybox/fancy_shadow_nw.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_s.png b/public/javascripts/fancybox/fancy_shadow_s.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_se.png b/public/javascripts/fancybox/fancy_shadow_se.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_sw.png b/public/javascripts/fancybox/fancy_shadow_sw.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_shadow_w.png b/public/javascripts/fancybox/fancy_shadow_w.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_title_left.png b/public/javascripts/fancybox/fancy_title_left.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_title_main.png b/public/javascripts/fancybox/fancy_title_main.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_title_over.png b/public/javascripts/fancybox/fancy_title_over.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancy_title_right.png b/public/javascripts/fancybox/fancy_title_right.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancybox-x.png b/public/javascripts/fancybox/fancybox-x.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancybox-y.png b/public/javascripts/fancybox/fancybox-y.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/fancybox.png b/public/javascripts/fancybox/fancybox.png +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/jquery.easing-1.3.pack.js b/public/javascripts/fancybox/jquery.easing-1.3.pack.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.css b/public/javascripts/fancybox/jquery.fancybox-1.3.1.css +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js b/public/javascripts/fancybox/jquery.mousewheel-3.0.2.pack.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/fileuploader.js b/public/javascripts/fileuploader.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/jquery.cycle/jquery.cycle.lite.min.js b/public/javascripts/jquery.cycle/jquery.cycle.lite.min.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/jquery.infieldlabel.js b/public/javascripts/jquery.infieldlabel.js +old mode 100755 +new mode 100644 +diff --git a/public/javascripts/web_socket.js b/public/javascripts/web_socket.js +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/blueprint/src/grid.css b/public/stylesheets/blueprint/src/grid.css +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/blueprint/src/print.css b/public/stylesheets/blueprint/src/print.css +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/blueprint/src/reset.css b/public/stylesheets/blueprint/src/reset.css +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.eot b/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.eot +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg b/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.svg +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.ttf b/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.ttf +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.woff b/public/stylesheets/brandongrotesque_light/Brandon_light-webfont.woff +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/demo.html b/public/stylesheets/brandongrotesque_light/demo.html +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/brandongrotesque_light/stylesheet.css b/public/stylesheets/brandongrotesque_light/stylesheet.css +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/fileuploader.css b/public/stylesheets/fileuploader.css +old mode 100755 +new mode 100644 +diff --git a/public/stylesheets/loading.gif b/public/stylesheets/loading.gif +old mode 100755 +new mode 100644 From 03dbe0bb13828a7b7b0bd273ded1b3b93fd5f834 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 18:53:41 +0200 Subject: [PATCH 10/19] New workflow w 'rake db:seed:dev'. Permissions on logfiles, logrotate conf. README update --- pkg/fedora/README.fedora | 59 ++++++++++++++++++++++++++++++------- pkg/fedora/diaspora-setup | 31 +++++++++++++++++++ pkg/fedora/diaspora.logconf | 3 +- pkg/fedora/diaspora.spec | 41 +++++++++++++------------- 4 files changed, 102 insertions(+), 32 deletions(-) create mode 100755 pkg/fedora/diaspora-setup diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora index fc3c8b61e..fdcd00448 100644 --- a/pkg/fedora/README.fedora +++ b/pkg/fedora/README.fedora @@ -1,18 +1,55 @@ -Here is tools to package diaspora as a RPM package. +## Diaspora RPM tools -Synopsis: +Creates Fedora 13 RPM packages from diaspora git repository. -# Create dist/diaspora-0.0-1010041233_faded4231.tar.gz -% ./make_dist.sh source +#### Synopsis: -# Create dist/diaspora-bundle-0.0-1010041233_faded4231.tar.gz -% ./make_dist.sh bundle + # Create dist/diaspora-0.0-1010041233_fade4231.tar.gz + % ./make_dist.sh source -# Setup links to tarballs from RPM source directory: -% ./make_dist.sh links + # Create dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz + % ./make_dist.sh bundle -# Build rpms: -rpmbuild -ba dist/diaspora.spec -rpmbuild-ba dist/diaspora-bundle.spec + # Setup links to tarballs from RPM source directory: + % ./make_dist.sh links + + # Build rpms: + rpmbuild -ba dist/diaspora.spec + rpmbuild -ba dist/diaspora-bundle.spec + + #Install + rpm -U ~/rmpbuild/rpms/i686/diaspora-bundle-0.0-1.1010042345_4343fade43.fc13.i686 + rpm -U ~/rmpbuild/rpms/noarch/diaspora-0.0-1.1010042345_4343fade43.fc13.noarch + + #Initiate (as root) + /usr/sbin/diaspora-setup + # Fix hostname afterwards by editing pod_url in + # /usr/share/diaspora/master/config/app_config.yml + + + # Start development server: + sudo + su - diaspora + cd master + ./script/server + + # Start using apache passenger: + # See: http://github.com/diaspora/diaspora/wiki/Using-apache + +#### Notes Routines uses last available version from master branch at github. + +You need to copy all patches and secondary sources in this dir to +the rpm source directory a. k. a. $(rpm --eval %_sourcedir). + +The spec-files in dist/ are patched by ./make_dist.sh source to reference +correct versions of diaspora and diaspora-bundle. The diaspora-bundle +is only updated if Gemfile is updated, upgrading diaspora doesn't +always require a new diaspora-bundle. + +rpmlint shows many errors, most of which related to that the server +won't start if the .git directories are not included. Needs investigation. + +This has been confirmed to start up and provide basic functionality both using +the thin webserver and apache passenger. diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup new file mode 100755 index 000000000..84ac0763c --- /dev/null +++ b/pkg/fedora/diaspora-setup @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Do what's needed to initiate diaspora. +# +# See http://github.com/diaspora/diaspora/issues/issue/395 + +test $UID = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +cd /usr/share/diaspora/master + +if rake --trace db:seed:dev; then + cat <<- EOF + Database config OK, new user tom/evanhort in place. + You might want to edit /usr/share/diaspora/master/config/app_config.yml + and change the pod_url to this host's hostname. + EOF +else + cat <<- EOF + Database config failed. You might want to remove all db files with + rm -rf /var/lib/mongodb/* and giv it a new try. + EOF +fi + + + + + + diff --git a/pkg/fedora/diaspora.logconf b/pkg/fedora/diaspora.logconf index e51c705ed..48eca3916 100644 --- a/pkg/fedora/diaspora.logconf +++ b/pkg/fedora/diaspora.logconf @@ -1,4 +1,5 @@ /var/log/diaspora/*.log { + create 755 diaspora apache weekly rotate 10 copytruncate @@ -7,6 +8,6 @@ notifempty missingok postrotate - (/sbin/service diaspora-ws status | grep running /sbin/servive diaspora-ws restart || :) >/dev/null 2>&1 + ( /sbin/service diaspora-ws condrestart ) >/dev/null 2>&1 endscript } diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 34c221a0f..fb06da654 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -11,13 +11,11 @@ URL: http://www.joindiaspora.com/ Vendor: joindiaspora.com Source: %{name}-%{version}-%{git_release}.tar.gz Source1: diaspora-ws -BuildArch: noarch +Source2: diaspora-setup +BuildArch: noarch # See http://github.com/diaspora/diaspora/issues/issue/393 -Patch0: source-fix.patch - -# See: http://github.com/diaspora/diaspora/issues/issue/392 -Patch1: perm-fix.patch +Patch0: source-fix.patch BuildRequires: git @@ -30,32 +28,33 @@ Requires: diaspora-bundle = %{version} A privacy aware, personally controlled, do-it-all and open source social network server. -%pre -getent group diaspora >/dev/null || groupadd -r diaspora -getent passwd diaspora >/dev/null || \ - useradd -r -g diaspora \ - -md /usr/share/diaspora -s /sbin/nologin \ - -c "Diaspora daemon" diaspora -exit 0 - %prep %setup -q -n %{name}-%{version}-%{git_release} pushd master %patch0 -p1 + +# See: http://github.com/diaspora/diaspora/issues/issue/392 git apply %{_sourcedir}/perm-fix.patch popd -mkdir master/tmp || : find . -perm /u+x -type f -exec \ sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null %build rm -rf master/vendor/bundle +mkdir master/tmp || : pushd master tar cf public/source.tar --exclude='source.tar' -X .gitignore * popd -%install +%pre +getent group apache >/dev/null || groupadd -r apache +getent passwd diaspora >/dev/null || \ + useradd -r -g apache \ + -md /usr/share/diaspora -s /sbin/nologin \ + -c "Diaspora daemon" diaspora +exit 0 +%install [ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp master/README.md . @@ -72,10 +71,12 @@ cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora cp master/.gitignore $RPM_BUILD_ROOT/%{_datadir}/diaspora/master %post -/bin/chown diaspora:diaspora %{_localstatedir}/log/diaspora -ln -sf %{_localstatedir}/log/diaspora \ +rm -f %{_datadir}/diaspora/master/vendor/bundle +rm -f %{_datadir}/diaspora/master/log + +ln -s %{_localstatedir}/log/diaspora \ %{_datadir}/diaspora/master/log || : -ln -sf %{_libdir}/diaspora-bundle/master/vendor/bundle \ +ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \ %{_datadir}/diaspora/master/vendor || : /sbin/chkconfig --add diaspora-ws @@ -91,8 +92,8 @@ fi %files %defattr(-, root, root, 0755) %doc README.md GNU-AGPL-3.0 -%{_datadir}/diaspora -%{_localstatedir}/log/diaspora +%attr(0555, diaspora, apache) %{_datadir}/diaspora +%attr(0755, diaspora, apache) %{_localstatedir}/log/diaspora %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-ws From 28d6d418d78b116a0d2299e06d52370580fabff4 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 18:56:46 +0200 Subject: [PATCH 11/19] renaimng README, to see it properly on github --- pkg/fedora/README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pkg/fedora/README.md diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md new file mode 100644 index 000000000..fdcd00448 --- /dev/null +++ b/pkg/fedora/README.md @@ -0,0 +1,55 @@ +## Diaspora RPM tools + +Creates Fedora 13 RPM packages from diaspora git repository. + +#### Synopsis: + + # Create dist/diaspora-0.0-1010041233_fade4231.tar.gz + % ./make_dist.sh source + + # Create dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz + % ./make_dist.sh bundle + + # Setup links to tarballs from RPM source directory: + % ./make_dist.sh links + + # Build rpms: + rpmbuild -ba dist/diaspora.spec + rpmbuild -ba dist/diaspora-bundle.spec + + #Install + rpm -U ~/rmpbuild/rpms/i686/diaspora-bundle-0.0-1.1010042345_4343fade43.fc13.i686 + rpm -U ~/rmpbuild/rpms/noarch/diaspora-0.0-1.1010042345_4343fade43.fc13.noarch + + #Initiate (as root) + /usr/sbin/diaspora-setup + # Fix hostname afterwards by editing pod_url in + # /usr/share/diaspora/master/config/app_config.yml + + + # Start development server: + sudo + su - diaspora + cd master + ./script/server + + # Start using apache passenger: + # See: http://github.com/diaspora/diaspora/wiki/Using-apache + +#### Notes + +Routines uses last available version from master branch at github. + +You need to copy all patches and secondary sources in this dir to +the rpm source directory a. k. a. $(rpm --eval %_sourcedir). + +The spec-files in dist/ are patched by ./make_dist.sh source to reference +correct versions of diaspora and diaspora-bundle. The diaspora-bundle +is only updated if Gemfile is updated, upgrading diaspora doesn't +always require a new diaspora-bundle. + +rpmlint shows many errors, most of which related to that the server +won't start if the .git directories are not included. Needs investigation. + +This has been confirmed to start up and provide basic functionality both using +the thin webserver and apache passenger. From 1ec99d2839fc9a24c526419f7166e674a12795a3 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 19:04:25 +0200 Subject: [PATCH 12/19] EADME layout --- pkg/fedora/README.fedora | 55 ---------------------------------------- pkg/fedora/README.md | 23 ++++++++--------- 2 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 pkg/fedora/README.fedora diff --git a/pkg/fedora/README.fedora b/pkg/fedora/README.fedora deleted file mode 100644 index fdcd00448..000000000 --- a/pkg/fedora/README.fedora +++ /dev/null @@ -1,55 +0,0 @@ -## Diaspora RPM tools - -Creates Fedora 13 RPM packages from diaspora git repository. - -#### Synopsis: - - # Create dist/diaspora-0.0-1010041233_fade4231.tar.gz - % ./make_dist.sh source - - # Create dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz - % ./make_dist.sh bundle - - # Setup links to tarballs from RPM source directory: - % ./make_dist.sh links - - # Build rpms: - rpmbuild -ba dist/diaspora.spec - rpmbuild -ba dist/diaspora-bundle.spec - - #Install - rpm -U ~/rmpbuild/rpms/i686/diaspora-bundle-0.0-1.1010042345_4343fade43.fc13.i686 - rpm -U ~/rmpbuild/rpms/noarch/diaspora-0.0-1.1010042345_4343fade43.fc13.noarch - - #Initiate (as root) - /usr/sbin/diaspora-setup - # Fix hostname afterwards by editing pod_url in - # /usr/share/diaspora/master/config/app_config.yml - - - # Start development server: - sudo - su - diaspora - cd master - ./script/server - - # Start using apache passenger: - # See: http://github.com/diaspora/diaspora/wiki/Using-apache - -#### Notes - -Routines uses last available version from master branch at github. - -You need to copy all patches and secondary sources in this dir to -the rpm source directory a. k. a. $(rpm --eval %_sourcedir). - -The spec-files in dist/ are patched by ./make_dist.sh source to reference -correct versions of diaspora and diaspora-bundle. The diaspora-bundle -is only updated if Gemfile is updated, upgrading diaspora doesn't -always require a new diaspora-bundle. - -rpmlint shows many errors, most of which related to that the server -won't start if the .git directories are not included. Needs investigation. - -This has been confirmed to start up and provide basic functionality both using -the thin webserver and apache passenger. diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index fdcd00448..f2d77ed1d 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -4,44 +4,43 @@ Creates Fedora 13 RPM packages from diaspora git repository. #### Synopsis: - # Create dist/diaspora-0.0-1010041233_fade4231.tar.gz +Create source tarballs like dist/diaspor0a-0.0-1010041233_fade4231.tar.gz +and dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz % ./make_dist.sh source - - # Create dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz % ./make_dist.sh bundle - # Setup links to tarballs from RPM source directory: +Setup links to tarballs from RPM source directory: % ./make_dist.sh links - # Build rpms: +Build rpms: rpmbuild -ba dist/diaspora.spec rpmbuild -ba dist/diaspora-bundle.spec - #Install +Install rpm -U ~/rmpbuild/rpms/i686/diaspora-bundle-0.0-1.1010042345_4343fade43.fc13.i686 rpm -U ~/rmpbuild/rpms/noarch/diaspora-0.0-1.1010042345_4343fade43.fc13.noarch - #Initiate (as root) +Initiate (as root) /usr/sbin/diaspora-setup # Fix hostname afterwards by editing pod_url in # /usr/share/diaspora/master/config/app_config.yml - - # Start development server: +Start development server: sudo su - diaspora cd master ./script/server - # Start using apache passenger: - # See: http://github.com/diaspora/diaspora/wiki/Using-apache +Start using apache passenger: +See: [[http://github.com/diaspora/diaspora/wiki/Using-apache]] #### Notes Routines uses last available version from master branch at github. You need to copy all patches and secondary sources in this dir to -the rpm source directory a. k. a. $(rpm --eval %_sourcedir). +the rpm source directory a. k. a. $(rpm --eval %_sourcedir). This +includes some hidden .* files. The spec-files in dist/ are patched by ./make_dist.sh source to reference correct versions of diaspora and diaspora-bundle. The diaspora-bundle From 7a50d537da70e7b8e35bc5ce8eefe266932b2014 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 19:09:51 +0200 Subject: [PATCH 13/19] README wrapup --- pkg/fedora/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index f2d77ed1d..35535bd79 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -4,7 +4,7 @@ Creates Fedora 13 RPM packages from diaspora git repository. #### Synopsis: -Create source tarballs like dist/diaspor0a-0.0-1010041233_fade4231.tar.gz +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 @@ -36,7 +36,9 @@ See: [[http://github.com/diaspora/diaspora/wiki/Using-apache]] #### Notes -Routines uses last available version from master branch at github. +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 @@ -45,7 +47,8 @@ includes some hidden .* files. The spec-files in dist/ are patched by ./make_dist.sh source to reference correct versions of diaspora and diaspora-bundle. The diaspora-bundle is only updated if Gemfile is updated, upgrading diaspora doesn't -always require a new diaspora-bundle. +always require a new diaspora-bundle. Editing spec files should be done +in this directory, changes in dist/ are lost when doing ./make_dist source. rpmlint shows many errors, most of which related to that the server won't start if the .git directories are not included. Needs investigation. From e235c6b53731a954455e761c070912c7aa022023 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 19:12:56 +0200 Subject: [PATCH 14/19] linking --- pkg/fedora/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 35535bd79..bd9a99ad4 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -32,7 +32,7 @@ Start development server: ./script/server Start using apache passenger: -See: [[http://github.com/diaspora/diaspora/wiki/Using-apache]] +See: http://github.com/diaspora/diaspora/wiki/Using-apache #### Notes From 9c14be8b11c1f5954596ec41322c4ad37ed69f00 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 19:17:35 +0200 Subject: [PATCH 15/19] prerequisites --- pkg/fedora/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index bd9a99ad4..4a85a9164 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -4,6 +4,9 @@ Creates Fedora 13 RPM packages from diaspora git repository. #### Synopsis: +Prerequisites: rub-1.8, rubygem and other packages as described in +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 From 8ab97fe3f1015bf033cdf1e01884f5775d2ed4a0 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 6 Oct 2010 21:53:24 +0200 Subject: [PATCH 16/19] apache setup update, new diaspora-init --- pkg/fedora/README.md | 41 ++++++++++++++++++++++++++++++--------- pkg/fedora/diaspora-setup | 34 ++++++++++++++++++++++++-------- pkg/fedora/diaspora.spec | 1 + pkg/fedora/make_dist.sh | 3 +-- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 4a85a9164..09946e10e 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -1,10 +1,13 @@ ## Diaspora RPM tools -Creates Fedora 13 RPM packages from diaspora git repository. +Creates RPM packages from diaspora git repository. + +An alternative to the capistrano system, providing classic, binary RPM +packages for deployment on Fedora 13. #### Synopsis: -Prerequisites: rub-1.8, rubygem and other packages as described in +*Prerequisites*: ruby-1.8, rubygem and other packages as described in http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora Create source tarballs like dist/diaspora-0.0-1010041233_fade4231.tar.gz @@ -23,10 +26,8 @@ Install rpm -U ~/rmpbuild/rpms/i686/diaspora-bundle-0.0-1.1010042345_4343fade43.fc13.i686 rpm -U ~/rmpbuild/rpms/noarch/diaspora-0.0-1.1010042345_4343fade43.fc13.noarch -Initiate (as root) - /usr/sbin/diaspora-setup - # Fix hostname afterwards by editing pod_url in - # /usr/share/diaspora/master/config/app_config.yml +Initiate (as root). + /usr/share/diaspora/diaspora-setup Start development server: sudo @@ -34,9 +35,12 @@ Start development server: cd master ./script/server -Start using apache passenger: -See: http://github.com/diaspora/diaspora/wiki/Using-apache - +See http://github.com/diaspora/diaspora/wiki/Using-apache for +apache/passenger setup. After configuration, start with: + /sbin/service diaspora-ws start + /sbin/service httpd restart + + #### Notes Routines uses last available version from master branch at github. The @@ -58,3 +62,22 @@ won't start if the .git directories are not included. Needs investigation. This has been confirmed to start up and provide basic functionality both using the thin webserver and apache passenger. + +#### Implementation + + +'make_dist.sh source' script checks out latest version of diaspora into the + dist/diaspora directory. This content is, after some patches, the diaspora package. + +'make-dir.sh bundle' makes a 'bundle install --deployment' in the diaspora dir. +The resulting bundle is stored in vendor/bundle. This is, after some more +patches, the content of diaspora-bundle. + +Here is also support for running the diaspora websocket service as a system +service through /sbin/service and some install scripts. + +Diaspora files are stored in /usr/share/diaspora, and owned by diaspora. The +bundle, containing some C extensions, is architecture-dependent and lives +in /usr/lib[64]/diaspora. Log files are in /var/log/diaspora. Symlinks in +/usr/share diaspora makes log and bundle available as expected by diaspora app. +This is more or less as mandated by LSB and Fedora packaging rules. diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index 84ac0763c..e97bc0d11 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -3,6 +3,9 @@ # Do what's needed to initiate diaspora. # # See http://github.com/diaspora/diaspora/issues/issue/395 +# +# Note: This is really sort of prototyping. This should be done in ruby, +# on a web page. test $UID = "0" || { echo "You need to be root to do this, giving up" @@ -11,19 +14,34 @@ test $UID = "0" || { cd /usr/share/diaspora/master -if rake --trace db:seed:dev; then - cat <<- EOF - Database config OK, new user tom/evanhort in place. - You might want to edit /usr/share/diaspora/master/config/app_config.yml - and change the pod_url to this host's hostname. - EOF +if rake db:seed:dev; then + echo "Database config OK, new user tom/evankort in place" else - cat <<- EOF + cat <<- EOF + Database config failed. You might want to remove all db files with - rm -rf /var/lib/mongodb/* and giv it a new try. + rm -rf /var/lib/mongodb/* and/or resetting the config file by + cp config/app_config.yml.example config/app_config.yml before + making a new try. EOF + exit 1 fi +hostname=$( awk '/pod_url:/ { print $2; exit }' Date: Wed, 6 Oct 2010 23:15:52 +0200 Subject: [PATCH 17/19] Addding uploads directory --- pkg/fedora/README.md | 5 +++++ pkg/fedora/diaspora-setup | 3 +++ pkg/fedora/diaspora.spec | 11 ++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 09946e10e..22bb4b032 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -81,3 +81,8 @@ bundle, containing some C extensions, is architecture-dependent and lives in /usr/lib[64]/diaspora. Log files are in /var/log/diaspora. Symlinks in /usr/share diaspora makes log and bundle available as expected by diaspora app. This is more or less as mandated by LSB and Fedora packaging rules. + + find /usr/share/diaspora/ -type l -exec ls -l {} \; | awk '{print $9, $10, $11}' + /usr/share/diaspora/master/public/uploads -> /var/lib/diaspora/uploads + /usr/share/diaspora/master/log -> /var/log/diaspora + /usr/share/diaspora/master/vendor/bundle -> /usr/lib/diaspora-bundle/master/vendor/bundle diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index e97bc0d11..d4c275915 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -27,6 +27,9 @@ else exit 1 fi +# %attr(0777, diaspora, apache) doesn't work in specfile due to umask 022. +chmod 777 /var/lib/diaspora/uploads + hostname=$( awk '/pod_url:/ { print $2; exit }' /dev/null || groupadd -r apache +getent group diaspora >/dev/null || groupadd -r diaspora getent passwd diaspora >/dev/null || \ useradd -r -g apache \ -md /usr/share/diaspora -s /sbin/nologin \ @@ -70,15 +70,19 @@ mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora cp master/.gitignore $RPM_BUILD_ROOT/%{_datadir}/diaspora/master cp diaspora-setup $RPM_BUILD_ROOT/%{_datadir}/diaspora +mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads %post rm -f %{_datadir}/diaspora/master/vendor/bundle rm -f %{_datadir}/diaspora/master/log +rm -f %{_datadir}/diaspora/master/public/uploads ln -s %{_localstatedir}/log/diaspora \ %{_datadir}/diaspora/master/log || : ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \ %{_datadir}/diaspora/master/vendor || : +ln -s %{_localstatedir}/lib/diaspora/uploads \ + %{_datadir}/diaspora/master/public/uploads || : /sbin/chkconfig --add diaspora-ws %preun @@ -93,8 +97,9 @@ fi %files %defattr(-, root, root, 0755) %doc README.md GNU-AGPL-3.0 -%attr(0555, diaspora, apache) %{_datadir}/diaspora -%attr(0755, diaspora, apache) %{_localstatedir}/log/diaspora +%attr(0555, diaspora, diaspora) %{_datadir}/diaspora +%attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora +%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-ws From 5bd5aea48443d4e5fc3d3d4cc3f332ad946efe8d Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Thu, 7 Oct 2010 01:42:33 +0200 Subject: [PATCH 18/19] make-dist handles commit arg OK, make-dist list links all sources. Smaller clean-ups. --- pkg/fedora/Gemfile.lock.patch | 13 ++ pkg/fedora/SOURCES | 7 + pkg/fedora/diaspora-setup | 2 +- pkg/fedora/make-dist.sh | 264 ++++++++++++++++++++++++++++++++++ 4 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 pkg/fedora/Gemfile.lock.patch create mode 100644 pkg/fedora/SOURCES create mode 100755 pkg/fedora/make-dist.sh diff --git a/pkg/fedora/Gemfile.lock.patch b/pkg/fedora/Gemfile.lock.patch new file mode 100644 index 000000000..7b96c043e --- /dev/null +++ b/pkg/fedora/Gemfile.lock.patch @@ -0,0 +1,13 @@ +diff --git a/Gemfile.lock b/Gemfile.lock +index 8534f58..44d386e 100644 +--- a/Gemfile.lock ++++ b/Gemfile.lock +@@ -258,7 +258,7 @@ DEPENDENCIES + autotest + bson (= 1.0.7) + bson_ext (= 1.0.7) +- bundler (= 1.0.0) ++ bundler (>= 1.0.0) + capybara (~> 0.3.9) + carrierwave! + cucumber-rails (= 0.3.2) diff --git a/pkg/fedora/SOURCES b/pkg/fedora/SOURCES new file mode 100644 index 000000000..4b487fdf5 --- /dev/null +++ b/pkg/fedora/SOURCES @@ -0,0 +1,7 @@ +# These files will be linked to %_sourcedir by 'make-dist links' +.bundle +diaspora-setup +diaspora-ws +Gemfile.patch +perm-fix.patch +source-fix.patch diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index d4c275915..e103e789d 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -27,7 +27,7 @@ else exit 1 fi -# %attr(0777, diaspora, apache) doesn't work in specfile due to umask 022. +# %attr(0777, diaspora, diaspora) doesn't work in specfile due to umask 022. chmod 777 /var/lib/diaspora/uploads hostname=$( awk '/pod_url:/ { print $2; exit }' ] +# +# -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 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 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'|' \ + 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. +# Usage: checkout [commit id, defaults to HEAD] +# Returns: commit for current branch's HEAD. +{ + mkdir dist >/dev/null 2>&1 || : + ( + cd dist + test -d diaspora || { + git clone --quiet $GIT_REPO; + ( + cd diaspora; + git remote add upstream \ + git://github.com/diaspora/diaspora.git + ) + } + cd diaspora; + git fetch --quiet upstream + git merge --quiet upstream/master + git checkout --quiet -b dist ${1:-'HEAD'} + git_id -n + ) +} + + +function make_dist +# Create a distribution tarball +{ + commit=$(checkout ${1:-'HEAD'}) + 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} +} + +function make_bundle() +{ + checkout 'HEAD' + 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] + + -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 + + + From 876a32d64bcf52b162ebbc2f30c6ad9bf26cbceb Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Thu, 7 Oct 2010 01:48:44 +0200 Subject: [PATCH 19/19] make-dist handles commit arg, links handles all sources --- pkg/fedora/README.md | 11 +- pkg/fedora/diaspora-setup | 3 +- pkg/fedora/make-dist.sh | 51 ++++--- pkg/fedora/make_dist.sh | 273 -------------------------------------- 4 files changed, 37 insertions(+), 301 deletions(-) delete mode 100755 pkg/fedora/make_dist.sh diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 22bb4b032..d5bd23fe9 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -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 diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index e103e789d..0df7ceb2f 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -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 diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 957db6fa7..6d0795618 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -1,12 +1,7 @@ #!/bin/bash -#Usage: make_dist [-b] [-d] [s] [-c ] +#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 diff --git a/pkg/fedora/make_dist.sh b/pkg/fedora/make_dist.sh deleted file mode 100755 index 4a3586da3..000000000 --- a/pkg/fedora/make_dist.sh +++ /dev/null @@ -1,273 +0,0 @@ -#!/bin/bash - -#Usage: make_dist [-b] [-d] [s] [-c ] -# -# -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 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 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'|' \ - 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] - - -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 - - -