From 9b83b07f8029ca3aba2f8e2050cbcac846d028ca Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 04:04:34 +0200 Subject: [PATCH 01/56] Install from local git gems without download from remote repo. --- pkg/fedora/make-dist.sh | 49 ++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 3da2ab6e3..5857114c7 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -175,41 +175,23 @@ function make_src echo "Required bundle: $(git_id dist/diaspora/Gemfile)" } -function get_git_repos() +function read_git_urls() +# Simple now, possibly needs to handle also http: git repos. { - grep -A 2 GIT $1 | - awk ' /remote:/ { repo = $2 } - /revision:/ { printf "%s=%s\n",repo, $2}' + grep -o 'git://[^ ]*' $1 | tr -d '\047",' } - -function package_git_gems() +function fix_gemfile() { - gemfile="$1" - dest="$2" - - rm -rf git-tmp - mkdir git-tmp - cd git-tmp - for repo in $( get_git_repos $1); do - url=${repo%%=*} - rev=${repo##*=} - - name=${url##*/} - name="${name%.git}" - - rm -rf "$name" - git clone "$url" "$name" - cd $name - git reset --hard $rev - sed -i '/s.date/s/Date.today/"2010-09-25"/' *.gemspec - gem build *.gemspec - cp *.gem $dest - echo "Built GIT gem $name (*.gem)" - echo "Where: $dest" - cd .. - done - cd .. + gemfile=$1 + for url in $(read_git_urls $gemfile); do + name=${url##*/} + name=${name%.*} + rm -rf vendor/git/$name + git clone --bare --quiet $url vendor/git/$name && + sed -i "s#$url#vendor/git/$name#" $gemfile || + echo "Cannot fix git repo \"$url\"" + done } @@ -231,9 +213,10 @@ function make_bundle() rm -rf .bundle bundle update fi - bundle install --deployment + [ -d 'vendor/git' ] || mkdir vendor/git + fix_gemfile ./Gemfile + bundle install --path vendor/gems bundle package - package_git_gems "$PWD/Gemfile.lock" "$PWD/vendor/cache" cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ vendor/cache cd vendor From a279bae720218cd340df123cb214b70da5b123b6 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 10:31:13 +0200 Subject: [PATCH 02/56] Separate doc dir collecting copyrights and readmes. --- pkg/fedora/.gitignore | 1 + pkg/fedora/diaspora-bundle.spec | 4 +-- pkg/fedora/diaspora.spec | 3 +-- pkg/fedora/make-dist.sh | 42 ++++++++++++++++++++++-------- pkg/ubuntu/diaspora-bundle-install | 6 ++--- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/pkg/fedora/.gitignore b/pkg/fedora/.gitignore index bedbdc760..2a21dd54d 100644 --- a/pkg/fedora/.gitignore +++ b/pkg/fedora/.gitignore @@ -1,3 +1,4 @@ TODO dist .stgit* +vendor diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index dee189a26..b3496262b 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -38,8 +38,6 @@ Source file usede to compile native libraries in diaspora-bundle. %setup -q -n %{name}-%{version}-%{git_release} %build -mkdir -p vendor/cache -mv *.gem vendor/cache bundle install --local --deployment --without ri rdoc pushd vendor/bundle/ruby/1.8/gems @@ -218,7 +216,7 @@ cat files >> dirs && cp dirs files %files -f files %defattr(-, diaspora, diaspora, 0755) -%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 +%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 docs %files -f dev-files devel %defattr(-, root, root, 0644) diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 1d61026e5..8a30492c8 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -49,13 +49,12 @@ find . -perm /u+x -type f -exec \ %build rm -rf master/vendor/bundle -mkdir master/tmp || : %install rm -fr $RPM_BUILD_ROOT sed -i \ - '/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/bundle|' \ + '/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/vendor/bundle|' \ master/.bundle/config cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS . diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 5857114c7..a0f91b515 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -138,7 +138,7 @@ function checkout() cd diaspora; git fetch --quiet upstream git merge --quiet upstream/master - git checkout --quiet ${1:-'HEAD'} + [ -n "$1" ] && git reset --hard --quiet $1 git_id -n ) } @@ -183,9 +183,9 @@ function read_git_urls() function fix_gemfile() { - gemfile=$1 + local gemfile=$1 for url in $(read_git_urls $gemfile); do - name=${url##*/} + local name=${url##*/} name=${name%.*} rm -rf vendor/git/$name git clone --bare --quiet $url vendor/git/$name && @@ -194,6 +194,22 @@ function fix_gemfile() done } +function make_docs() +{ + local gems=$1 + local dest=$2 + + for gem in $(ls $gems); do + local name=$(basename $gem) + [ -r $gem/README* ] && { + local readme=$(basename $gem/README*) + cp -a $gem/$readme $dest/$readme.$name + } + [ -r $gem/COPYRIGHT ] && \ + cp -a $gem/COPYRIGHT $dest/COPYRIGHT.$name + done +} + function make_bundle() # Create the bundle tarball @@ -201,8 +217,8 @@ function make_bundle() # { checkout ${1:-'HEAD'} >/dev/null - bundle_id=$( git_id dist/diaspora/Gemfile) - bundle_name="diaspora-bundle-$VERSION-$bundle_id" + local bundle_id=$( git_id dist/diaspora/Gemfile) + local bundle_name="diaspora-bundle-$VERSION-$bundle_id" test -e "dist/$bundle_name.tar.gz" || { echo "Creating bundle $bundle_name" cd dist @@ -213,17 +229,21 @@ function make_bundle() rm -rf .bundle bundle update fi + [ -d 'vendor/git' ] || mkdir vendor/git fix_gemfile ./Gemfile bundle install --path vendor/gems bundle package + + mkdir -p "../$bundle_name/docs" + mkdir -p "../$bundle_name/vendor" cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ - vendor/cache - cd vendor - mv cache $bundle_name - tar czf ../../$bundle_name.tar.gz $bundle_name - mv $bundle_name cache - cd .. + ../$bundle_name + make_docs "vendor/gems" "../$bundle_name/docs" + mv vendor/cache ../$bundle_name/cache + + tar czf ../$bundle_name.tar.gz $bundle_name + mv ../$bundle_name/cache cache cd .. cd .. } diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install index 88924b930..9a4c9a10a 100755 --- a/pkg/ubuntu/diaspora-bundle-install +++ b/pkg/ubuntu/diaspora-bundle-install @@ -23,11 +23,9 @@ mv $(basename $1 .tar.gz) diaspora-bundle mkdir -p /usr/share/doc/diaspora-bundle || : cd /usr/lib/diaspora-bundle -cp AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ +cp -a AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ /usr/share/doc/diaspora-bundle - -mkdir -p vendor/cache -mv *.gem vendor/cache +cp -ar docs /usr/share/doc/diaspora-bundle bundle install --local --deployment --without ri rdoc From 1c170694911100ded9ea1435409752b1b021e029 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 10:59:57 +0200 Subject: [PATCH 03/56] bugfix --- pkg/fedora/make-dist.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index a0f91b515..250caa0d8 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -241,10 +241,9 @@ function make_bundle() ../$bundle_name make_docs "vendor/gems" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/cache - - tar czf ../$bundle_name.tar.gz $bundle_name - mv ../$bundle_name/cache cache cd .. + tar czf $bundle_name.tar.gz $bundle_name + mv $bundle_name/cache diaspora/vendor/cache cd .. } echo From 66d468c2b2c4c2210112de866689b5e3c290055b Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 11:10:00 +0200 Subject: [PATCH 04/56] bugfix --- pkg/fedora/make-dist.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 250caa0d8..50ddbdc47 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -240,10 +240,10 @@ function make_bundle() cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ ../$bundle_name make_docs "vendor/gems" "../$bundle_name/docs" - mv vendor/cache ../$bundle_name/cache + mv vendor/cache ../$bundle_name/vendor cd .. tar czf $bundle_name.tar.gz $bundle_name - mv $bundle_name/cache diaspora/vendor/cache + mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } echo From 76a8ea0e73346158959f28ce6e4e6df6fb744321 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 23:15:26 +0200 Subject: [PATCH 05/56] new git gem flow using. --- pkg/Licenses | 99 ++++++++++++++++++++++++++++++ pkg/fedora/diaspora-bundle.spec | 13 +++- pkg/fedora/make-dist.sh | 91 +++++++++++++++++++++------ pkg/ubuntu/diaspora-bundle-install | 9 +++ 4 files changed, 192 insertions(+), 20 deletions(-) create mode 100644 pkg/Licenses diff --git a/pkg/Licenses b/pkg/Licenses new file mode 100644 index 000000000..cc8f33741 --- /dev/null +++ b/pkg/Licenses @@ -0,0 +1,99 @@ + +abstract: Ruby +actionmailer: MIT +actionpack: MIT +activemodel: MIT +activerecord: MIT +activeresource: ? (Other distros uses MIT, "Ruby-alike", no pointers) +activesupport: MIT +addressable: MIT +arel: MIT +aws MIT +bcrypt-ruby: MIT +builder: MIT +bunny: MIT +capistrano: MIT +capybara: MIT +chef: ASL 2.0 +childprocess: MIT +columnize: GPLv2 +crack: MIT +cucumber: MIT +cucumber-rails: MIT +culerity: MIT +daemons: Ruby+MIT +database_cleaner: MIT +devise: MIT +devise_invitable MIT +diff Ruby+GPLv2+ Artistic 2.0 +em-websocket: MIT +eribus: MIT +event-machine: Ruby+GPLv2 +extlib: MIT +factory_girls MIT +factory_girls_rails: MIT +ffi MIT +haml MIT +http_connection: MIT +gherkin: MIT +hashie: MIT +highline GPLv2+Ruby +json: Ruby +json-pure: Ruby +launchy: MIT +linecache: GPLv2 +mail: MIT +mime-types: GPLv2+Ruby+Artistic 2.0 +mini_magick: MIT +mini_fb: ? +mixlib-authentication: ASL 2.0 +mixlib-cli ASL 2.0 +mixlib-config ASL 2.0 +mixlib-log ASL 2.0 +mocha Ruby+MIT +moneta: MIT +mongo: ASL 2.0 +net-scp: MIT +net-sftp: MIT +net-ssh: MIT +net-ssh-gatawey: MIT +ohai: ASL 2.0 +plucky: MIT +polyglot. MIT +pubsubhubbub: ASL 2.0 http://code.google.com/p/pubsubhubbub/ +rake: MIT +rack-mount: MIT +rack-test: MIT +railties: MIT +rest-client: MIT +rspec-core: MIT +rspec-expectations: MIT +rspec-mocks: MIT +rspec-rails: MIT +rack: MIT +rack-mount: MIT +ruby-debug: MIT +ruby-debug-base: MIT +rubyzip: Ruby +selenium-webdriver: ASL 2.0 +subexec: MIT +term-ansicolor: GPLv2 +textile. MIT +textile-warden: MIT +thin: MIT +thor: MIT +treetop: MIT +tx-info: MIT +uutdtools: MIT +iwarden: MIT +webmock: MIT +will-paginate MIT + + + + + + + + + diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index b3496262b..a13a85368 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -38,7 +38,16 @@ Source file usede to compile native libraries in diaspora-bundle. %setup -q -n %{name}-%{version}-%{git_release} %build -bundle install --local --deployment --without ri rdoc +bundle install --local --deployment --without ri rdoc test +for gem in vendor/git/*; do + gem install --local \ + --force \ + --no-rdoc \ + --no-ri \ + --install-dir vendor/bundle/ruby/1.8/bundler \ + $gem + +done pushd vendor/bundle/ruby/1.8/gems # In repo (2.2.4) @@ -198,7 +207,7 @@ popd } mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle -cp -ar vendor/bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle +cp -ar vendor $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle find %{buildroot}/%{_libdir}/diaspora-bundle \ -type d -fprintf dirs '%%%dir "%%p"\n' diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 50ddbdc47..273ad6eae 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -183,15 +183,61 @@ function read_git_urls() function fix_gemfile() { - local gemfile=$1 - for url in $(read_git_urls $gemfile); do - local name=${url##*/} - name=${name%.*} - rm -rf vendor/git/$name - git clone --bare --quiet $url vendor/git/$name && - sed -i "s#$url#vendor/git/$name#" $gemfile || - echo "Cannot fix git repo \"$url\"" + + sed -i '/git:/s/,.*//' $1 + sed -i -e 's/GIT/GEM/' \ + -e '/[ ]*revision:/d' \ + -e '/[ ]*remote: git/s|git:.*|http://github.com|' \ + $1.lock + +} + +function build_git_gems() +# Usage: build_git_gems +{ + mkdir gem-tmp || : + cd gem-tmp + rm -rf * + + grep 'git:' ../$1 | sed 's/,/ /' | awk ' + /^.*git:\/\/.*$/ { + gsub( "=>", "") + gsub( ",", "") + if ( $1 != "gem") { + print "Strange git: line (ignored) :" $0 + next + } + name = $2 + suffix = "" + url="" + for (i = 3; i <= NF; i += 1) { + key = $i + i += 1 + if (key == ":git") + url = $i + else if ( key == ":ref") { + suffix = "; cd " name + suffix = suffix "; git reset --hard " $i + suffix = suffix "; cd .." + } + else if ( key == ":branch") + suffix = "; git checkout " $i + } + print "Running: ", cmd + cmd = sprintf( "git clone --quiet %s %s %s\n", + url, name, suffix) + system( cmd) + }' + sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec + for dir in *; do + cd $dir + gem build *.gemspec + cp *.gem ../../$2 + cd .. done + + cd .. + # rm -rf gem-tmp } function make_docs() @@ -201,12 +247,18 @@ function make_docs() for gem in $(ls $gems); do local name=$(basename $gem) - [ -r $gem/README* ] && { - local readme=$(basename $gem/README*) - cp -a $gem/$readme $dest/$readme.$name + [ -r $gems/$gem/README* ] && { + local readme=$(basename $gems/$gem/README*) + cp -a $gems/$gem/$readme $dest/$readme.$name } - [ -r $gem/COPYRIGHT ] && \ - cp -a $gem/COPYRIGHT $dest/COPYRIGHT.$name + [ -r $gems/$gem/COPYRIGHT ] && \ + cp -a $gems/$gem/COPYRIGHT $dest/COPYRIGHT.$name + [ -r $gems/$gem/LICENSE ] && \ + cp -a $gems/$gem/LICENSE $dest/LICENSE.$name + [ -r $gems/$gem/MIT-LICENSE ] && \ + cp -a $gems/$gem/MIT-LICENSE $dest/MIT-LICENSE.$name + [ -r $gems/$gem/COPYING ] && \ + cp -a $gems/$gem/COPYING $dest/COPYING.$name done } @@ -229,11 +281,14 @@ function make_bundle() rm -rf .bundle bundle update fi - +set -x [ -d 'vendor/git' ] || mkdir vendor/git - fix_gemfile ./Gemfile - bundle install --path vendor/gems + bundle install bundle package + mkdir vendor/git + build_git_gems Gemfile vendor/git +# fix_gemfile Gemfile +set +x mkdir -p "../$bundle_name/docs" mkdir -p "../$bundle_name/vendor" @@ -241,14 +296,14 @@ function make_bundle() ../$bundle_name make_docs "vendor/gems" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/vendor + mv vendor/git ../$bundle_name/vendor + rm -rf vendor/gems/* cd .. tar czf $bundle_name.tar.gz $bundle_name - mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } echo echo "Bundle: dist/$bundle_name.tar.gz" - echo "Current dir:$PWD" } diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install index 9a4c9a10a..65ae9520e 100755 --- a/pkg/ubuntu/diaspora-bundle-install +++ b/pkg/ubuntu/diaspora-bundle-install @@ -28,4 +28,13 @@ cp -a AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ cp -ar docs /usr/share/doc/diaspora-bundle bundle install --local --deployment --without ri rdoc +for gem in vendor/git/*; do + gem install --local \ + --force \ + --no-rdoc \ + --no-ri \ + --install-dir vendor/bundle/ruby/1.8/bundler \ + $gem +done + From fcb88bdba77d4c5007dc3adecbbe55995b2aa228 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 25 Oct 2010 04:04:34 +0200 Subject: [PATCH 06/56] Bundle: add licenses, handle git gems Adding a docs dir collexting README and licenses from contained gems. git gems, which bundler does not handle well today, are handled by a hacked parsing of Gemfile.log, gem built into the source bundle and installed on target system --- pkg/fedora/make-dist.sh | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 273ad6eae..093f6a4c3 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -175,25 +175,9 @@ function make_src echo "Required bundle: $(git_id dist/diaspora/Gemfile)" } -function read_git_urls() -# Simple now, possibly needs to handle also http: git repos. -{ - grep -o 'git://[^ ]*' $1 | tr -d '\047",' -} - -function fix_gemfile() -{ - - sed -i '/git:/s/,.*//' $1 - sed -i -e 's/GIT/GEM/' \ - -e '/[ ]*revision:/d' \ - -e '/[ ]*remote: git/s|git:.*|http://github.com|' \ - $1.lock - -} - function build_git_gems() # Usage: build_git_gems +# Horrible hack, in wait for bundler handling git gems OK. { mkdir gem-tmp || : cd gem-tmp @@ -202,7 +186,6 @@ function build_git_gems() grep 'git:' ../$1 | sed 's/,/ /' | awk ' /^.*git:\/\/.*$/ { gsub( "=>", "") - gsub( ",", "") if ( $1 != "gem") { print "Strange git: line (ignored) :" $0 next @@ -223,9 +206,9 @@ function build_git_gems() else if ( key == ":branch") suffix = "; git checkout " $i } - print "Running: ", cmd cmd = sprintf( "git clone --quiet %s %s %s\n", url, name, suffix) + print "Running: ", cmd system( cmd) }' sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec @@ -255,6 +238,8 @@ function make_docs() cp -a $gems/$gem/COPYRIGHT $dest/COPYRIGHT.$name [ -r $gems/$gem/LICENSE ] && \ cp -a $gems/$gem/LICENSE $dest/LICENSE.$name + [ -r $gems/$gem/License ] && \ + cp -a $gems/$gem/License $dest/License.$name [ -r $gems/$gem/MIT-LICENSE ] && \ cp -a $gems/$gem/MIT-LICENSE $dest/MIT-LICENSE.$name [ -r $gems/$gem/COPYING ] && \ @@ -281,25 +266,24 @@ function make_bundle() rm -rf .bundle bundle update fi -set -x - [ -d 'vendor/git' ] || mkdir vendor/git + bundle install bundle package - mkdir vendor/git + [ -d 'vendor/git' ] || mkdir vendor/git build_git_gems Gemfile vendor/git -# fix_gemfile Gemfile -set +x mkdir -p "../$bundle_name/docs" mkdir -p "../$bundle_name/vendor" cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ ../$bundle_name + make_docs "vendor/gems" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/vendor mv vendor/git ../$bundle_name/vendor rm -rf vendor/gems/* cd .. tar czf $bundle_name.tar.gz $bundle_name + mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } echo From 97940073d7e3d0abea98d74f6a9984228d8c92e5 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 26 Oct 2010 22:09:12 +0200 Subject: [PATCH 07/56] Works, w ith bit gem file and git repos... --- pkg/fedora/README.md | 12 ++++-- pkg/fedora/diaspora-bundle.spec | 6 ++- pkg/fedora/make-dist.sh | 67 +++++++++++++++++++------------- pkg/ubuntu/diaspora-install-deps | 3 +- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 7c5c9e3a2..38801dc42 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -18,7 +18,7 @@ Prerequisites: - A personal environment to build RPM:s, also described in [RPM installation Fedora](http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora) -Install g++ (possibly unnnecessary?): +Install g++ (unnecessary?): % yum install gcc-c++ Create source tarballs like dist/diaspora-0.0-1010041233_fade4231.tar.gz @@ -73,7 +73,7 @@ to the bundle's bundle directory. Reasonable defaults are to install diaspora in /usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, the link is % rm -rf /usr/share/diaspora/master/vendor/bundle - % ln -sf /usr/lib/diaspora-bundle/bundle \ + % ln -sf /usr/lib/diaspora-bundle/vendor/bundle \ > /usr/share/diaspora/master/vendor % @@ -93,6 +93,9 @@ The source tarball is as retrieved from diaspora with following differences: - The file .bundle/config is patched. Remove before doing *bundle install* +The bundle is basically the output from 'bundle package'. The git-based +gems are also added into vendor/git. + ./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The root cause is a bad Gemfile in the git repo. Possible fixes includes using a older version known to work: @@ -128,9 +131,10 @@ at [ftp://mumin.dnsalias.net/pub/leamas/diaspora/builds](ftp://mumin.dnsalias.ne '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. +'make-dir.sh bundle' makes a *bundle package* in the diaspora dir. The resulting bundle is stored in vendor/bundle. This is, after some more -patches, the content of diaspora-bundle. +patches, the content of diaspora-bundle tarball. Target systems makes a +*bundle install --local* to use it. Here is also support for running the diaspora websocket service as a system service through /sbin/service and some install scripts. diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index a13a85368..a5f1e7071 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -39,12 +39,12 @@ Source file usede to compile native libraries in diaspora-bundle. %build bundle install --local --deployment --without ri rdoc test -for gem in vendor/git/*; do +for gem in vendor/git/*.gem; do gem install --local \ --force \ --no-rdoc \ --no-ri \ - --install-dir vendor/bundle/ruby/1.8/bundler \ + --install-dir vendor/bundle/ruby/1.8 \ $gem done @@ -190,6 +190,8 @@ exit 0 find . -name .git | xargs rm -rf find . -name .gitignore -delete find . -name \*.o -delete || : +rm -rf vendor/git +rm -rf vendor/cache test -d vendor/bundle/ruby/1.8//gems/selenium-webdriver-0.0.* && { pushd vendor/bundle//ruby/1.8/gems/selenium-webdriver-0.0.*/lib/selenium/webdriver/ diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 093f6a4c3..3e250f31b 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -175,6 +175,12 @@ function make_src echo "Required bundle: $(git_id dist/diaspora/Gemfile)" } +function fix_gemfile +{ + sed -i 's|git://.*/|vendor/git/|g' $1 + +} + function build_git_gems() # Usage: build_git_gems # Horrible hack, in wait for bundler handling git gems OK. @@ -183,42 +189,46 @@ function build_git_gems() cd gem-tmp rm -rf * - grep 'git:' ../$1 | sed 's/,/ /' | awk ' + grep 'git:' ../$1 | sed 's/,/ /g' | awk ' /^.*git:\/\/.*$/ { - gsub( "=>", "") + gsub( "=>", " ") if ( $1 != "gem") { print "Strange git: line (ignored) :" $0 next } name = $2 - suffix = "" url="" + suffix = "; cd " name for (i = 3; i <= NF; i += 1) { key = $i i += 1 if (key == ":git") url = $i - else if ( key == ":ref") { - suffix = "; cd " name + else if ( key == ":ref") suffix = suffix "; git reset --hard " $i - suffix = suffix "; cd .." - } else if ( key == ":branch") - suffix = "; git checkout " $i + suffix = suffix "; git checkout " $i } + suffix = suffix "; cd .." cmd = sprintf( "git clone --quiet %s %s %s\n", url, name, suffix) print "Running: ", cmd system( cmd) + cmd = sprintf( "git clone --bare --quiet %s\n", url) + print "Running: ", cmd + system( cmd) }' sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec for dir in *; do - cd $dir - gem build *.gemspec - cp *.gem ../../$2 - cd .. + if [ -e $dir/*.gemspec ] ; then + cd $dir + gem build *.gemspec + cp *.gem ../../$2 + cd .. + else + cp -ar $dir ../$2 + fi done - cd .. # rm -rf gem-tmp } @@ -230,19 +240,19 @@ function make_docs() for gem in $(ls $gems); do local name=$(basename $gem) - [ -r $gems/$gem/README* ] && { + [ -r "$gems/$gem/README*" ] && { local readme=$(basename $gems/$gem/README*) cp -a $gems/$gem/$readme $dest/$readme.$name } - [ -r $gems/$gem/COPYRIGHT ] && \ + [ -r "$gems/$gem/COPYRIGHT" ] && \ cp -a $gems/$gem/COPYRIGHT $dest/COPYRIGHT.$name - [ -r $gems/$gem/LICENSE ] && \ + [ -r "$gems/$gem/LICENSE" ] && \ cp -a $gems/$gem/LICENSE $dest/LICENSE.$name - [ -r $gems/$gem/License ] && \ + [ -r "$gems/$gem/License" ] && \ cp -a $gems/$gem/License $dest/License.$name - [ -r $gems/$gem/MIT-LICENSE ] && \ + [ -r "$gems/$gem/MIT-LICENSE" ] && \ cp -a $gems/$gem/MIT-LICENSE $dest/MIT-LICENSE.$name - [ -r $gems/$gem/COPYING ] && \ + [ -r "$gems/$gem/COPYING" ] && \ cp -a $gems/$gem/COPYING $dest/COPYING.$name done } @@ -267,17 +277,22 @@ function make_bundle() bundle update fi - bundle install - bundle package [ -d 'vendor/git' ] || mkdir vendor/git build_git_gems Gemfile vendor/git + sed -i 's|git://.*/|vendor/git/|g' Gemfile + rm Gemfile.lock + rm -rf .bundle + # see: http://bugs.joindiaspora.com/issues/440 + bundle install --path=vendor/bundle || + bundle install --path=vendor/bundle + bundle package mkdir -p "../$bundle_name/docs" mkdir -p "../$bundle_name/vendor" cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \ ../$bundle_name - make_docs "vendor/gems" "../$bundle_name/docs" + make_docs "vendor/bundle/ruby/1.8/gems/" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/vendor mv vendor/git ../$bundle_name/vendor rm -rf vendor/gems/* @@ -348,16 +363,16 @@ function usage() -h Print this message. -c commit Use a given commit, defaults to last checked in. - -r release Mark with specified release, defaults to 1. + -r release For prepare, mark with release nr, defaults to 1. -u uri Git repository URI, defaults to $GIT_REPO. - -f For bundle, fix dependencies by running 'bundle update' - before 'bundle install' + -f For bundle, fix dependencies by running 'bundle update' + before 'bundle install' source Build a diaspora application tarball. bundle Build a bundler(1) bundle for diaspora. prepare Symlink bundle and source tarballs to rpm source dir, - create patched rpm spec files. + create patched rpm spec files. All results are stored in dist/ diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps index 388dc39e0..cf30822ea 100755 --- a/pkg/ubuntu/diaspora-install-deps +++ b/pkg/ubuntu/diaspora-install-deps @@ -14,7 +14,8 @@ grep -v '^#' /etc/apt/sources.list | grep -q universe || { release=$( lsb_release -a | awk '/Release:/ {print $2}') sudo apt-get update -sudo apt-get install -qy build-essential libxslt1-dev libxml2 \ +sudo apt-get install --no-install-recommends -qy\ + build-essential libxslt1-dev libxml2 \ ruby-full mongodb rake python-software-properties git-core \ imagemagick libmagick9-dev if [ "$release" = "10.04" ]; then From 88a12ca8893bffc47832053e72e3a9d141882801 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 27 Oct 2010 11:47:11 +0200 Subject: [PATCH 08/56] Big cleanup, linking to bundle, removing garbage, git mgmt --- pkg/fedora/diaspora-bundle.spec | 19 ++++------------- pkg/fedora/diaspora-setup | 5 +++++ pkg/fedora/diaspora.spec | 1 + pkg/fedora/make-dist.sh | 33 +++++++----------------------- pkg/ubuntu/diaspora-bundle-install | 8 -------- pkg/ubuntu/diaspora-setup | 6 ++++++ 6 files changed, 23 insertions(+), 49 deletions(-) diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index a5f1e7071..2b3b4238a 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -38,16 +38,7 @@ Source file usede to compile native libraries in diaspora-bundle. %setup -q -n %{name}-%{version}-%{git_release} %build -bundle install --local --deployment --without ri rdoc test -for gem in vendor/git/*.gem; do - gem install --local \ - --force \ - --no-rdoc \ - --no-ri \ - --install-dir vendor/bundle/ruby/1.8 \ - $gem - -done +bundle install --local --deployment --without ri rdoc pushd vendor/bundle/ruby/1.8/gems # In repo (2.2.4) @@ -154,7 +145,7 @@ pushd vendor/bundle/ruby/1.8/gems chmod 644 cucumber-rails-0.3.2/templates/install/step_definitions/capybara_steps.rb.erb || : chmod 644 ffi-0.6.3/ext/ffi_c/libffi/ltmain.sh || : chmod 644 gherkin-2.2.4/tasks/compile.rake || : - chmod 644 i18n-0.4.1/MIT-LICENSE + chmod 644 i18n-0.4.1/MIT-LICENSE || : chmod 755 linecache-0.43/Rakefile || : chmod 755 mime-types-1.16/Rakefile || : chmod 755 mini_magick-2.1/test/not_an_image.php || : @@ -168,7 +159,7 @@ pushd vendor/bundle/ruby/1.8/gems for file in CHANGES VERSION README Rakefile; do chmod 644 term-ansicolor-1.0.5/$file || : done - chmod 755 thin-1.2.7/lib/thin/controllers/service.sh.erb + chmod 755 thin-1.2.7/lib/thin/controllers/service.sh.erb ||: chmod 755 thin-1.2.7/example/async_chat.ru || : chmod 755 thin-1.2.7/example/async_tailer.ru || : chmod 644 treetop-1.4.8/spec/compiler/test_grammar.tt || : @@ -190,8 +181,6 @@ exit 0 find . -name .git | xargs rm -rf find . -name .gitignore -delete find . -name \*.o -delete || : -rm -rf vendor/git -rm -rf vendor/cache test -d vendor/bundle/ruby/1.8//gems/selenium-webdriver-0.0.* && { pushd vendor/bundle//ruby/1.8/gems/selenium-webdriver-0.0.*/lib/selenium/webdriver/ @@ -227,7 +216,7 @@ cat files >> dirs && cp dirs files %files -f files %defattr(-, diaspora, diaspora, 0755) -%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 docs +%doc COPYRIGHT AUTHORS GNU-AGPL-3.0 docs %files -f dev-files devel %defattr(-, root, root, 0644) diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index b3e2eac69..56fb030a8 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -22,6 +22,11 @@ test -n "$services" && { cd /usr/share/diaspora/master +rm -rf vendor +ln -s /usr/lib/diaspora-bundle/vendor . +ln -sf /usr/lib/diaspora-bundle/Gemfile . +ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . + test -e config/app_config.yml || cp config/app_config.yml.example config/app_config.yml diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 8a30492c8..dc02467f4 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -71,6 +71,7 @@ cp %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master +rm -rf $RPM_BUILD_ROOT/%{_datadir}/diaspora/master/vendor/* mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/tmp cp %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/diaspora diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 3e250f31b..ecfffb781 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -161,6 +161,7 @@ function make_src cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master ( cd ${RELEASE_DIR}/master + rm -rf vendor/bundle/* vendor/git/* vendor/cache/* gem-tmp git show --name-only > config/gitversion tar czf public/source.tar.gz \ --exclude='source.tar.gz' -X .gitignore * @@ -175,17 +176,11 @@ function make_src echo "Required bundle: $(git_id dist/diaspora/Gemfile)" } -function fix_gemfile -{ - sed -i 's|git://.*/|vendor/git/|g' $1 - -} - function build_git_gems() # Usage: build_git_gems # Horrible hack, in wait for bundler handling git gems OK. { - mkdir gem-tmp || : + [ -d 'gem-tmp' ] || mkdir gem-tmp cd gem-tmp rm -rf * @@ -198,34 +193,19 @@ function build_git_gems() } name = $2 url="" - suffix = "; cd " name for (i = 3; i <= NF; i += 1) { key = $i i += 1 if (key == ":git") url = $i - else if ( key == ":ref") - suffix = suffix "; git reset --hard " $i - else if ( key == ":branch") - suffix = suffix "; git checkout " $i } - suffix = suffix "; cd .." - cmd = sprintf( "git clone --quiet %s %s %s\n", - url, name, suffix) - print "Running: ", cmd - system( cmd) cmd = sprintf( "git clone --bare --quiet %s\n", url) print "Running: ", cmd system( cmd) }' - sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec + mv devise-mongo_mapper.git devise-mongo_mapper for dir in *; do - if [ -e $dir/*.gemspec ] ; then - cd $dir - gem build *.gemspec - cp *.gem ../../$2 - cd .. - else + if [ ! -e $dir/*.gemspec ]; then cp -ar $dir ../$2 fi done @@ -271,16 +251,17 @@ function make_bundle() cd dist rm -rf $bundle_name cd diaspora + rm Gemfile.lock if [ "$BUNDLE_FIX" = 'yes' ]; then - rm -f Gemfile.lock rm -rf .bundle bundle update fi [ -d 'vendor/git' ] || mkdir vendor/git + rm -rf vendor/git/* + git checkout Gemfile build_git_gems Gemfile vendor/git sed -i 's|git://.*/|vendor/git/|g' Gemfile - rm Gemfile.lock rm -rf .bundle # see: http://bugs.joindiaspora.com/issues/440 bundle install --path=vendor/bundle || diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install index 65ae9520e..506dec038 100755 --- a/pkg/ubuntu/diaspora-bundle-install +++ b/pkg/ubuntu/diaspora-bundle-install @@ -28,13 +28,5 @@ cp -a AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \ cp -ar docs /usr/share/doc/diaspora-bundle bundle install --local --deployment --without ri rdoc -for gem in vendor/git/*; do - gem install --local \ - --force \ - --no-rdoc \ - --no-ri \ - --install-dir vendor/bundle/ruby/1.8/bundler \ - $gem -done diff --git a/pkg/ubuntu/diaspora-setup b/pkg/ubuntu/diaspora-setup index 579664597..71466cf9a 100755 --- a/pkg/ubuntu/diaspora-setup +++ b/pkg/ubuntu/diaspora-setup @@ -24,6 +24,12 @@ service mongodb start || : cd /usr/share/diaspora/master +rm -rf vendor +ln -s /usr/lib/diaspora-bundle/vendor . +ln -sf /usr/lib/diaspora-bundle/Gemfile . +ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . + + test -e config/app_config.yml || cp config/app_config.yml.example config/app_config.yml From 322faf3cc00aa3f366ea9b8fa114404351b55deb Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 27 Oct 2010 13:27:40 +0200 Subject: [PATCH 09/56] Error recovery --- pkg/fedora/make-dist.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index ecfffb781..c96a7f756 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -252,8 +252,8 @@ function make_bundle() rm -rf $bundle_name cd diaspora rm Gemfile.lock + rm -rf .bundle if [ "$BUNDLE_FIX" = 'yes' ]; then - rm -rf .bundle bundle update fi @@ -262,10 +262,12 @@ function make_bundle() git checkout Gemfile build_git_gems Gemfile vendor/git sed -i 's|git://.*/|vendor/git/|g' Gemfile - rm -rf .bundle # see: http://bugs.joindiaspora.com/issues/440 - bundle install --path=vendor/bundle || - bundle install --path=vendor/bundle + bundle install --path=vendor/bundle || { + rm -rf vendor/git/* .bundle + build_git_gems Gemfile vendor/git + bundle install --path=vendor/bundle + } bundle package mkdir -p "../$bundle_name/docs" From 916d488298470f0420ef35221b976dc40bc9545d Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 27 Oct 2010 20:21:06 +0200 Subject: [PATCH 10/56] New try, outside vendor --- pkg/fedora/make-dist.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index c96a7f756..8da155d59 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -257,16 +257,17 @@ function make_bundle() bundle update fi - [ -d 'vendor/git' ] || mkdir vendor/git - rm -rf vendor/git/* + [ -d 'git-repos' ] || mkdir git-repos + rm -rf git-repos/* git checkout Gemfile - build_git_gems Gemfile vendor/git - sed -i 's|git://.*/|vendor/git/|g' Gemfile + build_git_gems Gemfile git-repos + sed -i 's|git://.*/|git-repos/|g' Gemfile # see: http://bugs.joindiaspora.com/issues/440 bundle install --path=vendor/bundle || { - rm -rf vendor/git/* .bundle - build_git_gems Gemfile vendor/git - bundle install --path=vendor/bundle + bundle install --path=vendor/bundle || { + echo "bundle install failed, giving up" >&2 + exit 3 + } } bundle package @@ -277,7 +278,7 @@ function make_bundle() make_docs "vendor/bundle/ruby/1.8/gems/" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/vendor - mv vendor/git ../$bundle_name/vendor + mv git-repos ../$bundle_name rm -rf vendor/gems/* cd .. tar czf $bundle_name.tar.gz $bundle_name From cdcb693c9521530644c46b7d873339c7d748f585 Mon Sep 17 00:00:00 2001 From: Justin Wienckowski Date: Thu, 28 Oct 2010 20:58:39 -0700 Subject: [PATCH 11/56] Issue #446: Adding 32-character length limit to User#username, Profile#first_name, Profile#last_name --- app/models/profile.rb | 2 ++ app/models/user.rb | 3 ++- spec/models/profile_spec.rb | 20 ++++++++++++++++++++ spec/models/user_spec.rb | 10 ++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 8848cd823..145732d7c 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -24,6 +24,8 @@ class Profile key :bio, String after_validation :strip_names + validates_length_of :first_name, :maximum => 32 + validates_length_of :last_name, :maximum => 32 before_save :strip_names diff --git a/app/models/user.rb b/app/models/user.rb index 071abfcb0..cc9a2b7e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -45,7 +45,8 @@ class User before_validation :strip_username, :on => :create validates_presence_of :username validates_uniqueness_of :username, :case_sensitive => false - validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/ + validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/ + validates_length_of :username, :maximum => 32 validates_with InvitedUserValidator one :person, :class_name => 'Person', :foreign_key => :owner_id diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index fed124726..728fc4c3d 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -12,6 +12,16 @@ describe Profile do profile.should be_valid profile.first_name.should == "Shelly" end + + it "can be 32 characters long" do + profile = Factory.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") + profile.should be_valid + end + + it "cannot be 33 characters" do + profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") + profile.should_not be_valid + end end describe "of last_name" do it "strips leading and trailing whitespace" do @@ -19,6 +29,16 @@ describe Profile do profile.should be_valid profile.last_name.should == "Ohba" end + + it "can be 32 characters long" do + profile = Factory.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") + profile.should be_valid + end + + it "cannot be 33 characters" do + profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") + profile.should_not be_valid + end end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a9530093f..fe92b6b94 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -102,6 +102,16 @@ describe User do user = Factory.build(:user, :username => "kittens;") user.should_not be_valid end + + it "can be 32 characters long" do + user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon") + user.should be_valid + end + + it "cannot be 33 characters" do + user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon") + user.should_not be_valid + end end describe "of email" do From de06f43d2637a765aebf3d44ae6a62ff498f643a Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 06:11:27 +0300 Subject: [PATCH 12/56] bugfix --- pkg/fedora/diaspora-bundle.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index 2b3b4238a..7a03479a4 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -205,7 +205,7 @@ find %{buildroot}/%{_libdir}/diaspora-bundle \ find -L %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \ -type f -not -regex '.*[.]c$|.*[.]h$|.*[.]cpp$|.*Makefile$' \ -fprintf files '"%%p"\n' -find %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \ +find -L %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \ -type f -regex '.*[.]c$|.*[.]h$|.*[.]cpp$|.*Makefile$' \ -fprintf dev-files '"%%p"\n' sed -i -e 's|%{buildroot}||' -e 's|//|/|' files dev-files dirs From 625bd428a175ddec509f6c2bfed46a2404579b50 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 13:18:56 +0200 Subject: [PATCH 13/56] bugfixes. Rewrite http: github path to git: --- Gemfile | 2 +- pkg/fedora/diaspora-setup | 2 +- pkg/fedora/make-dist.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 457bfd75b..2b2b8eb92 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ gem 'roxml', :git => 'git://github.com/Empact/roxml.git' gem 'addressable', :require => 'addressable/uri' gem 'json' gem 'mini_fb' -gem 'http_accept_language', :git => 'http://github.com/iain/http_accept_language.git' +gem 'http_accept_language', :git => git://github.com/iain/http_accept_language.git' #Standards gem 'pubsubhubbub' diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index 56fb030a8..726cfe148 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -30,7 +30,7 @@ ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . test -e config/app_config.yml || cp config/app_config.yml.example config/app_config.yml -if rake db:seed:dev; then +if bundle exec rake db:seed:dev; then echo "Database config OK, new user tom/evankorth in place" else cat <<- EOF diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 8da155d59..5d6d1cdba 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -278,8 +278,8 @@ function make_bundle() make_docs "vendor/bundle/ruby/1.8/gems/" "../$bundle_name/docs" mv vendor/cache ../$bundle_name/vendor + mv vendor/gems ../$bundle_name/vendor mv git-repos ../$bundle_name - rm -rf vendor/gems/* cd .. tar czf $bundle_name.tar.gz $bundle_name mv $bundle_name/vendor/cache diaspora/vendor/cache From 668da620f19d0e43b0a8bcaf4501c460c238a8be Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 13:34:45 +0200 Subject: [PATCH 14/56] bugfix --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2b2b8eb92..29a77fb0b 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ gem 'roxml', :git => 'git://github.com/Empact/roxml.git' gem 'addressable', :require => 'addressable/uri' gem 'json' gem 'mini_fb' -gem 'http_accept_language', :git => git://github.com/iain/http_accept_language.git' +gem 'http_accept_language', :git => 'git://github.com/iain/http_accept_language.git' #Standards gem 'pubsubhubbub' From 04984d576a5152764b45807415d5701a9f678902 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 15:48:33 +0200 Subject: [PATCH 15/56] bugfix --- pkg/fedora/diaspora-bundle.spec | 1 + pkg/fedora/diaspora-setup | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/fedora/diaspora-bundle.spec b/pkg/fedora/diaspora-bundle.spec index 7a03479a4..5b56f4d56 100644 --- a/pkg/fedora/diaspora-bundle.spec +++ b/pkg/fedora/diaspora-bundle.spec @@ -199,6 +199,7 @@ popd mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle cp -ar vendor $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle +cp -a Gemfile Gemfile.lock $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle find %{buildroot}/%{_libdir}/diaspora-bundle \ -type d -fprintf dirs '%%%dir "%%p"\n' diff --git a/pkg/fedora/diaspora-setup b/pkg/fedora/diaspora-setup index 726cfe148..4c5138571 100755 --- a/pkg/fedora/diaspora-setup +++ b/pkg/fedora/diaspora-setup @@ -4,6 +4,7 @@ # # Usage: # ./diaspora-setup [external hostname] # +export PATH=$PATH:/usr/local/bin arg_hostname="$1" @@ -22,10 +23,12 @@ test -n "$services" && { cd /usr/share/diaspora/master +libdir=$(rpm --eval %_libdir) + rm -rf vendor -ln -s /usr/lib/diaspora-bundle/vendor . -ln -sf /usr/lib/diaspora-bundle/Gemfile . -ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . +ln -s $libdir/diaspora-bundle/vendor . +ln -sf $libdir/diaspora-bundle/Gemfile . +ln -sf $libdir/diaspora-bundle/Gemfile.lock . test -e config/app_config.yml || cp config/app_config.yml.example config/app_config.yml From 42e8c8f11b9f033bb895a7aed2709bcb7564c138 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 21:16:37 +0200 Subject: [PATCH 16/56] Raw code --- pkg/.gitignore | 1 + pkg/README.md | 13 ++ pkg/fedora/README.md | 75 ++----- pkg/fedora/dist | 1 + pkg/fedora/dist/.gitkeep | 0 pkg/fedora/prepare-rpm.sh | 165 +++++++++++++++ pkg/source/README.md | 74 +++++++ pkg/{fedora => source}/add-bundle.diff | 0 pkg/source/funcs.sh | 78 ++++++++ pkg/{fedora => source}/make-dist.sh | 266 ++++--------------------- pkg/ubuntu/README.md | 15 +- pkg/ubuntu/make-dist.sh | 1 - 12 files changed, 390 insertions(+), 299 deletions(-) create mode 100644 pkg/.gitignore create mode 100644 pkg/README.md create mode 120000 pkg/fedora/dist delete mode 100644 pkg/fedora/dist/.gitkeep create mode 100755 pkg/fedora/prepare-rpm.sh create mode 100644 pkg/source/README.md rename pkg/{fedora => source}/add-bundle.diff (100%) create mode 100644 pkg/source/funcs.sh rename pkg/{fedora => source}/make-dist.sh (50%) delete mode 120000 pkg/ubuntu/make-dist.sh diff --git a/pkg/.gitignore b/pkg/.gitignore new file mode 100644 index 000000000..1521c8b76 --- /dev/null +++ b/pkg/.gitignore @@ -0,0 +1 @@ +dist diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 000000000..8b65d479c --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,13 @@ +## Diaspora install and packaging tools + +This directory contains stuff to install and run diaspora. + +- ubuntu-setup.bash: script which installs all of Diasporas + dependencies and starts the server. + +- source: stuff to package Diaspora into traditional tarballs + which can be installed. + +- ubuntu: Scripts and tools to install generic tarballs on Ubuntu + +- fedora: Scripts and tools to create fedora RPMS:s from tarballs diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 38801dc42..40ccf7ae3 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -18,16 +18,20 @@ Prerequisites: - A personal environment to build RPM:s, also described in [RPM installation Fedora](http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora) -Install g++ (unnecessary?): +Install g++ and gcc: % yum install gcc-c++ -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 +Bootstrap the distribution from git: + % sudo apt-get install git-core + % git clone git://github.com/diaspora/diaspora.git + % cd diaspora/pkg/ubuntu -Setup links to tarballs from RPM source directory and create spec files: - % ./make-dist.sh prepare +Create and install the diaspora bundle and application in +diaspora/pkg/source according to +[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) + +Setup links from tarballs to RPM source directory and create spec files: + % ./prepare-rpm.sh Build rpms: rpmbuild -ba dist/diaspora.spec @@ -51,63 +55,10 @@ apache/passenger setup. After configuration, start with: /sbin/service diaspora-wsd start /sbin/service httpd restart -#### Generic source synopsis - -Generate source tarball: - % ./make-dist.sh source - Using repo: http://github.com/diaspora/diaspora.git - Commit id: 1010092232_b313272 - Source: dist/diaspora-0.0-1010092232_b313272.tar.gz - Required bundle: 1010081636_d1a4ee0 - % - -The source tarball could be used as-is, by unpacking add making a -*bundle install*. An alternative is to generate a canned bundle like: - % ./make-dist.sh bundle - [ lot's of output...] - Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz - % - -This file can be installed anywhere. To use it, add a symlink from vendor/bundle -to the bundle's bundle directory. Reasonable defaults are to install -diaspora in /usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, -the link is - % rm -rf /usr/share/diaspora/master/vendor/bundle - % ln -sf /usr/lib/diaspora-bundle/vendor/bundle \ - > /usr/share/diaspora/master/vendor - % - -The directories tmp, log, and public/uploads needs to be writable. If using -apache passenger, read the docs on uid used and file ownership. - -Note that the bundle version required is printed each time a new source -is generated. - #### Notes -The source tarball is as retrieved from diaspora with following differences: - - - The .git directories are removed (freeing more than 50% of the size). - - A new file /master/config/gitversion is created. - - The file public/source.tar.gz is generated. - - The file .bundle/config is patched. Remove before doing - *bundle install* - -The bundle is basically the output from 'bundle package'. The git-based -gems are also added into vendor/git. - -./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The -root cause is a bad Gemfile in the git repo. Possible fixes includes -using a older version known to work: - % ./make-dist.sh -c c818885b6 bundle - % ./make-dist.sh -c c818885b6 source - -or forcing a complete update of Gemfile.lock using 'bundle update' (a -potentially problematic operation): - % ./make-dist.sh -f bundle - -*make-dist prepare* creates links also for all files listed in SOURCES. -Typically, this is secondary sources. *make-dist.sh sources* +prepare-rpm.sh prepare creates links also for all files listed in SOURCES. +Typically, this is secondary sources. *make-dist.sh source* applies all patches named *.patch in this directory after checking out source from git. diff --git a/pkg/fedora/dist b/pkg/fedora/dist new file mode 120000 index 000000000..378798d00 --- /dev/null +++ b/pkg/fedora/dist @@ -0,0 +1 @@ +../source/dist \ No newline at end of file diff --git a/pkg/fedora/dist/.gitkeep b/pkg/fedora/dist/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pkg/fedora/prepare-rpm.sh b/pkg/fedora/prepare-rpm.sh new file mode 100755 index 000000000..5d03f8328 --- /dev/null +++ b/pkg/fedora/prepare-rpm.sh @@ -0,0 +1,165 @@ +#!/bin/bash + +# Create RPM spec files matching diaspora tarballs +# +# Usage: See function usage() at bottom. +# +GIT_REPO='http://github.com/diaspora/diaspora.git' +VERSION='0.0' +RELEASE='1' + +. ../source/funcs.sh + + +function fix_alphatag() +# Patch version on top comment first id line: +# Usage: fix_alphatag +# Patches:\ +# * Fri Sep 24 2010 name surname 1.20100925_faf23207 +{ + local dist=$(rpm --eval %dist) + awk -v dist="$dist" -v version="$2" -v commit="$3" -v release="$4" \ + ' BEGIN { done = 0 } + /^[*]/ { if (done) + print + else + { + s = sprintf( "-%s.%s%s\n", release, commit, dist) + gsub( "-[0-9][.][^ ]*$", s) + done = 1 + # add new gsub for version... + print + } + next + } + { print }' < $1 > $1.tmp && mv -f $1.tmp $1 +} + + +function fix_bundle_deps +# usage: fix_bundle_deps +# 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 && mv -f $1.tmp $1 +} + + +function patch() +# Patch spec-files with current version-release +# Usage: patch +{ + sed -e "/^%define/s|HEAD|$2|" \ + -e '/^Version:/s|.*|Version: '$1'|' \ + dist/diaspora.spec + fix_alphatag dist/diaspora.spec $1 $2 $3 + local bundle_id=$(git_id dist/diaspora/Gemfile) + local dist_tag=$(rpm --eval %dist) + fix_bundle_deps dist/diaspora.spec $1 "$RELEASE.${bundle_id}$dist_tag" + sed -e "/^%define/s|HEAD|$bundle_id|" \ + -e '/^Version:/s|.*|Version: '$1'|' \ + < diaspora-bundle.spec > dist/diaspora-bundle.spec + + cp dist/diaspora.spec dist/diaspora/diaspora.spec +} + + +function prepare_rpm() +# Usage: prepare_rpm < commit> +{ + local dest=$(rpm --eval %_sourcedir) + test -z "$dest" && { + echo "Can't find RPM source directory, giving up." + exit 2 + } + + local commit=$( checkout $1) + echo "Release: $RELEASE.$commit" + echo "Rpm source dir: $dest" + + patch $VERSION $commit $RELEASE + + local src="dist/diaspora-$VERSION-$commit.tar.gz" + test -e $src || + cat <<- EOF + Warning: $src does not exist + (last version not built?) + EOF + ln -sf $PWD/$src $dest + + local bundle_commit=$( git_id dist/diaspora/Gemfile) + local bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz" + test -e $bundle || + cat <<- EOF + Warning: $bundle does not exist + (last version not built?) + EOF + ln -sf $PWD/$bundle $dest + + local file + for file in $( grep -v '^#' SOURCES); do + if [ -e "$file" ]; then + ln -sf $PWD/$file $dest/$file + else + echo "Warning: $file (listed in SOURCES) does not exist" + fi + done + + ( cd $dest; find . -type l -not -readable -exec rm {} \;) + echo "Source specfile: dist/diaspora.spec" + echo "Bundle specfile: dist/diaspora-bundle.spec" +} + + +function usage() +{ + cat <<- EOF + + Usage: prepare-rpm [options] + + Options: + + -h Print this message. + -r release For prepare, mark with release nr, defaults to 1. + + Symlink bundle and source tarballs to rpm source dir, create + patched rpm spec files. + + All results are stored in dist/ + + EOF +} + + +commit='HEAD' +BUNDLE_FIX='no' +while getopts ":r:h" opt +do + case $opt in + r) RELEASE="$OPTARG:" + ;; + h) usage + exit 0 + ;; + *) usage + exit 2 + ;; + esac +done +shift $(($OPTIND - 1)) + +typeset -r GIT_REPO RELEASE BUNDLE_FIX +export LANG=C + +test $# -gt 0 && { + usage; + exit 2; +} +prepare_rpm diff --git a/pkg/source/README.md b/pkg/source/README.md new file mode 100644 index 000000000..789da6ec8 --- /dev/null +++ b/pkg/source/README.md @@ -0,0 +1,74 @@ +## Diaspora source tarball generation + +Creates diaspora source tarballs. + +#### Generic source synopsis + +Generate source tarball: + % ./make-dist.sh source + Using repo: http://github.com/diaspora/diaspora.git + Commit id: 1010092232_b313272 + Source: dist/diaspora-0.0-1010092232_b313272.tar.gz + Required bundle: 1010081636_d1a4ee0 + % + +The source tarball could be used as-is, by unpacking add making a +*bundle install*. An alternative is to generate a canned bundle like: + % ./make-dist.sh bundle + [ lot's of output...] + Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz + % + +This file can be installed anywhere. To use it, add a symlinks from app +to the bundle'. Reasonable defaults are to install diaspora in +/usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, +the link setups is + % cd /usr/share/diaspora/master + % rm -rf vendor + % ln -sf /usr/lib/diaspora-bundle/vendor vendor + % ln -sf /usr/lib/diaspora-bundle/Gemfile . + % ln -sf /usr/lib/diaspora-bundle/Gemfile.lock . + + +The directories tmp, log, and public/uploads needs to be writable. If using +apache passenger, read the docs on uid used and file ownership. + +Note that the bundle version required is printed each time a new source +is generated. + +#### Notes + +The source tarball is as retrieved from diaspora with following differences: + + - The .git directories are removed (freeing more than 50% of the size). + - A new file /master/config/gitversion is created. + - The file public/source.tar.gz is generated. + - The file .bundle/config is patched. Remove before doing + *bundle install* + +The bundle is basically the output from 'bundle package'. The git-based +gems are also added into git-gems. Bundle also houses the two files +Gemfile and Gemfile.lock + +*make-dist.sh source* applies all patches named *.patch in this directory +after checking out source from git. + +./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The +root cause is a bad Gemfile in the git repo. Possible fixes includes +using a older version known to work: + % ./make-dist.sh -c c818885b6 bundle + % ./make-dist.sh -c c818885b6 source + +or forcing a complete update of Gemfile.lock using 'bundle update' (a +potentially problematic operation): + % ./make-dist.sh -f bundle + +#### 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 package* in the diaspora dir. +The resulting bundle is stored in vendor/bundle. This is, after some more +patches, the content of diaspora-bundle tarball. Target systems makes a +*bundle install --local* to use it. diff --git a/pkg/fedora/add-bundle.diff b/pkg/source/add-bundle.diff similarity index 100% rename from pkg/fedora/add-bundle.diff rename to pkg/source/add-bundle.diff diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh new file mode 100644 index 000000000..127801ea6 --- /dev/null +++ b/pkg/source/funcs.sh @@ -0,0 +1,78 @@ +# +# Common stuff for pkg scripts +# + +function git_id +# +# Echo package-friendly source id. +# +# Usage: git_id [-n] [file or directory] +# +{ + local nl="\n" + local file_or_dir="$PWD" + test "$1" = '-n' && { nl=""; shift; } + test -n "$1" && file_or_dir="$1" + if [ -d $file_or_dir ]; then + local file="" + local dir=$file_or_dir + else + local file=$(basename $file_or_dir) + local dir=$(dirname $file_or_dir) + fi + + ( + cd $dir + git log -1 --abbrev-commit --date=iso $file | + awk -v nl="$nl" \ + ' BEGIN { commit = ""; d[1] = "" } + /^commit/ { if ( commit == "") commit = $2 } + /^Date:/ { if (d[1] == "") { + 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 checkout() +# Checkout last version of diaspora unless it's already there. +# Uses global GIT_REPO to determine repo url +# Usage: checkout [commit id, defaults to HEAD] +# Returns: commit for current branch's HEAD. +{ + mkdir dist &>/dev/null || : + ( + local last_repo='' + cd dist + + test -e '.last-repo' && + last_repo=$( cat '.last-repo') + test "$last_repo" != $GIT_REPO && + rm -rf diaspora + test -d diaspora || { + git clone --quiet $GIT_REPO; + ( + cd diaspora; + git remote add upstream \ + git://github.com/diaspora/diaspora.git + for p in ../../*.patch; do + git apply --whitespace=fix $p > /dev/null + done &> /dev/null || : + ) + } + echo -n "$GIT_REPO" > '.last-repo' + + cd diaspora; + git fetch --quiet upstream + git merge --quiet upstream/master + [ -n "$1" ] && git reset --hard --quiet $1 + git_id -n + ) +} + diff --git a/pkg/fedora/make-dist.sh b/pkg/source/make-dist.sh similarity index 50% rename from pkg/fedora/make-dist.sh rename to pkg/source/make-dist.sh index 5d6d1cdba..125f9dcdd 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/source/make-dist.sh @@ -1,180 +1,13 @@ #!/bin/bash -# Create a diaspora distribution +# Create diaspora distribution tarballs. # # Usage: See function usage() at bottom. # GIT_REPO='http://github.com/diaspora/diaspora.git' VERSION='0.0' -RELEASE='1' - -function git_id -# -# Echo package-friendly source id. -# -# Usage: git_id [-n] [file or directory] -# -{ - local nl="\n" - local file_or_dir="$PWD" - test "$1" = '-n' && { nl=""; shift; } - test -n "$1" && file_or_dir="$1" - if [ -d $file_or_dir ]; then - local file="" - local dir=$file_or_dir - else - local file=$(basename $file_or_dir) - local dir=$(dirname $file_or_dir) - fi - - ( - cd $dir - git log -1 --abbrev-commit --date=iso $file | - awk -v nl="$nl" \ - ' BEGIN { commit = ""; d[1] = "" } - /^commit/ { if ( commit == "") commit = $2 } - /^Date:/ { if (d[1] == "") { - 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: -# Usage: fix_alphatag -# Patches:\ -# * Fri Sep 24 2010 name surname 1.20100925_faf23207 -{ - local dist=$(rpm --eval %dist) - awk -v dist="$dist" -v version="$2" -v commit="$3" -v release="$4" \ - ' BEGIN { done = 0 } - /^[*]/ { if (done) - print - else - { - s = sprintf( "-%s.%s%s\n", release, commit, dist) - gsub( "-[0-9][.][^ ]*$", s) - done = 1 - # add new gsub for version... - print - } - next - } - { print }' < $1 > $1.tmp && mv -f $1.tmp $1 -} - - -function fix_bundle_deps -# usage: fix_bundle_deps -# 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 && mv -f $1.tmp $1 -} - - -function patch() -# Patch spec-files with current version-release -# Usage: patch -{ - sed -e "/^%define/s|HEAD|$2|" \ - -e '/^Version:/s|.*|Version: '$1'|' \ - dist/diaspora.spec - fix_alphatag dist/diaspora.spec $1 $2 $3 - local bundle_id=$(git_id dist/diaspora/Gemfile) - local dist_tag=$(rpm --eval %dist) - fix_bundle_deps dist/diaspora.spec $1 "$RELEASE.${bundle_id}$dist_tag" - sed -e "/^%define/s|HEAD|$bundle_id|" \ - -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 || : - ( - local last_repo='' - cd dist - - test -e '.last-repo' && - last_repo=$( cat '.last-repo') - test "$last_repo" != $GIT_REPO && - rm -rf diaspora - test -d diaspora || { - git clone --quiet $GIT_REPO; - ( - cd diaspora; - git remote add upstream \ - git://github.com/diaspora/diaspora.git - for p in ../../*.patch; do - git apply --whitespace=fix $p > /dev/null - done &> /dev/null || : - ) - } - echo -n "$GIT_REPO" > '.last-repo' - - cd diaspora; - git fetch --quiet upstream - git merge --quiet upstream/master - [ -n "$1" ] && git reset --hard --quiet $1 - git_id -n - ) -} - - -function make_src -# Create a distribution tarball -# Usage: make src -{ - echo "Using repo: $GIT_REPO" - - commit=$(checkout ${1:-'HEAD'}) - echo "Commit id: $commit" - - RELEASE_DIR="diaspora-$VERSION-$commit" - rm -rf dist/${RELEASE_DIR} - mkdir dist/${RELEASE_DIR} - cd dist - mkdir ${RELEASE_DIR}/master - cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master - ( - cd ${RELEASE_DIR}/master - rm -rf vendor/bundle/* vendor/git/* vendor/cache/* gem-tmp - git show --name-only > config/gitversion - tar czf public/source.tar.gz \ - --exclude='source.tar.gz' -X .gitignore * - find $PWD -name .git\* | xargs rm -rf - rm -rf .bundle - /usr/bin/patch -p1 -s <../../../add-bundle.diff - ) - tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ - rm -rf ${RELEASE_DIR} - cd .. - echo "Source: dist/${RELEASE_DIR}.tar.gz" - echo "Required bundle: $(git_id dist/diaspora/Gemfile)" -} +. ./funcs.sh function build_git_gems() # Usage: build_git_gems @@ -213,6 +46,38 @@ function build_git_gems() # rm -rf gem-tmp } +function make_src +# Create a distribution tarball +# Usage: make src +{ + echo "Using repo: $GIT_REPO" + + commit=$(checkout ${1:-'HEAD'}) + echo "Commit id: $commit" + + RELEASE_DIR="diaspora-$VERSION-$commit" + rm -rf dist/${RELEASE_DIR} + mkdir dist/${RELEASE_DIR} + cd dist + mkdir ${RELEASE_DIR}/master + cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master + ( + cd ${RELEASE_DIR}/master + rm -rf vendor/bundle/* vendor/git/* vendor/cache/* gem-tmp + git show --name-only > config/gitversion + tar czf public/source.tar.gz \ + --exclude='source.tar.gz' -X .gitignore * + find $PWD -name .git\* | xargs rm -rf + rm -rf .bundle + /usr/bin/patch -p1 -s <../../../add-bundle.diff + ) + tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ + rm -rf ${RELEASE_DIR} + cd .. + echo "Source: dist/${RELEASE_DIR}.tar.gz" + echo "Required bundle: $(git_id dist/diaspora/Gemfile)" +} + function make_docs() { local gems=$1 @@ -238,6 +103,7 @@ function make_docs() } + function make_bundle() # Create the bundle tarball # Usage: make_bundle [ commit, defaults to HEAD] @@ -285,69 +151,21 @@ function make_bundle() mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } + git checkout Gemfile echo echo "Bundle: dist/$bundle_name.tar.gz" } - -function prepare_rpm() -# Usage: prepare_rpm < commit> -{ - local dest=$(rpm --eval %_sourcedir) - test -z "$dest" && { - echo "Can't find RPM source directory, giving up." - exit 2 - } - - local commit=$( checkout $1) - echo "Release: $RELEASE.$commit" - echo "Rpm source dir: $dest" - - patch $VERSION $commit $RELEASE - - local src="dist/diaspora-$VERSION-$commit.tar.gz" - test -e $src || - cat <<- EOF - Warning: $src does not exist - (last version not built?) - EOF - ln -sf $PWD/$src $dest - - local bundle_commit=$( git_id dist/diaspora/Gemfile) - local bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz" - test -e $bundle || - cat <<- EOF - Warning: $bundle does not exist - (last version not built?) - EOF - ln -sf $PWD/$bundle $dest - - local file - for file in $( grep -v '^#' SOURCES); do - if [ -e "$file" ]; then - ln -sf $PWD/$file $dest/$file - else - echo "Warning: $file (listed in SOURCES) does not exist" - fi - done - - ( cd $dest; find . -type l -not -readable -exec rm {} \;) - echo "Source specfile: dist/diaspora.spec" - echo "Bundle specfile: dist/diaspora-bundle.spec" -} - - function usage() { cat <<- EOF - Usage: make-dist [options] + Usage: make-dist [options] Options: -h Print this message. -c commit Use a given commit, defaults to last checked in. - -r release For prepare, mark with release nr, defaults to 1. -u uri Git repository URI, defaults to $GIT_REPO. -f For bundle, fix dependencies by running 'bundle update' @@ -355,8 +173,6 @@ function usage() source Build a diaspora application tarball. bundle Build a bundler(1) bundle for diaspora. - prepare Symlink bundle and source tarballs to rpm source dir, - create patched rpm spec files. All results are stored in dist/ @@ -366,15 +182,13 @@ function usage() commit='HEAD' BUNDLE_FIX='no' -while getopts ":r:c:u:fh" opt +while getopts ":c:u:fh" opt do case $opt in u) GIT_REPO="$OPTARG" ;; c) commit="${OPTARG:0:7}" ;; - r) RELEASE="$OPTARG:" - ;; f) BUNDLE_FIX='yes' ;; h) usage @@ -387,7 +201,7 @@ do done shift $(($OPTIND - 1)) -typeset -r GIT_REPO RELEASE BUNDLE_FIX +typeset -r GIT_REPO BUNDLE_FIX export LANG=C test $# -gt 1 -o $# -eq 0 && { @@ -401,8 +215,6 @@ case $1 in ;; 'source') make_src $commit ;; - 'prepare') prepare_rpm $commit $release - ;; *) usage exit 1 ;; diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 44e83c79b..53960af05 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -5,23 +5,20 @@ work as a first step towards packaging, but should be usable as is. ### Synopsis - Bootstrap the distribution from git: % sudo apt-get install git-core % git clone git://github.com/diaspora/diaspora.git % cd diaspora/pkg/ubuntu +Create and install the diaspora bundle and application in +diaspora/pkg/source according to +[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) + Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps -Create and install the diaspora bundle and application: - % ./make-dist.sh bundle - % sudo ./diaspora-bundle-install dist/diaspora-bundle-*.tar.gz - - % ./make-dist.sh source - % sudo ./diaspora-install dist/diaspora-0.0*.tar.gz - -Initiate and start the server; +Install, initiate and start the server; + % sudo ./diaspora-install % sudo ./diaspora-setup % sudo su - diaspora % cd /usr/share/diaspora/master diff --git a/pkg/ubuntu/make-dist.sh b/pkg/ubuntu/make-dist.sh deleted file mode 120000 index f6ba9c6a2..000000000 --- a/pkg/ubuntu/make-dist.sh +++ /dev/null @@ -1 +0,0 @@ -../fedora/make-dist.sh \ No newline at end of file From 6c25b02216d19de4e8e861637717f49aa7a7853c Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 21:21:10 +0200 Subject: [PATCH 17/56] bugfix --- pkg/ubuntu/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 53960af05..f0cdfb767 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -12,7 +12,7 @@ Bootstrap the distribution from git: Create and install the diaspora bundle and application in diaspora/pkg/source according to -[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) +[source README](//diaspora/diaspora/blob/master/source/fedora/README.md) Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps From 2a3ea8b8e6ab32357300194d633a2b94e98680e0 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 21:25:05 +0200 Subject: [PATCH 18/56] bugfix --- pkg/ubuntu/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index f0cdfb767..ad55213de 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -12,7 +12,7 @@ Bootstrap the distribution from git: Create and install the diaspora bundle and application in diaspora/pkg/source according to -[source README](//diaspora/diaspora/blob/master/source/fedora/README.md) +[source README](/diaspora/diaspora/blob/master/source/fedora/README.md) Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps From 814041d771c595feece1e10fe5d0a336bcbb2792 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 21:27:07 +0200 Subject: [PATCH 19/56] bugfix --- pkg/ubuntu/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index ad55213de..53960af05 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -12,7 +12,7 @@ Bootstrap the distribution from git: Create and install the diaspora bundle and application in diaspora/pkg/source according to -[source README](/diaspora/diaspora/blob/master/source/fedora/README.md) +[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps From 50b52af11abbd227bb7564584ff6d0558f4bc0db Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 21:37:45 +0200 Subject: [PATCH 20/56] bugfix,docs --- pkg/fedora/README.md | 26 +++++++------------------- pkg/source/make-dist.sh | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 40ccf7ae3..7d645374f 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -1,13 +1,12 @@ ## Diaspora RPM tools -Creates diaspora source tarballs and RPM packages +Create RPM packages An alternative to the capistrano system, providing classic, binary RPM -packages for deployment on Fedora 13 and OS-independent source tarballs -aimed for packaging purposes. +packages for deployment on Fedora. -#### Fedora RPM synopsis +#### Synopsis Prerequisites: @@ -62,15 +61,15 @@ Typically, this is secondary sources. *make-dist.sh source* applies all patches named *.patch in this directory after checking out source from git. -The spec-files in dist/ are patched by *./make-dist.sh prepare* to reference +The spec-files in dist/ are patched by *./prepare-rpm.sh 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. Editing spec files should be done -in this directory, changes in dist/ are lost when doing *./make-dist prepare*. +in this directory, changes in dist/ are lost when doing *./prepare-rpm.sh *. The topmost comment's version is patched to reflect the complete version -of current specfile by *make-dist source*. Write the comment in this -directory, copy-paste previous version nr. It will be updated. +of current specfile . Write the comment in this directory, copy-paste +previous version nr. It will be updated. This has been confirmed to start up and provide basic functionality both using the thin webserver and apache passenger, on 32/64 bit systems and in the @@ -79,17 +78,6 @@ at [ftp://mumin.dnsalias.net/pub/leamas/diaspora/builds](ftp://mumin.dnsalias.ne #### 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 package* in the diaspora dir. -The resulting bundle is stored in vendor/bundle. This is, after some more -patches, the content of diaspora-bundle tarball. Target systems makes a -*bundle install --local* to use it. - -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 root. 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 diff --git a/pkg/source/make-dist.sh b/pkg/source/make-dist.sh index 125f9dcdd..e96e62ef6 100755 --- a/pkg/source/make-dist.sh +++ b/pkg/source/make-dist.sh @@ -146,12 +146,12 @@ function make_bundle() mv vendor/cache ../$bundle_name/vendor mv vendor/gems ../$bundle_name/vendor mv git-repos ../$bundle_name + git checkout Gemfile cd .. tar czf $bundle_name.tar.gz $bundle_name mv $bundle_name/vendor/cache diaspora/vendor/cache cd .. } - git checkout Gemfile echo echo "Bundle: dist/$bundle_name.tar.gz" } From 205a0a69f21b873ab65630b2093cbe0ce0046ff4 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sun, 31 Oct 2010 00:02:06 +0200 Subject: [PATCH 21/56] Hlding dist dirs in rep --- pkg/ubuntu/dist | 1 + pkg/ubuntu/dist/.gitkeep | 0 2 files changed, 1 insertion(+) create mode 120000 pkg/ubuntu/dist delete mode 100644 pkg/ubuntu/dist/.gitkeep diff --git a/pkg/ubuntu/dist b/pkg/ubuntu/dist new file mode 120000 index 000000000..378798d00 --- /dev/null +++ b/pkg/ubuntu/dist @@ -0,0 +1 @@ +../source/dist \ No newline at end of file diff --git a/pkg/ubuntu/dist/.gitkeep b/pkg/ubuntu/dist/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 68d2f4162ea0da5160d1664784e9168e85240d57 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sun, 31 Oct 2010 01:38:48 +0200 Subject: [PATCH 22/56] bugfix --- pkg/source/funcs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh index 127801ea6..bc9edd862 100644 --- a/pkg/source/funcs.sh +++ b/pkg/source/funcs.sh @@ -59,6 +59,7 @@ function checkout() git clone --quiet $GIT_REPO; ( cd diaspora; + git checkout Gemfile git remote add upstream \ git://github.com/diaspora/diaspora.git for p in ../../*.patch; do From 96906d9eaf602219b31c8150abca8cb49ea39794 Mon Sep 17 00:00:00 2001 From: Abdulaziz Al-Shetwi Date: Sun, 31 Oct 2010 14:14:48 +0300 Subject: [PATCH 23/56] Retranslate arabic localization. --- config/locales/diaspora/ar.yml | 140 ++++++++++++++++----------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/config/locales/diaspora/ar.yml b/config/locales/diaspora/ar.yml index 87522287a..6e9d7700e 100644 --- a/config/locales/diaspora/ar.yml +++ b/config/locales/diaspora/ar.yml @@ -5,18 +5,18 @@ # Sample localization file for Arabic. ar: - hello: "مرحبا العالم" + hello: "مرحبا" application: helper: - unknown_person: "غير معروف شخص" + unknown_person: "شخص غير معروف" new_requests: "طلبات جديدة" dashboards: helper: - home: "منزل" + home: "الرئيسية" error_messages: helper: - invalid_fields: "الحقول غير صالحة" - correct_the_following_errors_and_try_again: ".تصحيح الأخطاء التالية وحاول مرة أخرى" + invalid_fields: "مدخلات غير صحيحة" + correct_the_following_errors_and_try_again: ".صحح الأخطاء التالية وحاول مرة أخرى" people: helper: results_for: "%{params} نتائج " @@ -34,39 +34,39 @@ ar: all_aspects: "جميع الجوانب" manage_aspects: "إدارة الجوانب" publisher: - share: "تقاسم" + share: "مشاركة" aspect_friends: add_friends: "أضف أصدقاء" albums: album: you: "أنت" new_album: - create: "خلق" - add_a_new_album: "إضافة ألبوم جديد" + create: "جديد" + add_a_new_album: "أضف ألبوم جديد" show: edit_album: "تعديل الألبوم" albums: "البومات" updated: "تحديث" by: "بواسطة" edit: - editing: "التحرير" - updated: "تحديث" + editing: "تحرير" + updated: "محدث" are_you_sure: "هل أنت متأكد؟" delete_album: "حذف ألبوم" cancel: "إلغاء" index: - home: "منزل" + home: "الرئيسية" new_album: "ألبوم جديد" create: - success: ".ألبوما %{name} لقد قمت دعا" + success: " .%{name} لقد قمت بإنشاء ألبوم بإسم" update: - success: ".تحرير بنجاح %{name} الألبوم" + success: ".بنجاح %{name} تم تحرير ألبوم" failure: ".%{name} فشلت في تحرير ألبوم" destroy: - success: ".حذفها %{name} الألبوم" + success: ".%{name} تم حذف ألبوم" helper: - friends_albums: "أصدقاء البومات" - your_albums: "البومات الخاص" + friends_albums: "ألبومات الأصدقاء" + your_albums: "البوماتك" aspects: index: photos: "صور" @@ -81,23 +81,23 @@ ar: ignore_remove: "تجاهل/إزالة" new_aspect: add_a_new_aspect: "أضف جانبا جديدا" - create: "خلق" + create: "جديد" create: - success: ".الذي يمكن أن نرى الجانب الجديد الخاص بك Diaspora انقر على علامة الجمع على الجانب الأيسر لنقو" + success: ".من الذي يمكنه مشاهدة مظهرك الجديد Diaspora انقر على علامة الزائد على الجانب الأيسر لتقول ل" failure: ".فشل إنشاء الجانب" destroy: - success: ".%{name} وقد نجحت في إزالة" + success: ".بنجاح %{name} تم إزالة" update: - success: ".تحرير بنجاح ,%{name} ,وقد الجانب الخاص بك" + success: ".بنجاح %{name} تم تعديل" move_friends: failure: ".%{real_name} فشل تحرير آسبكت لصدي" success: ".جوانب الموضوع بنجاح" move_friend: failure: "%{inspect} لم تنجح" - success: ".أنت الآن عرض صديقك جانبا مختلفا من جوانب نفسك" + success: ".تم إضافة صديقك بنجاح" helper: - remove: "نزع" - aspect_not_empty: "الجانب يست فارغ" + remove: "حذف" + aspect_not_empty: "الجانب ليس فارغ" users: edit: editing_profile: "تحرير الملف الشخصي" @@ -110,82 +110,82 @@ ar: picture: "صورة" editing_profile: "تحرير الملف الشخصي" albums: "البومات" - you_dont_have_any_photos: "ليس لديك أي صوا! نتقل إلى" - page_to_upload_some: ".الصفحة لتحميل بعض" + you_dont_have_any_photos: "ليس لديك أي صور! انتقل إلى" + page_to_upload_some: ".صفحة تحميل بعض" comments: comment: ago: "منذ" new_comment: - comment: "كيف" + comment: "تعليق" photos: show: prev: "السابق" - full_size: "الحجم الكام" + full_size: "الحجم اﻷصلي" next: "القادم" - edit_photo: "تحرير الصو" - delete_photo: "حذف الصو" + edit_photo: "تحرير الصورة" + delete_photo: "حذف الصورة" are_you_sure: "هل أنت متأكد؟" comments: "تعليقات" edit: - editing: "تصحيح" - are_you_sure: "هل أنت متأك؟" - delete_photo: "حذف الصو" + editing: "تحرير" + are_you_sure: "هل أنت متأكد؟" + delete_photo: "حذف الصورة" photo: - show_comments: "sعرض التعليقا" - posted_a_new_photo_to: "أرسلت صورة جديدة ل" + show_comments: "عرض التعليقات" + posted_a_new_photo_to: "أضفت صورة جديدة ل" new: - new_photo: "جديد الصو" - back_to_list: "عودة إلى قائم" - post_it: "!بعد ذلك" + new_photo: "صورة جديدة" + back_to_list: "عودة إلى القائمة" + post_it: "!ألصقها" create: - runtime_error: "?فشل تحميل الصور. هل أنت متأكد من أن يتم ربط حزام الأمان" - integrity_error: "?فشل تحميل الصور. هل أنت متأكد من أن صورة" - type_error: "?فشل تحميل الصور. هل أنت متأكد من وأضيف صورة" + runtime_error: "فشل تحميل الصور. هل ربطت حزام الأمان؟" + integrity_error: "فشل تحميل الصور. هل ملفك صورة؟" + type_error: "فشل تحميل الصور. هل أنت متأكد أنك أضفت صورة؟" update: - notice: ".الصورة تحديثها بنجاح" - error: ".فشل لتحرير الصو" + notice: "تم تحديث الصورة بنجاح" + error: "فشل تحرير الصورة." destroy: - notice: ".الصور المحذوفة" + notice: "تم حذف الصورة" registrations: new: - sign_up: "قم بالتسجي" + sign_up: "التسجيل" create: - success: "!Diaspora لقد انضممت" + success: "!Diaspora سجل في" status_messages: new_status_message: - tell_me_something_good: "قل لي شيئا جيد" - oh_yeah: "!نعم" + tell_me_something_good: "قل لي شيئا جيداً" + oh_yeah: "!يا سلااام" status_message: - show_comments: "عرض التعليقا" + show_comments: "عرض التعليقات" delete: "حذف" are_you_sure: "هل أنت متأكد؟" show: - status_message: "رسالة الحالة" + status_message: "الحالة" comments: "تعليقات" are_you_sure: "هل أنت متأكد؟" - destroy: "هدم" - view_all: "عرض الك" + destroy: "إزالة" + view_all: "عرض الكل" message: "رسالة" owner: "مالك" helper: - no_message_to_display: ".أي رسالة لعرضه" + no_message_to_display: "لا يوجد رسالة لعرضها" people: person: - add_friend: "أضف صدي" - pending_request: "في انتظار طلب" + add_friend: "أضف صديق" + pending_request: "طلبات معلقة" index: - add_friend: "أضف صدي" - real_name: "اسمه الحقيقي" + add_friend: "أضف صديق" + real_name: "الاسم الحقيقي" diaspora_handle: "اسمك المستعار diaspora" - thats_you: "!هذا لك" - friend_request_pending: "طلب صديق معلقة" - you_have_a_friend_request_from_this_person: "لديك صديق طلب من هذا الشخص" + thats_you: "!هذا أنت" + friend_request_pending: "طلبات صداقة معلقة" + you_have_a_friend_request_from_this_person: "لديك طلب صداقة من هذا الشخص" new: new_person: "شخص جديد" - back_to_list: "عودة إلى قائمة" + back_to_list: "عودة إلى القائمة" show: - last_seen: "%{how_long_ago} :المشاهدة الأخيرة" - friends_since: "%{how_long_ago} :أصدقاء منذ" + last_seen: "%{how_long_ago} :آخر مشاهدة" + friends_since: "%{how_long_ago} :صديق منذ" save: "حفظ" are_you_sure: "هل أنت متأكد؟" remove_friend: "إزالة صديق" @@ -194,13 +194,13 @@ ar: add_a_new_friend_to: "إضافة صديق جديد إلى" enter_a_diaspora_username: ":Diaspora أدخل اسم مستخدم" your_diaspora_username_is: "%{diaspora_handle} :هو Diaspora اسم المستخدم الخاص" - friends_username: "صديق اسم المستخدم" + friends_username: "اسم مستخدم الصديق" destroy: - success: ".أنت الآن أصدقاء" - error: "!الرجاء اختيار جانبا" - ignore: ".صديق تجاهل الطلب" + success: ".أنتم الآن أصدقاء" + error: "!الرجاء اختيار جانب" + ignore: ". تجاهل طلب الصداقة" create: - error: "!مع هذا البريد الإلكتروني diaspora لم يتم العثور على بذور" - already_friends: "!%{destination_url} كنت بالفعل مع أصدقاء" - success: ".%{destination_url} وأرسل طلب صداقة إلى" - horribly_wrong: ".ذهب شيء خاطئ" + error: "!في هذا البريد الإلكتروني diaspora لم يتم العثور على بذور" + already_friends: "!من قبل %{destination_url} أنت صديق مع" + success: ".%{destination_url} تم إرسال طلب صداقة ل" + horribly_wrong: ".فيه بلوى كبيرة حصلت" From 21772842be0e256ff70afbe96558bf09f98cf90f Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sun, 31 Oct 2010 13:20:00 +0100 Subject: [PATCH 24/56] bugfixes --- pkg/source/dist/.gitkeep | 0 pkg/ubuntu/diaspora-install | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 pkg/source/dist/.gitkeep diff --git a/pkg/source/dist/.gitkeep b/pkg/source/dist/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install index 4679c9f2b..fc4aebbf6 100755 --- a/pkg/ubuntu/diaspora-install +++ b/pkg/ubuntu/diaspora-install @@ -43,12 +43,19 @@ mkdir -p /var/lib/diaspora/tmp mkdir -p /var/run/diaspora mkdir -p /etc/diaspora +bundle='/usr/lib/diaspora-bundle' +[[ $(arch) == 'x86_64']] && bundle='/usr/lib64/diaspora-bundle' + ln -sf /var/log/diaspora ./master/log cp master/config/app_config.yml.example /etc/diaspora/app_config.yml ln -sf /etc/diaspora/app_config.yml master/config/app_config.yml ln -sf /var/lib/diaspora/uploads master/public/ ln -sf /var/lib/diaspora/tmp master -ln -sf /usr/lib/diaspora-bundle/vendor/bundle master/vendor +rm -rf master/vendor +ln -sf $bundle/vendor master/vendor + +ln -sf $bundle/Gemfile master/Gemfile +ln -sf $bundle/Gemfile.lock master/Gemfile.lock rm -rf /usr/share/doc/diaspora mkdir -p /usr/share/doc/diaspora From c07771b390ccbd3f3faba574a81bc23bae92450c Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sun, 31 Oct 2010 13:55:33 +0100 Subject: [PATCH 25/56] bugfix --- pkg/ubuntu/diaspora-install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install index fc4aebbf6..7090e775b 100755 --- a/pkg/ubuntu/diaspora-install +++ b/pkg/ubuntu/diaspora-install @@ -44,7 +44,8 @@ mkdir -p /var/run/diaspora mkdir -p /etc/diaspora bundle='/usr/lib/diaspora-bundle' -[[ $(arch) == 'x86_64']] && bundle='/usr/lib64/diaspora-bundle' +[ "$(arch | tr -d '\n')" = 'x86_64' ] && \ + bundle='/usr/lib64/diaspora-bundle' ln -sf /var/log/diaspora ./master/log cp master/config/app_config.yml.example /etc/diaspora/app_config.yml From cf82a0a9c8b1956a4761872f0e51e77e4ac2a542 Mon Sep 17 00:00:00 2001 From: "livefromthemoon@gmail.com" Date: Sun, 31 Oct 2010 21:55:49 +0100 Subject: [PATCH 26/56] Better to set the default locale in an initializer than in a before_filter --- app/controllers/application_controller.rb | 1 - config/initializers/locale.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3e32d4c27..2ab2838c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,7 +35,6 @@ class ApplicationController < ActionController::Base end def set_locale - I18n.default_locale = DEFAULT_LANGUAGE if current_user I18n.locale = current_user.language else diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 08d3923b0..395a55d68 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -4,4 +4,4 @@ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] -I18n.default_locale = :en +I18n.default_locale = DEFAULT_LANGUAGE From 9e27797092cb2ff5f886bdea294a625379a3a083 Mon Sep 17 00:00:00 2001 From: "livefromthemoon@gmail.com" Date: Sun, 31 Oct 2010 21:58:00 +0100 Subject: [PATCH 27/56] Fallback to default language when a translation is missing for the current language --- config/initializers/locale.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 395a55d68..c6cfa2e51 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -5,3 +5,4 @@ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] I18n.default_locale = DEFAULT_LANGUAGE +I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) From bbd0d350703ca307062da9a1045e844758cd69fa Mon Sep 17 00:00:00 2001 From: "livefromthemoon@gmail.com" Date: Sun, 31 Oct 2010 22:39:00 +0100 Subject: [PATCH 28/56] Fix some bugs for I18n fallbacks --- config/initializers/locale.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index c6cfa2e51..5d4a53a61 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -6,3 +6,6 @@ I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] I18n.default_locale = DEFAULT_LANGUAGE I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) +AVAILABLE_LANGUAGE_CODES.each do |c| + I18n.fallbacks[c.to_sym] = [c.to_sym, DEFAULT_LANGUAGE.to_sym, :en] +end \ No newline at end of file From d8376b5a8401f510129fe05a55af6c2a3018c5a0 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 1 Nov 2010 05:20:33 +0100 Subject: [PATCH 29/56] bugfix, refactor funcs --- pkg/bootstrap-fedora-diaspora.sh | 122 ++++++++++++++++++++++--------- pkg/source/funcs.sh | 31 +++++++- 2 files changed, 118 insertions(+), 35 deletions(-) diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 84352f12d..67ba40fc2 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -1,48 +1,102 @@ #!/bin/bash +# +# Install diaspora, its dependencies and start. +# +# Usage: bootstrap-fedora-diaspora.sh [external hostname] +# +# Must run as root -export DIASPORADIR=`pwd` +arg_hostname="$1" -echo "####" -echo "Installing build deps ..." -echo "####" -sleep 3 -su -c "yum install git bison svn autoconf sqlite-devel gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel ImageMagick git rubygems libxslt libxslt-devel libxml2 libxml2-devel openssl-devel" +. source/funcs.sh -echo "####" -echo "Installing RVM ..." -echo "####" -sleep 3 +test $UID = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} -mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install +yum install -y git bison svn autoconf sqlite-devel gcc-c++ patch \ + readline-devel zlib-devel libyaml-devel libffi-devel \ + ImageMagick git rubygems libxslt-devel libxml2-devel \ + openssl-devel mongodb-server wget openssh-clients -echo "####" -echo "Installing RVM into bashrc and sourcing bash ..." -echo "####" -sleep 3 +getent group diaspora >/dev/null || groupadd diaspora +getent passwd diaspora >/dev/null || { + useradd -g diaspora -s /bin/bash -m diaspora + echo "Created user diaspora" +} -if [[ `grep -l "rvm/scripts/rvm" $HOME/.bashrc | wc -l` -eq 0 ]]; then - echo 'if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi' >> $HOME/.bashrc +su - diaspora <> \$HOME/.bashrc + } +} + +source \$HOME/.bashrc + +[ -d .ssh ] || { + ssh-keygen -q + echo "StrictHostKeyChecking no" > .ssh/config + chmod 600 .ssh/config +} + +ruby=\$(which ruby) || ruby="" + +if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then + echo '#### Installing ruby (will take forever) ... ####' + rvm install ruby-1.8.7-p302 + rvm --default ruby-1.8.7 + + echo "#### Installing bundler ... ####" + gem install bundler fi -source $HOME/.bashrc -echo "####" -echo "Installing ruby (will take forever) ..." -echo "####" -sleep 3 +echo '### Clone diapora, install bundle. ###' +git clone git@github.com:diaspora/diaspora.git +cd diaspora +bundle install -rvm install ruby-1.8.7-p302 -rvm --default ruby-1.8.7 +#Configure diaspora -echo "####" -echo "Installing bundler ..." -echo "####" -sleep 3 +source pkg/source/funcs.sh +init_appconfig config/app_config.yml "\$arg_hostname" -gem install bundler +# Install DB setup +echo "Setting up DB..." +if bundle exec rake db:seed:dev ; then + cat <<- EOM + DB ready. Login -> tom and password -> evankorth. + More details ./diaspora/db/seeds/tom.rb. and ./diaspora/db/seeds/dev.rb. + EOM +else + cat <<- EOM + Database config failed. You might want to remove all db files with + 'rm -rf /var/lib/mongodb/*' and/or reset the config file by + 'cp config/app_config.yml.example config/app_config.yml' before + making a new try. Also, make sure the mongodb server is running + e. g., by running 'service mongodb status'. + EOM +fi + +# Run appserver +echo "Starting server" +script/server + +EOF -echo "####" -echo "Installing deps with bundle ..." -echo "####" -sleep 3 -pushd $DIASPORADIR && bundle install && popd diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh index bc9edd862..8fb0ee937 100644 --- a/pkg/source/funcs.sh +++ b/pkg/source/funcs.sh @@ -59,7 +59,7 @@ function checkout() git clone --quiet $GIT_REPO; ( cd diaspora; - git checkout Gemfile + git checkout Gemfile Gemfile.lock git remote add upstream \ git://github.com/diaspora/diaspora.git for p in ../../*.patch; do @@ -77,3 +77,32 @@ function checkout() ) } +function init_appconfig +# Edit pod_url in hostname +# Silently uses argumetn if present, else run dialog. +# Usage: init_appconfig [hostname] +{ + config=$1 + arg_hostanme="$2" + hostname=$( awk '/pod_url:/ { print $2; exit }' <$config ) + + if [ -n "$arg_hostname" ]; then + sed -i "/pod_url:/s|$hostname|$arg_hostname|g" $config && \ + echo "config/app_config.yml updated." + return 0 + else + while : ; do + echo "Current hostname is \"$hostname\"" + echo -n "Enter new hostname [$hostname] :" + read new_hostname garbage + echo -n "Use \"$new_hostname\" as pod_url (Yes/No) [Yes]? :" + read yesno garbage + [ "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" ] && { + sed -i "/pod_url:/s|$hostname|$new_hostname|g" $config && + echo "config/app_config.yml updated." + break + } + done + fi +} + From 23e566ce2e663469f45f89300825f4e3a4fd9297 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 1 Nov 2010 06:13:31 +0100 Subject: [PATCH 30/56] bugfix --- pkg/.gitignore | 1 + pkg/bootstrap-fedora-diaspora.sh | 17 ++++++++++------- pkg/source/funcs.sh | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/.gitignore b/pkg/.gitignore index 1521c8b76..470b7660b 100644 --- a/pkg/.gitignore +++ b/pkg/.gitignore @@ -1 +1,2 @@ dist +*.log diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 67ba40fc2..34b32eb1b 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -5,10 +5,8 @@ # Usage: bootstrap-fedora-diaspora.sh [external hostname] # # Must run as root - -arg_hostname="$1" - -. source/funcs.sh +GIT_REPO='git@github.com:leamas/diaspora.git' +DIASPORA_HOSTNAME='mumin.dnsalias.net' test $UID = "0" || { echo "You need to be root to do this, giving up" @@ -67,14 +65,19 @@ if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then fi echo '### Clone diapora, install bundle. ###' -git clone git@github.com:diaspora/diaspora.git +rm -rf diaspora +git clone $GIT_REPO cd diaspora +echo "PWD: \$PWD" +echo "pkg: \$(ls pkg)" +echo "source: \$(ls pkg/source)" +source pkg/source/funcs.sh bundle install #Configure diaspora -source pkg/source/funcs.sh -init_appconfig config/app_config.yml "\$arg_hostname" +cp config/app_config.yml.example config/app_config.yml +init_appconfig config/app_config.yml "$DIASPORA_HOSTNAME" # Install DB setup echo "Setting up DB..." diff --git a/pkg/source/funcs.sh b/pkg/source/funcs.sh index 8fb0ee937..e47af236d 100644 --- a/pkg/source/funcs.sh +++ b/pkg/source/funcs.sh @@ -83,7 +83,7 @@ function init_appconfig # Usage: init_appconfig [hostname] { config=$1 - arg_hostanme="$2" + arg_hostname="$2" hostname=$( awk '/pod_url:/ { print $2; exit }' <$config ) if [ -n "$arg_hostname" ]; then From 85f94a2b002f2b2ed8a98b33b5fc9c7674dc08f1 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Sat, 30 Oct 2010 13:18:56 +0200 Subject: [PATCH 31/56] Refactored into separate generic, source dir + distro addons. --- pkg/bootstrap-fedora-diaspora.sh | 2 +- pkg/fedora/README.md | 6 ++++++ pkg/fedora/dist | 1 - pkg/source/dist/.gitkeep | 0 pkg/ubuntu/add-bundle.diff | 11 ----------- vendor/plugins/.gitkeep | 0 6 files changed, 7 insertions(+), 13 deletions(-) delete mode 120000 pkg/fedora/dist delete mode 100644 pkg/source/dist/.gitkeep delete mode 100644 pkg/ubuntu/add-bundle.diff delete mode 100644 vendor/plugins/.gitkeep diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 34b32eb1b..41d317a34 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -26,7 +26,7 @@ getent passwd diaspora >/dev/null || { su - diaspora < Date: Mon, 1 Nov 2010 06:59:41 +0100 Subject: [PATCH 32/56] pkg bugfixes --- pkg/bootstrap-fedora-diaspora.sh | 73 ++++++++++++++++++++------------ pkg/fedora/prepare-rpm.sh | 6 ++- pkg/source/dist/.gitkeep | 0 3 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 pkg/source/dist/.gitkeep diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 41d317a34..a8a7c2f41 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -2,21 +2,42 @@ # # Install diaspora, its dependencies and start. # -# Usage: bootstrap-fedora-diaspora.sh [external hostname] +# Usage: pkg/bootstrap-fedora-diaspora.sh [external hostname] +# +# Synopsis: +# +# $ git clone git@github.com:diaspora/diaspora.git +# $ cd diaspora +# $ sudo pkg/bootstrap-rffedora-diaspora.sh +# +# Unless already existing, the diaspora user is created. +# The directory the scripts is invoked from is copied to +# diasporas's home dir, populated and configured and finally +# acts as a base for running diaspora servers. +# +# Script is designed not to make any changes in invoking +# caller's environment. +# user. # # Must run as root + GIT_REPO='git@github.com:leamas/diaspora.git' -DIASPORA_HOSTNAME='mumin.dnsalias.net' +DIASPORA_HOSTNAME=${1:-'mumin.dnsalias.net'} test $UID = "0" || { echo "You need to be root to do this, giving up" exit 2 } -yum install -y git bison svn autoconf sqlite-devel gcc-c++ patch \ +[[ -d config && -d script ]] || { + echo Error: "this is not a diaspora base directory" + exit 3 +} +yum install -y git bison svn sqlite-devel gcc-c++ patch \ readline-devel zlib-devel libyaml-devel libffi-devel \ - ImageMagick git rubygems libxslt-devel libxml2-devel \ - openssl-devel mongodb-server wget openssh-clients + ImageMagick rubygems libxslt-devel libxml2-devel \ + openssl-devel mongodb-server wget openssh-clients \ + make autoconf automake getent group diaspora >/dev/null || groupadd diaspora getent passwd diaspora >/dev/null || { @@ -24,10 +45,27 @@ getent passwd diaspora >/dev/null || { echo "Created user diaspora" } -su - diaspora < .ssh/config - chmod 600 .ssh/config -} - ruby=\$(which ruby) || ruby="" if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then @@ -64,22 +96,8 @@ if [[ -z "\$ruby" || ("\${ruby:0:4}" == "/usr") ]]; then gem install bundler fi -echo '### Clone diapora, install bundle. ###' -rm -rf diaspora -git clone $GIT_REPO -cd diaspora -echo "PWD: \$PWD" -echo "pkg: \$(ls pkg)" -echo "source: \$(ls pkg/source)" -source pkg/source/funcs.sh bundle install -#Configure diaspora - -cp config/app_config.yml.example config/app_config.yml -init_appconfig config/app_config.yml "$DIASPORA_HOSTNAME" - -# Install DB setup echo "Setting up DB..." if bundle exec rake db:seed:dev ; then cat <<- EOM @@ -96,7 +114,6 @@ else EOM fi -# Run appserver echo "Starting server" script/server diff --git a/pkg/fedora/prepare-rpm.sh b/pkg/fedora/prepare-rpm.sh index 5d03f8328..908c1844a 100755 --- a/pkg/fedora/prepare-rpm.sh +++ b/pkg/fedora/prepare-rpm.sh @@ -128,6 +128,8 @@ function usage() -h Print this message. -r release For prepare, mark with release nr, defaults to 1. + -u uri Git repository URI, defaults to + $GIT_REPO. Symlink bundle and source tarballs to rpm source dir, create patched rpm spec files. @@ -140,7 +142,7 @@ function usage() commit='HEAD' BUNDLE_FIX='no' -while getopts ":r:h" opt +while getopts ":r:u:h" opt do case $opt in r) RELEASE="$OPTARG:" @@ -148,6 +150,8 @@ do h) usage exit 0 ;; + u) GIT_REPO="$OPTARG" + ;; *) usage exit 2 ;; diff --git a/pkg/source/dist/.gitkeep b/pkg/source/dist/.gitkeep new file mode 100644 index 000000000..e69de29bb From 168843bcd502f2b5a0688cf4af370e6297da27bd Mon Sep 17 00:00:00 2001 From: Gabriel Gilder Date: Thu, 28 Oct 2010 20:57:18 -0700 Subject: [PATCH 33/56] redirecting to :back instead of manage page on failed aspect creation +spec --- app/controllers/aspects_controller.rb | 2 +- spec/controllers/aspects_controller_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index aadbf1ecf..9f2942f6c 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -24,7 +24,7 @@ class AspectsController < ApplicationController respond_with @aspect else flash[:error] = I18n.t('aspects.create.failure') - redirect_to aspects_manage_path + redirect_to :back end end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index d62d91f5b..7c3c0dda9 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -16,6 +16,7 @@ describe AspectsController do friend_users(@user,@aspect, @user2, @aspect2) @contact = @user.contact_for(@user2.person) sign_in :user, @user + request.env["HTTP_REFERER"] = 'http://' + request.host end describe "#index" do @@ -44,9 +45,9 @@ describe AspectsController do post :create, "aspect" => {"name" => ""} @user.reload.aspects.count.should == 2 end - it "goes back to manage aspects" do + it "goes back to the page you came from" do post :create, "aspect" => {"name" => ""} - response.should redirect_to(aspects_manage_path) + response.should redirect_to(:back) end end end From b0b1fa51c22eaa7af7b5d7ff181c86ded2610bf9 Mon Sep 17 00:00:00 2001 From: Himanshu Chhetri Date: Fri, 29 Oct 2010 20:31:45 -0700 Subject: [PATCH 34/56] Use FileUtils for all file operations. Also uses Kernel.system to execute shell commands in a secure fashion. --- lib/collect_user_photos.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/collect_user_photos.rb b/lib/collect_user_photos.rb index 4b0fedea2..d95aa386a 100644 --- a/lib/collect_user_photos.rb +++ b/lib/collect_user_photos.rb @@ -17,12 +17,12 @@ module PhotoMover current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}" new_photo_location = "#{album_dir}/#{photo.image_filename}" - `cp #{current_photo_location} #{new_photo_location}` + FileUtils::cp current_photo_location new_photo_location end end - `tar cf #{user.id}.tar #{user.id}` - `rm -r #{user.id}` + system("tar", "cf #{user.id}.tar #{user.id}") + FileUtils::rm_r user.id, :secure => true, :force => true "#{Rails.root}/#{temp_dir}.tar" end From f33fded40053d96ec3f982d523908bb7a029fba2 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Sun, 31 Oct 2010 22:49:40 -0700 Subject: [PATCH 35/56] Refactor aspect cucumber feature - now happy path only. --- features/manages_aspects.feature | 14 ++++++++++++++ features/user_creates_an_aspect.feature | 21 --------------------- 2 files changed, 14 insertions(+), 21 deletions(-) create mode 100644 features/manages_aspects.feature delete mode 100644 features/user_creates_an_aspect.feature diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature new file mode 100644 index 000000000..74f6744f4 --- /dev/null +++ b/features/manages_aspects.feature @@ -0,0 +1,14 @@ +@aspects @javascript +Feature: User manages aspects + In order to share with a limited group + As a User + I want to create new aspects + + Scenario: creating an aspect + Given I am signed in + When I follow "Manage" in the header + And I follow "Add a new aspect" + And I fill in "Name" with "Dorm Mates" in the modal window + And I press "Create" in the modal window + Then I should see "Dorm Mates" in the header + And I should see "Your aspect 'Dorm Mates' is empty." diff --git a/features/user_creates_an_aspect.feature b/features/user_creates_an_aspect.feature deleted file mode 100644 index d611d412f..000000000 --- a/features/user_creates_an_aspect.feature +++ /dev/null @@ -1,21 +0,0 @@ -@aspects @javascript -Feature: User creates an aspect - In order to share with a limited group - As a User - I want to create a new aspect - - Background: - Given I am signed in - And I follow "Manage" in the header - And I follow "Add a new aspect" - - Scenario: success - Given I fill in "Name" with "Dorm Mates" in the modal window - When I press "Create" in the modal window - Then I should see "Dorm Mates" in the header - And I should see "Your aspect 'Dorm Mates' is empty." - - Scenario: I omit the name - Given I fill in "Name" with "" in the modal window - When I press "Create" in the modal window - Then I should see "Aspect creation failed." From 7f7f160ca1e3343444b450135cff9d162f2c03ae Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Sun, 31 Oct 2010 22:50:20 -0700 Subject: [PATCH 36/56] Add feature for skipping the setup wizard. --- features/signs_up.feature | 16 ++++------------ features/step_definitions/custom_web_steps.rb | 4 ++++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/features/signs_up.feature b/features/signs_up.feature index e64b066e7..d449034cf 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -1,7 +1,7 @@ @javascript Feature: new user registration - Scenario: new user sees profile wizard + Background: When I go to the new user registration page And I fill in "Username" with "ohai" And I fill in "Email" with "ohai@example.com" @@ -11,6 +11,7 @@ Feature: new user registration Then I should be on the getting started page And I should see "Welcome to Diaspora!" + Scenario: new user goes through the setup wizard When I fill in "person_profile_first_name" with "O" And I fill in "person_profile_last_name" with "Hai" And I press "Save and continue" @@ -32,17 +33,8 @@ Feature: new user registration Then I should be on the home page And I should see "We know you have friends, bring them to Diaspora!" - @wip - Scenario: new user can skip the profile wizard - When I go to the new user registration page - And I fill in "Username" with "ohai" - And I fill in "Email" with "ohai@example.com" - And I fill in "Password" with "secret" - And I fill in "Password confirmation" with "secret" - And I press "Sign up" - Then I should be on the getting started page - And I should see "Welcome to Diaspora!" - + Scenario: new user skips the setup wizard When I follow "skip getting started" + And I wait for the home page to load Then I should be on the home page And I should see "We know you have friends, bring them to Diaspora!" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index d213cbf4d..c98150d3d 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -20,4 +20,8 @@ Then /^I should see "([^\"]*)" in the main content area$/ do |stuff| within("#stream") do Then "I should see #{stuff}" end +end + +When /^I wait for the home page to load$/ do + wait_until { current_path == root_path } end \ No newline at end of file From fb145beb9a25e9182981389e251c7399214d6aa8 Mon Sep 17 00:00:00 2001 From: Sarah Allen Date: Thu, 28 Oct 2010 21:28:20 -0700 Subject: [PATCH 37/56] Rails.env is a string, not a symbol --- config/initializers/_load_app_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 723e38525..b66b0c8f9 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -23,4 +23,4 @@ end APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/' -puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != :test +puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != "test" From f693a97bf3d7db77835b6a534fee7c106193be85 Mon Sep 17 00:00:00 2001 From: Curtis J Schofield Date: Thu, 28 Oct 2010 21:02:58 -0700 Subject: [PATCH 38/56] i put in a dash --- config/locales/diaspora/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index d61abb8a2..837ecf8b8 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -91,7 +91,7 @@ en: your_albums: "Your Albums" aspects: no_friends_message: - nobody: "We know you have friends, bring them to Diaspora!" + nobody: "We know you have friends — bring them to Diaspora!" nobody_in_aspect: "Your aspect '%{aspect_name}' is empty." add_friend: "Add a friend" add_friend_to: "Add someone to %{aspect_name}" From 1a32766fb06af55fc49004ba4cae049017a343ef Mon Sep 17 00:00:00 2001 From: J David Eisenberg Date: Sat, 30 Oct 2010 22:01:02 -0700 Subject: [PATCH 39/56] Issue #492: Informal, vague description when signing up as a new user --- app/views/users/getting_started.html.haml | 2 +- config/locales/diaspora/en.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/users/getting_started.html.haml b/app/views/users/getting_started.html.haml index 5edb3e67a..c90a3fadd 100644 --- a/app/views/users/getting_started.html.haml +++ b/app/views/users/getting_started.html.haml @@ -30,7 +30,7 @@ %h1{:style => "text-align:right;"} = "Welcome to Diaspora!" .description - Do the stuff below to further complete some things. + =t('.signup_steps') %h3{:style => "text-align:right;"} = link_to "Edit your profile", getting_started_path(:step => 1) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 837ecf8b8..ca1d8f471 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -143,6 +143,7 @@ en: cancel: "Cancel" destroy: "Account successfully closed." getting_started: + signup_steps: "Complete your sign-up by doing these things:" 'step_1': albums: "Albums" you_dont_have_any_photos: "You don't have any photos! Go to the" From 9a56296214c6ceee87f76ccf253364299302b22a Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 1 Nov 2010 00:55:16 -0700 Subject: [PATCH 40/56] Forgot to change spelling in feature --- features/signs_up.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/signs_up.feature b/features/signs_up.feature index d449034cf..80e32934f 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -31,10 +31,10 @@ Feature: new user registration When I follow "Continue on to your everyone page, an overview of all of your aspects." Then I should be on the home page - And I should see "We know you have friends, bring them to Diaspora!" + And I should see "bring them to Diaspora!" Scenario: new user skips the setup wizard When I follow "skip getting started" And I wait for the home page to load Then I should be on the home page - And I should see "We know you have friends, bring them to Diaspora!" + And I should see "bring them to Diaspora!" From 65419e423a5106b3de4dc34588d5fb883d6fa1f1 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Sun, 31 Oct 2010 22:54:26 +0100 Subject: [PATCH 41/56] Added missing strings to swedish translation --- config/locales/devise/devise.sv.yml | 24 +++++++-- config/locales/diaspora/sv.yml | 82 +++++++++++++++++++++++------ 2 files changed, 86 insertions(+), 20 deletions(-) diff --git a/config/locales/devise/devise.sv.yml b/config/locales/devise/devise.sv.yml index 0366d0c49..419d90deb 100644 --- a/config/locales/devise/devise.sv.yml +++ b/config/locales/devise/devise.sv.yml @@ -8,6 +8,7 @@ sv: errors: messages: not_found: "kan ej hitta" + already_confirmed: "är redan bekräftad" not_locked: "var ej låst" devise: @@ -15,11 +16,16 @@ sv: unauthenticated: 'Du måste logga in innan du kan fortsätta.' unconfirmed: 'Du måste verifiera ditt konto innan du kan fortsätta.' locked: 'Ditt konto är låst.' - invalid: 'Felaktig användare eller lösenord.' + invalid: 'Felaktigt användarnamn eller lösenord.' invalid_token: 'Ogiltig identifiering.' timeout: 'Din session är avslutad, var vänlig logga in igen.' inactive: 'Ditt konto är inte aktiverat.' sessions: + new: + login: 'Logga in' + username: 'Användarnamn' + password: 'Lösenord' + sign_in: 'Logga in' signed_in: 'Inloggning ok.' signed_out: 'Utloggning ok.' passwords: @@ -40,6 +46,16 @@ sv: invitation_token_invalid: 'Denna inbjudan är ej giltig!' updated: 'Ditt lösenord är nu inställt och du är inloggad.' mailer: - confirmation_instructions: 'Instruktioner för att verifiera ditt konto.' - reset_password_instructions: 'Instruktioner för att återställa ditt lösenord.' - unlock_instructions: 'Instruktioner för att låsa upp ditt konto.' + confirmation_instructions: + subject: 'Instruktioner för att verifiera ditt konto.' + reset_password_instructions: + subject: 'Instruktioner för att återställa ditt lösenord.' + unlock_instructions: + subject: 'Instruktioner för att låsa upp ditt konto.' + invitation: + subject: 'En vän vill att du ska gå med i Diaspora!' + shared: + links: + sign_in: 'Logga in' + sign_up: 'Registrera dig' + forgot_your_password: 'Glömt ditt lösenord?' diff --git a/config/locales/diaspora/sv.yml b/config/locales/diaspora/sv.yml index 968a3cafa..d5b18e6fa 100644 --- a/config/locales/diaspora/sv.yml +++ b/config/locales/diaspora/sv.yml @@ -27,6 +27,8 @@ sv: models: user: attributes: + person: + invalid: "är ogiltigt" username: taken: "är redan taget" email: @@ -35,7 +37,6 @@ sv: attributes: diaspora_handle: taken: "är redan taget" - hello: "Hej världen!" application: helper: @@ -54,7 +55,10 @@ sv: people_on_pod_are_aware_of: " personer på denna plats är medvetna om att" layouts: application: + view_profile: "visa profil" edit_profile: "ändra profil" + account_settings: "kontoinstallningar" + search: "Search" logout: "logga ut" shared: aspect_nav: @@ -81,8 +85,10 @@ sv: updated: "uppdaterad" by: "av" edit: + album_name: "Namn på fotoalbum" editing: "Ändrar" updated: "uppdaterad" + update_album: "Uppdatera fotoalbum" are_you_sure: "Är du säker?" delete_album: "Ta bort fotoalbum" cancel: "Avbryt" @@ -117,6 +123,7 @@ sv: ignore_remove: "Ignorera/Ta bort" new_aspect: add_a_new_aspect: "Lägg till ny sida" + name: "Namn" create: "Skapa" create: success: "Klicka på plustecknet till höger för att välja vilka som kan se din nya sida." @@ -137,19 +144,26 @@ sv: users: edit: editing_profile: "Ändrar profil" - profile: + invite_friends: "Bjud in en vän" + are_you_sure: "Är du säker?" + export_data: "Exportera data" + close_account: "Stäng kontot" + change_language: "Ändra språk" + change_password: "Ändra lösenord" + new_password: "Nytt lösenord" + password_confirmation: "Bekräfta lösenord" + settings: "Inställningar" + profile: "Profil" + account: "Konto" + services: "Tjänster" cancel: "Avbryt" - update_profile: "Uppdatera Profil" - home: "Hem" - diaspora_username: "Diaspora-användarnamn:" - info: "Info" - picture: "Profilbild" - editing_profile: "Ändrar profil" - albums: "Album" - you_dont_have_any_photos: "Du har inga foton! Gå till" - page_to_upload_some: "sidan för att ladda upp några." - or: "eller" destroy: "Ditt konto är nu stängt." + getting_started: + 'step_1': + albums: "Fotoalbum" + you_dont_have_any_photos: "Du har inga foton! Gå till" + page_to_upload_some: "sidan för att ladda upp några." + or: "eller" comments: comment: ago: "sedan" @@ -189,6 +203,13 @@ sv: registrations: new: sign_up: "Registrera dig" + sign_up_for_diaspora: "Gå med i Diaspora" + upload_existing_account: "Ladda upp ett befintligt Diaspora-konto" + upload: "Ladda upp" + username: "Användarnamn" + email: "E-post address" + password: "Lösenord" + password_confirmation: "Bekräfta lösenord" create: success: "Du har nu gått med i Diaspora!" invitations: @@ -232,10 +253,6 @@ sv: new: new_person: "Ny person" back_to_list: "Tillbaka till listan" - edit: - cancel: "Avbryt" - or: "eller" - update_profile: "Uppdatera profil" show: last_seen: "senast sedd: %{how_long_ago}" friends_since: "vänner sedan: %{how_long_ago}" @@ -243,12 +260,39 @@ sv: are_you_sure: "Är du säker?" remove_friend: "ta bort vän" no_posts: "ingenting att visa!" + add_friend: "lägg till en vän" + edit: + settings: "Inställningar" + your_profile: "Din profil" + your_name: "Ditt namn" + first_name: "Förnamn" + last_name: "Efternamn" + your_gender: "Ditt kön" + your_birthday: "Din födelsedag" + your_bio: "Din biografi" + fill_me_out: "Fyll i mig" + your_photo: "Ditt foto" + profile: "Profil" + account: "Konto" + services: "Tjänster" + cancel: "Avbryt" + update_profile: "Uppdatera profil" + home: "Hem" + diaspora_username: "Användarnamn:" + info: "Info" + picture: "Foto" + editing_profile: "Ändrar profil" + albums: "Fotoalbum" + you_dont_have_any_photos: "Du har inga foton! Gå till" + page_to_upload_some: "sidan för att ladda upp några." + or: "eller" requests: new_request: add_a_new_friend_to: "Lägg till en vän till" enter_a_diaspora_username: "Ange ett användarnamn:" your_diaspora_username_is: "Din Diaspora-adress är: %{diaspora_handle}" friends_username: "Vännens Diaspora-adress" + create_request: "Skapa förfrågan" destroy: success: "Ni är nu vänner." error: "Var god välj en aspekt!" @@ -261,6 +305,12 @@ sv: already_friends: "Du är redan vän med %{destination_url}!" success: "En vänförfrågan har skickats till %{destination_url}." horribly_wrong: "Nu gick något rejält fel här." + services: + index: + settings: "Inställningar" + profile: "Profil" + account: "Konto" + services: "Tjänster" # The following is from the rails-i18n project at http://github.com/svenfuchs/rails-i18n From be4f33bf67849d9a3ae09387182d5e5303727cbe Mon Sep 17 00:00:00 2001 From: Gabriel Gilder Date: Thu, 28 Oct 2010 20:57:18 -0700 Subject: [PATCH 42/56] redirecting to :back instead of manage page on failed aspect creation +spec --- pkg/ubuntu/dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ubuntu/dist b/pkg/ubuntu/dist index 2fb4d8549..378798d00 120000 --- a/pkg/ubuntu/dist +++ b/pkg/ubuntu/dist @@ -1 +1 @@ -../source/dist/ \ No newline at end of file +../source/dist \ No newline at end of file From 2c8f6c27ba86819fa7b12880ec9401ddeb8edef6 Mon Sep 17 00:00:00 2001 From: Himanshu Chhetri Date: Fri, 29 Oct 2010 20:31:45 -0700 Subject: [PATCH 43/56] Use FileUtils for all file operations. Also uses Kernel.system to execute shell commands in a secure fashion. --- pkg/ubuntu/dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ubuntu/dist b/pkg/ubuntu/dist index 378798d00..2fb4d8549 120000 --- a/pkg/ubuntu/dist +++ b/pkg/ubuntu/dist @@ -1 +1 @@ -../source/dist \ No newline at end of file +../source/dist/ \ No newline at end of file From bf4f402c309737deede37ba749ca0f64206c4101 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 1 Nov 2010 15:43:53 +0100 Subject: [PATCH 44/56] pkg bugfixes --- pkg/bootstrap-fedora-diaspora.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index a8a7c2f41..8230b01fa 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -33,10 +33,10 @@ test $UID = "0" || { echo Error: "this is not a diaspora base directory" exit 3 } -yum install -y git bison svn sqlite-devel gcc-c++ patch \ +yum install -y git bison sqlite-devel gcc-c++ patch \ readline-devel zlib-devel libyaml-devel libffi-devel \ - ImageMagick rubygems libxslt-devel libxml2-devel \ - openssl-devel mongodb-server wget openssh-clients \ + ImageMagick libxslt-devel libxml2-devel \ + openssl-devel mongodb-server wget \ make autoconf automake getent group diaspora >/dev/null || groupadd diaspora @@ -54,17 +54,13 @@ mkdir $home/diaspora cp -ar * $home/diaspora chown -R diaspora $home/diaspora +service mongod start + su - diaspora << EOF #set -x cd diaspora -#Configure diaspora -cp config/app_config.yml.example config/app_config.yml -source source/funcs.sh -init_appconfig config/app_config.yml "$DIASPORA_HOSTNAME" - - [ -e "\$HOME/.rvm/scripts/rvm" ] || { echo '#### Installing rvm ####' wget http://rvm.beginrescueend.com/releases/rvm-install-head @@ -98,6 +94,12 @@ fi bundle install +#Configure diaspora +cp config/app_config.yml.example config/app_config.yml +source pkg/source/funcs.sh +init_appconfig config/app_config.yml "$DIASPORA_HOSTNAME" + + echo "Setting up DB..." if bundle exec rake db:seed:dev ; then cat <<- EOM From 488df6eaa0813fcfa5acaabf45ccdcc78fff868d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 1 Nov 2010 11:35:37 -0700 Subject: [PATCH 45/56] RS IZ a good test to overwrite ids --- app/controllers/status_messages_controller.rb | 13 +---------- .../status_message_controller_spec.rb | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index a5c018af2..92bda1a36 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -13,9 +13,7 @@ class StatusMessagesController < ApplicationController public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag - data = clean_hash params[:status_message] - message = params[:status_message][:message] - status_message = current_user.post(:status_message, data) + status_message = current_user.post(:status_message, params[:status_message]) render :nothing => true end @@ -29,13 +27,4 @@ class StatusMessagesController < ApplicationController @status_message = current_user.find_visible_post_by_id params[:id] respond_with @status_message end - - private - def clean_hash(params) - return { - :message => params[:message], - :to => params[:to], - :public => params[:public] - } - end end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index c1fff84ca..100d60ebe 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -16,7 +16,12 @@ describe StatusMessagesController do end describe '#create' do - let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}} + let(:status_message_hash) { + {:status_message =>{ + :public =>"true", + :message =>"facebook, is that you?", + :to =>"#{aspect.id}"}} + } context "posting out to facebook" do let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s } @@ -27,10 +32,22 @@ describe StatusMessagesController do end it 'should not post to facebook when public is not set' do - status_message_hash['status_message']['public'] = 'false' + status_message_hash[:status_message][:public] = 'false' user.should_not_receive(:post_to_facebook) post :create, status_message_hash end + it "doesn't overwrite person_id" do + new_user = make_user + status_message_hash[:status_message][:person_id] = new_user.person.id + post :create, status_message_hash + StatusMessage.find_by_message(status_message_hash[:status_message][:message]).person_id.should == user.person.id + end + it "doesn't overwrite id" do + old_status_message = user.post(:status_message, :message => "hello", :to => aspect.id) + status_message_hash[:status_message][:id] = old_status_message.id + post :create, status_message_hash + old_status_message.reload.message.should == 'hello' + end end context "posting to twitter" do @@ -42,7 +59,7 @@ describe StatusMessagesController do end it 'should not post to twitter when public in not set' do - status_message_hash['status_message']['public'] = 'false' + status_message_hash[:status_message][:public] = 'false' user.should_not_receive(:post_to_twitter) post :create, status_message_hash end From 28fc8ac762aa733214ff6f3ff319dd6d8bf00eed Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 1 Nov 2010 11:59:05 -0700 Subject: [PATCH 46/56] remove local dist folder --- pkg/ubuntu/dist/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 pkg/ubuntu/dist/.gitkeep diff --git a/pkg/ubuntu/dist/.gitkeep b/pkg/ubuntu/dist/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 9d273c6d24648a0283bda65643c42b80920e227e Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 1 Nov 2010 12:31:00 -0700 Subject: [PATCH 47/56] Now expecting a 500 on someone passing an id to create, should really be a 422 --- app/models/photo.rb | 4 ++-- app/models/post.rb | 3 ++- app/models/status_message.rb | 2 ++ app/models/user.rb | 9 ++++++--- spec/controllers/status_message_controller_spec.rb | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/photo.rb b/app/models/photo.rb index d60bd3645..bce9d469d 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -29,9 +29,9 @@ class Photo < Post validates_with PhotoAlbumValidator - before_destroy :ensure_user_picture + attr_accessible :caption - attr_protected :person + before_destroy :ensure_user_picture def self.instantiate(params = {}) image_file = params.delete(:user_file) diff --git a/app/models/post.rb b/app/models/post.rb index 5b49dacd5..298d25b5f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -32,11 +32,12 @@ class Post before_destroy :propogate_retraction after_destroy :destroy_comments + attr_accessible :user_refs def self.instantiate params new_post = self.new params.to_hash new_post.person = params[:person] new_post.public = params[:public] - new_post.save + new_post.diaspora_handle = new_post.person.diaspora_handle new_post end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index a0f8ca002..d67bba6fb 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -11,6 +11,8 @@ class StatusMessage < Post key :message, String validates_presence_of :message + attr_accessible :message + def to_activity <<-XML diff --git a/app/models/user.rb b/app/models/user.rb index 1f1333e56..bb465e78a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -145,6 +145,7 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) post = build_post(class_name, options) + post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) push_to_aspects(post, aspect_ids) @@ -201,9 +202,11 @@ class User model_class = class_name.to_s.camelize.constantize post = model_class.instantiate(options) - post.save - self.raw_visible_posts << post - self.save + if post.save + raise 'MongoMapper failed to catch a failed save' unless post.id + self.raw_visible_posts << post + self.save + end post end diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 100d60ebe..059fe5fb4 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -45,7 +45,7 @@ describe StatusMessagesController do it "doesn't overwrite id" do old_status_message = user.post(:status_message, :message => "hello", :to => aspect.id) status_message_hash[:status_message][:id] = old_status_message.id - post :create, status_message_hash + lambda {post :create, status_message_hash}.should raise_error /failed save/ old_status_message.reload.message.should == 'hello' end end From d979ad4fc0f2e8f928ddb3901716d103d6e1ac93 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Mon, 1 Nov 2010 22:05:51 +0100 Subject: [PATCH 48/56] Documentation update --- pkg/README.md | 2 ++ pkg/bootstrap-fedora-diaspora.sh | 11 +++++--- pkg/fedora/README.md | 48 +++++--------------------------- pkg/ubuntu/README.md | 2 +- 4 files changed, 17 insertions(+), 46 deletions(-) diff --git a/pkg/README.md b/pkg/README.md index 8b65d479c..aa99e0ad7 100644 --- a/pkg/README.md +++ b/pkg/README.md @@ -5,6 +5,8 @@ This directory contains stuff to install and run diaspora. - ubuntu-setup.bash: script which installs all of Diasporas dependencies and starts the server. +- bootstrap-fedora-diaspora.sh. does the same for Fedora. + - source: stuff to package Diaspora into traditional tarballs which can be installed. diff --git a/pkg/bootstrap-fedora-diaspora.sh b/pkg/bootstrap-fedora-diaspora.sh index 8230b01fa..7c0d267d0 100755 --- a/pkg/bootstrap-fedora-diaspora.sh +++ b/pkg/bootstrap-fedora-diaspora.sh @@ -4,11 +4,15 @@ # # Usage: pkg/bootstrap-fedora-diaspora.sh [external hostname] # -# Synopsis: -# +# Synopsis, install: # $ git clone git@github.com:diaspora/diaspora.git # $ cd diaspora -# $ sudo pkg/bootstrap-rffedora-diaspora.sh +# $ sudo pkg/bootstrap-fedora-diaspora.sh +# +# New start: +# $ sudo su - diaspora +# $ cd diaspora +# $ script/server # # Unless already existing, the diaspora user is created. # The directory the scripts is invoked from is copied to @@ -17,7 +21,6 @@ # # Script is designed not to make any changes in invoking # caller's environment. -# user. # # Must run as root diff --git a/pkg/fedora/README.md b/pkg/fedora/README.md index 9b100ddb1..e926f5a4d 100644 --- a/pkg/fedora/README.md +++ b/pkg/fedora/README.md @@ -27,7 +27,7 @@ Bootstrap the distribution from git: Create and install the diaspora bundle and application in diaspora/pkg/source according to -[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) +[source README](http://github.com/diaspora/diaspora/tree/master/pkg/source/) Setup links from tarballs to RPM source directory and create spec files: % ./prepare-rpm.sh @@ -54,54 +54,17 @@ apache/passenger setup. After configuration, start with: /sbin/service diaspora-wsd start /sbin/service httpd restart -<<<<<<< HEAD prepare-rpm.sh prepare creates links also for all files listed in SOURCES. Typically, this is secondary sources. *make-dist.sh source* -#### Generic source synopsis - -Generate source tarball: - % ./make-dist.sh source - Using repo: http://github.com/diaspora/diaspora.git - Commit id: 1010092232_b313272 - Source: dist/diaspora-0.0-1010092232_b313272.tar.gz - Required bundle: 1010081636_d1a4ee0 - % - -The source tarball could be used as-is, by unpacking add making a -*bundle install*. An alternative is to generate a canned bundle like: - % ./make-dist.sh bundle - [ lot's of output...] - Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz - % - -This file can be installed anywhere. To use it, add a symlink from vendor/bundle -to the bundle's bundle directory. Reasonable defaults are to install -diaspora in /usr/share/diaspora and bundle in /usr/lib/diaspora-bundle. With these, -the link is - % rm -rf /usr/share/diaspora/master/vendor/bundle - % ln -sf /usr/lib/diaspora-bundle/vendor/bundle \ - > /usr/share/diaspora/master/vendor - % - -The directories tmp, log, and public/uploads needs to be writable. If using -apache passenger, read the docs on uid used and file ownership. - -Note that the bundle version required is printed each time a new source -is generated. - #### Notes prepare-rpm.sh prepare creates links also for all files listed in SOURCES. -Typically, this is secondary sources. *make-dist.sh source* -applies all patches named *.patch in this directory after checking out -source from git. +Typically, this is secondary sources. The spec-files in dist/ are patched by *./prepare-rpm.sh 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. Editing spec files should be done -in this directory, changes in dist/ are lost when doing *./prepare-rpm.sh *. +correct versions of diaspora and diaspora-bundle. Editing spec files should be +done in this directory, changes in dist/ are lost when doing *./prepare-rpm.sh *. The topmost comment's version is patched to reflect the complete version of current specfile . Write the comment in this directory, copy-paste @@ -129,6 +92,9 @@ diaspora app. This is more or less as mandated by LSB and Fedora packaging rule #### Discussion +The 1.8.7 rebuild is a pain. However, in Fedora 14 1.8.7 is the default +ruby version. + For better or worse, this installation differs from the procedure outlined in the original README.md: diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 53960af05..99735621a 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -12,7 +12,7 @@ Bootstrap the distribution from git: Create and install the diaspora bundle and application in diaspora/pkg/source according to -[source README](http://github.com/diaspora/diaspora/blob/master/source/fedora/README.md) +[source README](http://github.com/diaspora/diaspora/tree/master/pkg/source/) Install the dependencies (a good time for a coffe break): % sudo ./diaspora-install-deps From 1acc206fa47afd17018d0af0a136b2c367e8c854 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Mon, 1 Nov 2010 18:27:49 +0100 Subject: [PATCH 49/56] #475: Fixed more untranslated strings --- app/helpers/application_helper.rb | 2 +- app/views/comments/_new_comment.html.haml | 2 +- app/views/invitations/_new.haml | 15 +++++++++------ app/views/invitations/new.html.haml | 7 ++++--- app/views/people/edit.html.haml | 2 +- app/views/people/show.html.haml | 2 +- app/views/shared/_invitations.haml | 7 ++++--- app/views/shared/_publisher.haml | 6 +++--- app/views/shared/_reshare.haml | 4 ++-- app/views/users/edit.html.haml | 2 +- config/locales/diaspora/en.yml | 22 +++++++++++++++++++++- config/locales/diaspora/sv.yml | 2 +- 12 files changed, 49 insertions(+), 24 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9cb502908..d89b0b1ee 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,7 +34,7 @@ module ApplicationHelper end def how_long_ago(obj) - "#{time_ago_in_words(obj.created_at)} ago" + "#{time_ago_in_words(obj.created_at)} #{t('.ago')}" end def person_url(person) diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index bb8719ee7..b7c1fbbf4 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -4,7 +4,7 @@ = form_for Comment.new, :remote => true do |comment| %p - = label_tag "comment_text_on_#{post.id}", "Comment" + = label_tag "comment_text_on_#{post.id}", t('.comment') = comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post.id}", :class => "comment_box" = comment.hidden_field :post_id, :value => post.id diff --git a/app/views/invitations/_new.haml b/app/views/invitations/_new.haml index 77b07faa2..b05792dd1 100644 --- a/app/views/invitations/_new.haml +++ b/app/views/invitations/_new.haml @@ -1,20 +1,23 @@ .span-12.last .modal_title_bar - %h4 Invite someone to join Diaspora! + %h4 + = t('.invite_someone_to_join') - %i if they accept, they will be added to the aspect you invited them + %i + = t('.if_they_accept_info') = form_for User.new, :url => invitation_path(User) do |invite| %p - = invite.label :email + = invite.label :email , t('.email') = invite.text_field :email - To + = t('.to') - unless @aspect.is_a? Aspect = invite.select(:aspects, @aspects_dropdown_array) - else = invite.select(:aspects, @aspects_dropdown_array, :selected => @aspect.id) - Message: + = t('.message') + = invite.text_area :invite_messages, :value => "" - %p= invite.submit "Send an invitation" + %p= invite.submit t('.send_an_invitation') diff --git a/app/views/invitations/new.html.haml b/app/views/invitations/new.html.haml index 598b16a3d..1b226aa80 100644 --- a/app/views/invitations/new.html.haml +++ b/app/views/invitations/new.html.haml @@ -1,8 +1,9 @@ -%h2 Send invitation +%h2 + = t('.send_invitation') = form_for User.new, :url => invitation_path(User) do |f| = devise_error_messages! %p - = f.label :email + = f.label :email , t('.email') = f.text_field :email - %p= f.submit "Send an invitation" + %p= f.submit t('.send_an_invitation') /= link_to "Home", after_sign_in_path_for(resource_name) diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index f9aaab68c..082a31c2a 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -16,7 +16,7 @@ %h3 = t('.your_profile') .description - This info will be available to whomever you connect with on Diaspora. + =t('.info_available_to') = person.error_messages diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 022955032..0dd95e752 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -32,7 +32,7 @@ - if @person == current_user.person %b - = link_to "Edit my profile", edit_person_path(@person) + = link_to t('.edit_my_profile'), edit_person_path(@person) %br %br diff --git a/app/views/shared/_invitations.haml b/app/views/shared/_invitations.haml index 40476eae7..8ef2ba877 100644 --- a/app/views/shared/_invitations.haml +++ b/app/views/shared/_invitations.haml @@ -1,6 +1,7 @@ -%h4 Invites -= link_to "Invite a friend", "#invite_user_pane", :class => "invite_user_button", :title => "Invite a friend" -= "(#{invites} left)" +%h4 + = t('.invites') += link_to t('.invite_a_friend'), "#invite_user_pane", :class => "invite_user_button", :title => "Invite a friend" += t('.invitations_left', :count => invites) %br .yo{ :style => "display:none;"} #invite_user_pane diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 6499b01f3..5f36f3c84 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -26,7 +26,7 @@ = form_for StatusMessage.new, :remote => true do |status| = status.error_messages %p - = status.label :message, "Post a message to #{aspect}" + = status.label :message, t('.post_a_message_to', :aspect => aspect) = status.text_area :message, :rows => 2, :value => params[:prefill] = status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id) @@ -35,7 +35,7 @@ - if aspect == :all .public_toggle = status.check_box( :public, {}, true, false ) - make public + = t('.make_public') = link_to '(?)', "#question_mark_pane", :class => 'question_mark' .fancybox_content @@ -48,7 +48,7 @@ = status.submit t('.share'), :title => "Share with #{aspect}" #publisher_photo_upload - or + = t('.or') = render 'photos/new_photo', :aspect_id => (aspect == :all ? aspect : aspect.id), :album_id => nil diff --git a/app/views/shared/_reshare.haml b/app/views/shared/_reshare.haml index 44c8f00dd..a479dddef 100644 --- a/app/views/shared/_reshare.haml +++ b/app/views/shared/_reshare.haml @@ -5,7 +5,7 @@ - unless current_user.aspects.size == current_user.aspects_with_post(post.id).size .reshare_pane %span.reshare_button - = link_to "Reshare", "#" + = link_to t('.reshare'), "#" %ul.reshare_box - for aspect in current_user.aspects @@ -14,4 +14,4 @@ - else .reshare_pane %span.reshare_button - = link_to "Reshare", "#", :class => "inactive" + = link_to t('.reshare'), "#", :class => "inactive" diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 23fae0742..7aa2bbcda 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -44,7 +44,7 @@ .submit_block = link_to t('.cancel'), edit_user_path(current_user) - or + = t('.or') = f.submit t('.change_password') %h3 diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index ca1d8f471..250315b6a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -54,9 +54,18 @@ en: manage_aspects: "Manage Aspects" publisher: share: "Share" + or: "or" + post_a_message_to: "Post a message to %{aspect}" + make_public: "make public" aspect_friends: add_friends: "add friends" photos: "photos" + invitations: + invites: 'Invites' + invite_a_friend: 'Invite a friend' + invitations_left: '(%{count} left)' + reshare: + reshare: 'Reshare' albums: album: you: "you" @@ -141,6 +150,7 @@ en: account: "Account" services: "Services" cancel: "Cancel" + or: "or" destroy: "Account successfully closed." getting_started: signup_steps: "Complete your sign-up by doing these things:" @@ -205,7 +215,14 @@ en: already_friends: 'You are already friends with this person' invitation_token_invalid: 'The invitation token provided is not valid!' updated: 'Your password was set successfully. You are now signed in.' - + new: + email: 'Email' + invite_someone_to_join: 'Invite someone to join Diaspora!' + if_they_accept_info: 'if they accept, they will be added to the aspect you invited them' + to: 'To' + message: 'Message:' + send_an_invitation: 'Send an invitation' + send_invitation: 'Send invitation' status_messages: new_status_message: tell_me_something_good: "tell me something good" @@ -214,6 +231,7 @@ en: show_comments: "show comments" delete: "Delete" are_you_sure: "Are you sure?" + ago: "ago" show: status_message: "Status Message" comments: "comments" @@ -246,8 +264,10 @@ en: remove_friend: "remove friend" no_posts: "no posts to display!" add_friend: "add friend" + edit_my_profile: "Edit my profile" edit: settings: "Settings" + info_available_to: "This info will be available to whomever you connect with on Diaspora." your_profile: "Your profile" your_name: "Your name" first_name: "First name" diff --git a/config/locales/diaspora/sv.yml b/config/locales/diaspora/sv.yml index d5b18e6fa..587bc4350 100644 --- a/config/locales/diaspora/sv.yml +++ b/config/locales/diaspora/sv.yml @@ -58,7 +58,7 @@ sv: view_profile: "visa profil" edit_profile: "ändra profil" account_settings: "kontoinstallningar" - search: "Search" + search: "Sök ..." logout: "logga ut" shared: aspect_nav: From f6b4be97a3801b9975f4838ad40471e6db6eb5f3 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 29 Oct 2010 19:13:09 -0700 Subject: [PATCH 50/56] requests are almost there --- app/models/request.rb | 24 ++++++++--------- lib/diaspora/user/receiving.rb | 16 +++++------ spec/helper_methods.rb | 5 +++- spec/lib/diaspora/parser_spec.rb | 35 +++++++++++-------------- spec/models/request_spec.rb | 35 +++++++++++++++++-------- spec/models/user/user_friending_spec.rb | 13 +++++---- 6 files changed, 66 insertions(+), 62 deletions(-) diff --git a/app/models/request.rb b/app/models/request.rb index 2226a7b45..cba28cdef 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -9,18 +9,18 @@ class Request include Diaspora::Webhooks include ROXML - xml_accessor :_id - xml_accessor :person, :as => Person - xml_accessor :destination_url - xml_accessor :callback_url - xml_accessor :exported_key, :cdata => true + xml_reader :_id + xml_reader :diaspora_handle + xml_reader :destination_url + xml_reader :callback_url - key :person_id, ObjectId - key :aspect_id, ObjectId + key :aspect_id, ObjectId key :destination_url, String key :callback_url, String key :exported_key, String + key :diaspora_handle, String + belongs_to :person validates_presence_of :destination_url, :callback_url @@ -30,15 +30,13 @@ class Request person = options[:from] self.new(:destination_url => options[:to], :callback_url => person.receive_url, - :person => person, - :exported_key => person.exported_key, - :aspect_id => options[:into]) + :diaspora_handle => person.diaspora_handle, + :aspect_id => options[:into]) end def reverse_for accepting_user - self.person = accepting_user.person - self.exported_key = accepting_user.exported_key - self.destination_url = self.callback_url + self.diaspora_handle = accepting_user.diaspora_handle + self.destination_url = self.callback_url self.save end diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index a651b4793..1c6c4088c 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -21,7 +21,7 @@ module Diaspora Rails.logger.debug("From: #{object.person.inspect}") if object.person - if object.is_a?(Comment) || object.is_a?(Post) + if object.is_a?(Comment) || object.is_a?(Post)|| object.is_a?(Request) e = EMWebfinger.new(object.diaspora_handle) e.on_person { |person| @@ -32,6 +32,10 @@ module Diaspora raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} " end + if object.is_a? Request + return receive_request object, sender_in_xml + end + raise "Not friends with that person" unless self.contact_for(salmon_author) if object.is_a?(Comment) @@ -50,17 +54,12 @@ module Diaspora raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} " end - if object.is_a? Request - return receive_request object, sender_in_xml - end raise "Not friends with that person" unless self.contact_for(salmon_author) if object.is_a? Retraction receive_retraction object, xml elsif object.is_a? Profile receive_profile object, xml - else - receive_post object, xml end end end @@ -68,8 +67,6 @@ module Diaspora def sender(object, xml, webfingered_person = nil) if object.is_a? Retraction sender = object.person - elsif object.is_a? Request - sender = object.person elsif object.is_a? Profile sender = Diaspora::Parser.owner_id_from_xml xml @@ -98,10 +95,9 @@ module Diaspora end def receive_request request, person - person.serialized_public_key ||= request.exported_key request.person = person request.person.save - old_request = Request.first(:id => request.id) + old_request = Request.find(request.id) Rails.logger.info("I got a reqest_id #{request.id} with old request #{old_request.inspect}") request.aspect_id = old_request.aspect_id if old_request request.save diff --git a/spec/helper_methods.rb b/spec/helper_methods.rb index e60b39535..4dc1ca8f2 100644 --- a/spec/helper_methods.rb +++ b/spec/helper_methods.rb @@ -28,9 +28,12 @@ module HelperMethods def friend_users(user1, aspect1, user2, aspect2) request = user1.send_friend_request_to(user2.person, aspect1) - user2.receive_friend_request(request) + + user2.receive request.to_diaspora_xml, user1.person + reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.reload + user1.receive reversed_request.to_diaspora_xml, user2.person user1.reload aspect1.reload diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 6e7d74109..fc2a021fa 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -35,6 +35,8 @@ describe Diaspora::Parser do end context "friending" do + + let(:good_request) { FakeHttpRequest.new(:success)} before do deliverable = Object.new deliverable.stub!(:deliver) @@ -42,30 +44,24 @@ describe Diaspora::Parser do end it "should create a new person upon getting a person request" do + webfinger_mock = EMWebfinger.new(person.diaspora_handle) + webfinger_mock.should_receive(:on_person) + + EMWebfinger.should_receive(:new).and_return(webfinger_mock) + + request = Request.instantiate(:to =>"http://www.google.com/", :from => person) xml = request.to_diaspora_xml - user3.destroy - person.destroy + user3.delete + person.delete + Person.should_receive(:by_account_identifier).exactly(2).times.and_return(person) user lambda { user.receive xml, person }.should change(Person, :count).by(1) end - it "should not create a new person if the person is already here" do - request = Request.instantiate(:to =>"http://www.google.com/", :from => user2.person) - original_person_id = user2.person.id - xml = request.to_diaspora_xml - user - lambda { user.receive xml, user2.person }.should_not change(Person, :count) - user2.reload - user2.person.reload - user2.serialized_private_key.include?("PRIVATE").should be true - - url = "http://" + request.callback_url.split("/")[2] + "/" - Person.where(:url => url).first.id.should == original_person_id - end end it "should activate the Person if I initiated a request to that url" do @@ -73,13 +69,12 @@ describe Diaspora::Parser do user.reload request.reverse_for user3 - xml = request.to_diaspora_xml + xml = user3.salmon(request).xml_for(user.person) - user3.person.destroy - user3.destroy + user3.delete - user.receive xml, user3.person - new_person = Person.first(:url => user3.person.url) + user.receive_salmon(xml) + new_person = Person.find_by_url(user3.person.url) new_person.nil?.should be false user.reload diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index e08347d69..daab156b7 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -19,17 +19,6 @@ describe Request do person_request.valid?.should be true end - it 'should generate xml for the User as a Person' do - - request = user.send_friend_request_to person, aspect - xml = request.to_xml.to_s - - xml.should include user.person.diaspora_handle - xml.should include user.person.url - xml.should include user.profile.first_name - xml.should include user.profile.last_name - xml.should include user.exported_key - end it 'should strip the destination url' do person_request = Request.new @@ -68,4 +57,28 @@ describe Request do end end + describe 'serialization' do + it 'should not generate xml for the User as a Person' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should_not include user.person.profile.first_name + end + + it 'should serialize the handle and not the sender' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should include user.person.diaspora_handle + end + + it 'should not serialize the exported key' do + request = user.send_friend_request_to person, aspect + xml = request.to_xml.to_s + + xml.should_not include user.person.exported_key + end + + end + end diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 945f3dcbf..a1232b80b 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -233,23 +233,22 @@ describe Diaspora::UserModules::Friending do end it "keeps the right counts of friends" do - user.receive_friend_request @request + user.receive @request.to_diaspora_xml, person_one - person_two.destroy - user.reload.pending_requests.size.should be 1 + user.reload.pending_requests.size.should == 1 user.friends.size.should be 0 - user.receive_friend_request @request_two - user.reload.pending_requests.size.should be 2 + user.receive @request_two.to_diaspora_xml, person_two + user.reload.pending_requests.size.should == 2 user.friends.size.should be 0 user.accept_friend_request @request.id, aspect.id - user.reload.pending_requests.size.should be 1 + user.reload.pending_requests.size.should == 1 user.friends.size.should be 1 user.contact_for(person_one).should_not be_nil user.ignore_friend_request @request_two.id - user.reload.pending_requests.size.should be 0 + user.reload.pending_requests.size.should == 0 user.friends.size.should be 1 user.contact_for(person_two).should be_nil end From 922aa85fb7834a38eb8e7f5de79667b10325ac00 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 1 Nov 2010 13:01:33 -0700 Subject: [PATCH 51/56] MS IZ refactor green --- lib/diaspora/user/receiving.rb | 4 ++-- spec/lib/diaspora/parser_spec.rb | 23 ++++++++++++----------- spec/lib/encryptor_spec.rb | 32 -------------------------------- spec/misc_spec.rb | 4 ++++ 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index 1c6c4088c..586fcc904 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -27,6 +27,7 @@ module Diaspora e.on_person { |person| if person.class == Person + object.person = person sender_in_xml = sender(object, xml, person) if (salmon_author != sender_in_xml) raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} " @@ -71,7 +72,6 @@ module Diaspora sender = Diaspora::Parser.owner_id_from_xml xml else - object.person = webfingered_person if object.is_a?(Comment) sender = (owns?(object.post))? object.person : object.post.person else @@ -96,7 +96,7 @@ module Diaspora def receive_request request, person request.person = person - request.person.save + request.person.save! old_request = Request.find(request.id) Rails.logger.info("I got a reqest_id #{request.id} with old request #{old_request.inspect}") request.aspect_id = old_request.aspect_id if old_request diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index fc2a021fa..1c9d19e9f 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -44,21 +44,22 @@ describe Diaspora::Parser do end it "should create a new person upon getting a person request" do - webfinger_mock = EMWebfinger.new(person.diaspora_handle) - webfinger_mock.should_receive(:on_person) - - EMWebfinger.should_receive(:new).and_return(webfinger_mock) - - - request = Request.instantiate(:to =>"http://www.google.com/", :from => person) + new_person = Factory.build(:person) + puts new_person.persisted? + Person.should_receive(:by_account_identifier).and_return(new_person) + puts new_person.persisted? + request = Request.instantiate(:to =>"http://www.google.com/", :from => new_person) + puts new_person.persisted? xml = request.to_diaspora_xml - user3.delete - person.delete - Person.should_receive(:by_account_identifier).exactly(2).times.and_return(person) user - lambda { user.receive xml, person }.should change(Person, :count).by(1) + + puts Person.count + user.receive xml, new_person + + puts Person.count + #lambda { user.receive xml, new_person }.should change(Person, :count).by(1) end diff --git a/spec/lib/encryptor_spec.rb b/spec/lib/encryptor_spec.rb index e0c9f5ca9..eba23e6e5 100644 --- a/spec/lib/encryptor_spec.rb +++ b/spec/lib/encryptor_spec.rb @@ -10,38 +10,6 @@ describe 'user encryption' do @aspect = @user.aspects.create(:name => 'dudes') end - describe 'key exchange on friending' do - - it 'should receive and marshal a public key from a request' do - remote_user = Factory.build(:user) - remote_user.encryption_key.nil?.should== false - - deliverable = Object.new - deliverable.stub!(:deliver) - Notifier.stub!(:new_request).and_return(deliverable) - Person.should_receive(:by_account_identifier).and_return(remote_user.person) - remote_user.should_receive(:push_to_people).and_return(true) - #should move this to friend request, but i found it here - id = remote_user.person.id - original_key = remote_user.exported_key - - request = remote_user.send_friend_request_to( - @user.person, remote_user.aspects.create(:name => "temp")) - - xml = remote_user.salmon(request).xml_for(@user) - - remote_user.person.delete - remote_user.delete - - person_count = Person.all.count - @user.receive_salmon xml - - Person.all.count.should == person_count + 1 - new_person = Person.first(:id => id) - new_person.exported_key.should == original_key - end - end - describe 'encryption' do it 'should encrypt a string' do string = "Secretsauce" diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index e518a23a3..d4d9a20cd 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -37,6 +37,10 @@ describe 'making sure the spec runner works' do it 'does not save a built user' do Factory.build(:user).persisted?.should be_false end + + it 'does not save a built person' do + Factory.build(:person).persisted?.should be_false + end end end From 3c16a46f0e70cbd8c38358b1b67324c64a321fa9 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 1 Nov 2010 13:14:01 -0700 Subject: [PATCH 52/56] MS IZ updated the backer script to use aspects.create --- config/deploy_config.yml | 2 +- db/seeds/tom.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/deploy_config.yml b/config/deploy_config.yml index 06a6747e1..f99ef75d1 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -6,7 +6,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git://github.com/diaspora/diaspora.git' - branch: 'master' + branch: 'diaspora-handle-request' default_env: 'development' servers: tom: diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 28f043728..6290da594 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -42,8 +42,8 @@ user2.save! user2.seed_aspects user2.person.save! # friending users -aspect = user.aspect(:name => "other dudes") -aspect2 = user2.aspect(:name => "presidents") +aspect = user.aspects.create(:name => "other dudes") +aspect2 = user2.aspects.create(:name => "presidents") friend_users(user, aspect, user2, aspect2) -user.aspect(:name => "Presidents") +user.aspects.create(:name => "Presidents") From 3aab691c78981a61074b681f26e2ac57ecd1534c Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 1 Nov 2010 14:28:02 -0700 Subject: [PATCH 53/56] updating requests for me now that person is taken out of requests --- lib/diaspora/user/friending.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index db3a30c4d..472926346 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -140,7 +140,7 @@ module Diaspora end def requests_for_me - pending_requests.select{|req| req.person != self.person } + pending_requests.select{|req| req.destination_url == self.person.receive_url} end end end From a0ac6db946644ee482c9ff57c51da2482f21c284 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 1 Nov 2010 14:50:54 -0700 Subject: [PATCH 54/56] IZ MS; fixing parser spec --- spec/lib/diaspora/parser_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 1c9d19e9f..a6a306f03 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -46,20 +46,12 @@ describe Diaspora::Parser do it "should create a new person upon getting a person request" do new_person = Factory.build(:person) - puts new_person.persisted? Person.should_receive(:by_account_identifier).and_return(new_person) - puts new_person.persisted? request = Request.instantiate(:to =>"http://www.google.com/", :from => new_person) - puts new_person.persisted? xml = request.to_diaspora_xml - user - puts Person.count - user.receive xml, new_person - - puts Person.count - #lambda { user.receive xml, new_person }.should change(Person, :count).by(1) + lambda { user.receive xml, new_person }.should change(Person, :count).by(1) end From ccf897ed6297291a98d5aee6746480718249966d Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 1 Nov 2010 14:50:54 -0700 Subject: [PATCH 55/56] IZ MS; fixing parser spec --- spec/lib/diaspora/parser_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 1c9d19e9f..a6a306f03 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -46,20 +46,12 @@ describe Diaspora::Parser do it "should create a new person upon getting a person request" do new_person = Factory.build(:person) - puts new_person.persisted? Person.should_receive(:by_account_identifier).and_return(new_person) - puts new_person.persisted? request = Request.instantiate(:to =>"http://www.google.com/", :from => new_person) - puts new_person.persisted? xml = request.to_diaspora_xml - user - puts Person.count - user.receive xml, new_person - - puts Person.count - #lambda { user.receive xml, new_person }.should change(Person, :count).by(1) + lambda { user.receive xml, new_person }.should change(Person, :count).by(1) end From 3a4f1008060087a2af1898d6a5f48552adac7d8c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 1 Nov 2010 15:01:49 -0700 Subject: [PATCH 56/56] remove * --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c8c0448cc..70f610ebc 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -44,7 +44,7 @@ %header .container{:style => "position:relative;"} #diaspora_text{:href => root_path} - = link_to "DIASPORA*", (current_user ? root_path : new_user_session_path) + = link_to "DIASPORA", (current_user ? root_path : new_user_session_path) %span.sub_text PREVIEW