From 03df0ff716a07d5a527f7918a67b575a4c853467 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 11 Oct 2010 18:22:19 -0700 Subject: [PATCH 01/26] parser spec is green --- lib/diaspora/user/receiving.rb | 45 ++++++++++++++++++------- spec/lib/diaspora_parser_spec.rb | 16 +++++---- spec/models/user/attack_vectors_spec.rb | 13 +++---- spec/spec_helper.rb | 2 +- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index e6976a77e..f5390e476 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -5,28 +5,49 @@ module Diaspora salmon = Salmon::SalmonSlap.parse salmon_xml, self if salmon.verified_for_key?(salmon.author.public_key) Rails.logger.info("data in salmon: #{salmon.parsed_data}") - self.receive(salmon.parsed_data) + self.receive(salmon.parsed_data, salmon.author) end end - def receive xml + def receive xml, author object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") Rails.logger.debug("From: #{object.person.inspect}") if object.person - - if object.is_a? Retraction - receive_retraction object, xml - elsif object.is_a? Request - receive_request object, xml - elsif object.is_a? Profile - receive_profile object, xml - elsif object.is_a?(Comment) - receive_comment object, xml + + + + if (author == sender(object, xml)) + if object.is_a? Retraction + receive_retraction object, xml + elsif object.is_a? Request + receive_request object, xml + elsif object.is_a? Profile + receive_profile object, xml + elsif object.is_a?(Comment) + receive_comment object, xml + else + receive_post object, xml + end else - receive_post object, xml + raise "Possibly Malicious Post, #{author.real_name} with id #{author.id} is sending a #{object.class} as #{sender.real_name} with id #{sender.id} " end end + def sender(object, xml) + if object.is_a? Retraction + sender = object.person + elsif object.is_a? Request + sender = Diaspora::Parser.parse_or_find_person_from_xml( xml ) + elsif object.is_a? Profile + sender = Diaspora::Parser.owner_id_from_xml xml + elsif object.is_a?(Comment) + sender = object.post.person + else + sender = object.person + end + sender + end + def receive_retraction retraction, xml if retraction.type == 'Person' Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}") diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index fede700ad..3b9e090f9 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -55,7 +55,7 @@ describe Diaspora::Parser do xml = retraction.to_diaspora_xml StatusMessage.count.should == 1 - @user.receive xml + @user.receive xml, person StatusMessage.count.should == 0 end @@ -69,7 +69,7 @@ describe Diaspora::Parser do @user3.destroy @person.destroy Person.all.count.should == person_count -1 - @user.receive xml + @user.receive xml, @person Person.all.count.should == person_count Person.first(:_id => original_person_id).serialized_public_key.include?("PUBLIC").should be true @@ -85,7 +85,7 @@ describe Diaspora::Parser do xml = request.to_diaspora_xml Person.all.count.should be person_count - @user.receive xml + @user.receive xml, @user2.person Person.all.count.should be person_count @user2.reload @@ -106,7 +106,7 @@ describe Diaspora::Parser do @user2.person.destroy @user2.destroy - @user.receive xml + @user.receive xml, @user2.person new_person = Person.first(:url => @user2.person.url) new_person.nil?.should be false @@ -128,14 +128,16 @@ describe Diaspora::Parser do @user2.person.destroy @user2.destroy - @user.receive xml + @user.receive xml, @user2.person + @aspect.reload aspect_people_count = @aspect.people.size #They are now friends Person.count.should == person_count - @user.receive retraction_xml + @user.receive retraction_xml, @user2.person + @aspect.reload @aspect.people.size.should == aspect_people_count -1 @@ -163,7 +165,7 @@ describe Diaspora::Parser do old_profile.first_name.should == 'bob' #Marshal profile - @user.receive xml + @user.receive xml, person #Check that marshaled profile is the same as old profile person = Person.first(:id => person.id) diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index 0e14cf44c..2918cf1ca 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -28,38 +28,35 @@ describe User do user.raw_visible_posts.count.should be 1 malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user3.person) - user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person)) + proc{user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))}.should raise_error /Malicious Post/ user.raw_visible_posts.count.should be 1 user.raw_visible_posts.first.message.should == "store this!" end - it 'ovewrites messages which apear to ' do + it 'ovewrites messages which apear to be from the same user' do original_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id user.receive_salmon(user2.salmon(original_message).xml_for(user.person)) user.raw_visible_posts.count.should be 1 malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user2.person) - user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person)) + proc{user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))}.should raise_error /Malicious Post/ + user.raw_visible_posts.count.should be 1 user.raw_visible_posts.first.message.should == "store this!" end it 'overites another persons profile' do - pending "don't allow profile overwriting" profile = user2.profile.clone profile.first_name = "Not BOB" user2.reload user2.profile.first_name.should == "Robert" - user.receive_salmon(user3.salmon(profile).xml_for(user.person)) + proc{user.receive_salmon(user3.salmon(profile).xml_for(user.person))}.should raise_error /Malicious Post/ user2.reload user2.profile.first_name.should == "Robert" end - it 'overwrites requests' do - pending - end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7dede4436..403042406 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -82,7 +82,7 @@ ImageUploader.enable_processing = false request = user1.send_friend_request_to(user2.person, aspect1) reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.reload - user1.receive reversed_request.to_diaspora_xml + user1.receive reversed_request.to_diaspora_xml, user2.person user1.reload aspect1.reload user2.reload From ee2d134cb0e395c4542c33ec97da60e0fc72f99c Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 11 Oct 2010 19:20:00 -0700 Subject: [PATCH 02/26] receiving spec is green --- lib/diaspora/user/receiving.rb | 11 ++++++----- spec/models/aspect_spec.rb | 9 +++++---- spec/models/comments_spec.rb | 10 +++++----- spec/models/user/receive_spec.rb | 24 ++++++++++++------------ 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index f5390e476..d5eb0e49d 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -9,14 +9,15 @@ module Diaspora end end - def receive xml, author + def receive xml, salmon_author object = Diaspora::Parser.from_xml(xml) Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") Rails.logger.debug("From: #{object.person.inspect}") if object.person - - if (author == sender(object, xml)) + sender_in_xml = sender(object, xml) + + if (salmon_author == sender_in_xml) if object.is_a? Retraction receive_retraction object, xml elsif object.is_a? Request @@ -29,7 +30,7 @@ module Diaspora receive_post object, xml end else - raise "Possibly Malicious Post, #{author.real_name} with id #{author.id} is sending a #{object.class} as #{sender.real_name} with id #{sender.id} " + raise "Possibly 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 end @@ -41,7 +42,7 @@ module Diaspora elsif object.is_a? Profile sender = Diaspora::Parser.owner_id_from_xml xml elsif object.is_a?(Comment) - sender = object.post.person + sender = (owns?(object.post))? object.person : object.post.person else sender = object.person end diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 6c8a4aef6..b3acbd028 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -86,7 +86,7 @@ describe Aspect do message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) - @user.receive message.to_diaspora_xml + @user.receive message.to_diaspora_xml, @user2.person aspect.reload aspect.posts.include?(message).should be true @@ -100,13 +100,14 @@ describe Aspect do message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id) - @user.receive message.to_diaspora_xml + @user.receive message.to_diaspora_xml, @user2.person aspect.reload aspect.post_ids.include?(message.id).should be true retraction = @user2.retract(message) - @user.receive retraction.to_diaspora_xml + @user.receive retraction.to_diaspora_xml, @user2.person + aspect.reload aspect.post_ids.include?(message.id).should be false @@ -151,7 +152,7 @@ describe Aspect do it 'should move all the by that user to the new aspect' do message = @user2.post(:status_message, :message => "Hey Dude", :to => @aspect2.id) - @user.receive message.to_diaspora_xml + @user.receive message.to_diaspora_xml, @user2.person @aspect.reload @aspect.posts.count.should == 1 diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index c46fed5ba..6a60086d5 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -73,33 +73,33 @@ describe Comment do it 'should send a comment a person made on your post to all people' do comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status) User::QUEUE.should_receive(:add_post_request).twice - @user.receive(comment.to_diaspora_xml) + @user.receive comment.to_diaspora_xml, @person end it 'should send a comment a user made on your post to all people' do comment = @user2.comment( "balls", :on => @user_status) User::QUEUE.should_receive(:add_post_request).twice - @user.receive(comment.to_diaspora_xml) + @user.receive comment.to_diaspora_xml, @user2.person end it 'should not send a comment a person made on his own post to anyone' do User::QUEUE.should_not_receive(:add_post_request) comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status) - @user.receive(comment.to_diaspora_xml) + @user.receive comment.to_diaspora_xml, @person end it 'should not send a comment a person made on a person post to anyone' do User::QUEUE.should_not_receive(:add_post_request) comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status) - @user.receive(comment.to_diaspora_xml) + @user.receive comment.to_diaspora_xml, @person end it 'should not clear the aspect post array on receiving a comment' do @aspect.post_ids.include?(@user_status.id).should be true comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status) - @user.receive(comment.to_diaspora_xml) + @user.receive comment.to_diaspora_xml, @person @aspect.reload @aspect.post_ids.include?(@user_status.id).should be true diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 027645e39..1d97cdad1 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -28,7 +28,7 @@ describe User do user2.destroy status_message.destroy StatusMessage.all.size.should == 0 - user.receive( xml ) + user.receive xml , user2.person Post.all(:person_id => person.id).first.message.should == 'store this!' StatusMessage.all.size.should == 1 @@ -40,7 +40,7 @@ describe User do (0..5).each{ |n| status_message = user2.post :status_message, :message => "store this #{n}!", :to => aspect2.id xml = status_message.to_diaspora_xml - user.receive( xml ) + user.receive xml, user2.person } user.aspects.size.should == num_aspects @@ -60,7 +60,7 @@ describe User do it 'should be removed on unfriending' do status_message = user2.post :status_message, :message => "hi", :to => aspect2.id - user.receive status_message.to_diaspora_xml + user.receive status_message.to_diaspora_xml, user2.person user.reload user.raw_visible_posts.count.should == 1 @@ -75,13 +75,13 @@ describe User do it 'should be remove a post if the noone links to it' do status_message = user2.post :status_message, :message => "hi", :to => aspect2.id - user.receive status_message.to_diaspora_xml + user.receive status_message.to_diaspora_xml, user2.person user.reload user.raw_visible_posts.count.should == 1 person = user2.person - user2.destroy + user2.delete user.unfriend(person) user.reload @@ -92,7 +92,7 @@ describe User do it 'should keep track of user references for one person ' do status_message = user2.post :status_message, :message => "hi", :to => aspect2.id - user.receive status_message.to_diaspora_xml + user.receive status_message.to_diaspora_xml, user2.person user.reload user.raw_visible_posts.count.should == 1 @@ -116,9 +116,9 @@ describe User do user3.activate_friend(user2.person, aspect3) status_message = user2.post :status_message, :message => "hi", :to => aspect2.id - user.receive status_message.to_diaspora_xml + user.receive status_message.to_diaspora_xml, user2.person - user3.receive status_message.to_diaspora_xml + user3.receive status_message.to_diaspora_xml, user2.person user.reload user3.reload @@ -145,11 +145,11 @@ describe User do post = user.post :status_message, :message => "hello", :to => aspect.id - user2.receive post.to_diaspora_xml - user3.receive post.to_diaspora_xml + user2.receive post.to_diaspora_xml, user.person + user3.receive post.to_diaspora_xml, user.person comment = user2.comment('tada',:on => post) - user.receive comment.to_diaspora_xml + user.receive comment.to_diaspora_xml, user2.person user.reload commenter_id = user2.person.id @@ -159,7 +159,7 @@ describe User do comment_id = comment.id comment.delete - user3.receive comment.to_diaspora_xml + user3.receive comment.to_diaspora_xml, user.person user3.reload new_comment = Comment.find_by_id(comment_id) From a955dd308e42f57db79840619733cd77747846af Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 12 Oct 2010 10:25:43 -0700 Subject: [PATCH 03/26] user_friending_spec green, did a slight refactor need more --- spec/models/user/user_friending_spec.rb | 201 +++++++++++------------- 1 file changed, 95 insertions(+), 106 deletions(-) diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 47a756bd3..e5ff6ad77 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -5,74 +5,69 @@ require 'spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - end + let(:user) {Factory.create :user} + let(:aspect) {user.aspect(:name => 'heroes')} + let(:friend) { Factory.create(:person) } - describe 'friend requesting' do + let(:person_one) {Factory.create :person} + let(:person_two) {Factory.create :person} + + let(:user2) { Factory.create :user} + let(:aspect2) { user2.aspect(:name => "aspect two")} + + context 'friend requesting' do it "should assign a request to a aspect" do - friend = Factory.create(:person) - aspect = @user.aspect(:name => "Dudes") aspect.requests.size.should == 0 - @user.send_friend_request_to(friend, aspect) + user.send_friend_request_to(friend, aspect) aspect.reload aspect.requests.size.should == 1 end it "should be able to accept a pending friend request" do - friend = Factory.create(:person) - r = Request.instantiate(:to => @user.receive_url, :from => friend) + r = Request.instantiate(:to => user.receive_url, :from => friend) r.save Person.all.count.should == 2 - Request.for_user(@user).all.count.should == 1 - @user.accept_friend_request(r.id, @aspect.id) - Request.for_user(@user).all.count.should == 0 + Request.for_user(user).all.count.should == 1 + user.accept_friend_request(r.id, aspect.id) + Request.for_user(user).all.count.should == 0 end it 'should be able to ignore a pending friend request' do friend = Factory.create(:person) - r = Request.instantiate(:to => @user.receive_url, :from => friend) + r = Request.instantiate(:to => user.receive_url, :from => friend) r.save Person.count.should == 2 - @user.ignore_friend_request(r.id) + user.ignore_friend_request(r.id) Person.count.should == 2 Request.count.should == 0 end it 'should not be able to friend request an existing friend' do - friend = Factory.create(:person) + user.friends << friend + user.save - @user.friends << friend - @user.save - - proc { @user.send_friend_request_to(friend, @aspect) }.should raise_error + proc { user.send_friend_request_to(friend, aspect) }.should raise_error end describe 'multiple users accepting/rejecting the same person' do + before do - @person_one = Factory.create :person - @person_one.save + user.pending_requests.empty?.should be true + user.friends.empty?.should be true + user2.pending_requests.empty?.should be true + user2.friends.empty?.should be true - @user2 = Factory.create :user - @aspect2 = @user2.aspect(:name => "aspect two") + @request = Request.instantiate(:to => user.receive_url, :from => person_one) + @request_two = Request.instantiate(:to => user2.receive_url, :from => person_one) + @request_three = Request.instantiate(:to => user2.receive_url, :from => user.person) - @user.pending_requests.empty?.should be true - @user.friends.empty?.should be true - @user2.pending_requests.empty?.should be true - @user2.friends.empty?.should be true - - @request = Request.instantiate(:to => @user.receive_url, :from => @person_one) - @request_two = Request.instantiate(:to => @user2.receive_url, :from => @person_one) - @request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person) - - @req_xml = @request.to_diaspora_xml - @req_two_xml = @request_two.to_diaspora_xml + @req_xml = @request.to_diaspora_xml + @req_two_xml = @request_two.to_diaspora_xml @req_three_xml = @request_three.to_diaspora_xml @request.destroy @@ -81,129 +76,123 @@ describe User do end it 'should befriend the user other user on the same pod' do - @user2.receive @req_three_xml - @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_three.id, @aspect2.id - @user2.friends.include?(@user.person).should be true + user2.receive @req_three_xml, user.person + user2.pending_requests.size.should be 1 + user2.accept_friend_request @request_three.id, aspect2.id + user2.friends.include?(user.person).should be true Person.all.count.should be 3 end it 'should not delete the ignored user on the same pod' do - @user2.receive @req_three_xml - @user2.pending_requests.size.should be 1 - @user2.ignore_friend_request @request_three.id - @user2.friends.include?(@user.person).should be false + user2.receive @req_three_xml, user.person + user2.pending_requests.size.should be 1 + user2.ignore_friend_request @request_three.id + user2.friends.include?(user.person).should be false Person.all.count.should be 3 end it 'should both users should befriend the same person' do - @user.receive @req_xml - @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id, @aspect.id - @user.friends.include?(@person_one).should be true + user.receive @req_xml, person_one + user.pending_requests.size.should be 1 + user.accept_friend_request @request.id, aspect.id + user.friends.include?(person_one).should be true - @user2.receive @req_two_xml - @user2.pending_requests.size.should be 1 - @user2.accept_friend_request @request_two.id, @aspect2.id - @user2.friends.include?(@person_one).should be true + user2.receive @req_two_xml, person_one + user2.pending_requests.size.should be 1 + user2.accept_friend_request @request_two.id, aspect2.id + user2.friends.include?(person_one).should be true Person.all.count.should be 3 end it 'should keep the person around if one of the users rejects him' do - @user.receive @req_xml - @user.pending_requests.size.should be 1 - @user.accept_friend_request @request.id, @aspect.id - @user.friends.include?(@person_one).should be true + user.receive @req_xml, person_one + user.pending_requests.size.should be 1 + user.accept_friend_request @request.id, aspect.id + user.friends.include?(person_one).should be true - @user2.receive @req_two_xml - @user2.pending_requests.size.should be 1 - @user2.ignore_friend_request @request_two.id - @user2.friends.include?(@person_one).should be false + user2.receive @req_two_xml, person_one + user2.pending_requests.size.should be 1 + user2.ignore_friend_request @request_two.id + user2.friends.include?(person_one).should be false Person.all.count.should be 3 end it 'should keep the person around if the users ignores them' do - @user.receive @req_xml - @user.pending_requests.size.should be 1 - @user.ignore_friend_request @user.pending_requests.first.id - @user.friends.include?(@person_one).should be false + user.receive @req_xml, person_one + user.pending_requests.size.should be 1 + user.ignore_friend_request user.pending_requests.first.id + user.friends.include?(person_one).should be false - @user2.receive @req_two_xml - @user2.pending_requests.size.should be 1 - @user2.ignore_friend_request @user2.pending_requests.first.id #@request_two.id - @user2.friends.include?(@person_one).should be false + user2.receive @req_two_xml, person_one + user2.pending_requests.size.should be 1 + user2.ignore_friend_request user2.pending_requests.first.id #@request_two.id + user2.friends.include?(person_one).should be false Person.all.count.should be 3 end end describe 'a user accepting rejecting multiple people' do before do - @person_one = Factory.create :person - @person_two = Factory.create :person + user.pending_requests.empty?.should be true + user.friends.empty?.should be true - @user.pending_requests.empty?.should be true - @user.friends.empty?.should be true - - @request = Request.instantiate(:to => @user.receive_url, :from => @person_one) - @request_two = Request.instantiate(:to => @user.receive_url, :from => @person_two) + @request = Request.instantiate(:to => user.receive_url, :from => person_one) + @request_two = Request.instantiate(:to => user.receive_url, :from => person_two) end it "keeps the right counts of friends" do - @user.receive_friend_request @request + user.receive_friend_request @request - @person_two.destroy - @user.pending_requests.size.should be 1 - @user.friends.size.should be 0 + person_two.destroy + user.pending_requests.size.should be 1 + user.friends.size.should be 0 - @user.receive_friend_request @request_two - @user.pending_requests.size.should be 2 - @user.friends.size.should be 0 + user.receive_friend_request @request_two + user.pending_requests.size.should be 2 + user.friends.size.should be 0 - @user.accept_friend_request @request.id, @aspect.id - @user.pending_requests.size.should be 1 - @user.friends.size.should be 1 - @user.friends.include?(@person_one).should be true + user.accept_friend_request @request.id, aspect.id + user.pending_requests.size.should be 1 + user.friends.size.should be 1 + user.friends.include?(person_one).should be true - @user.ignore_friend_request @request_two.id - @user.pending_requests.size.should be 0 - @user.friends.size.should be 1 - @user.friends.include?(@person_two).should be false + user.ignore_friend_request @request_two.id + user.pending_requests.size.should be 0 + user.friends.size.should be 1 + user.friends.include?(person_two).should be false end end describe 'unfriending' do before do - @user2 = Factory.create :user - @aspect2 = @user2.aspect(:name => "Gross people") - - friend_users(@user, @aspect, @user2, @aspect2) + friend_users(user,aspect, user2, aspect2) end it 'should unfriend the other user on the same seed' do - @user.friends(true).count.should == 1 - @user2.friends(true).count.should == 1 + user.friends(true).count.should == 1 + user2.friends(true).count.should == 1 - @user2.unfriend @user.person + user2.unfriend user.person - @user2.friends(true).count.should == 0 - @user.unfriended_by @user2.person + user2.friends(true).count.should == 0 + user.unfriended_by user2.person - @aspect.reload.people(true).count.should == 0 - @aspect2.reload.people(true).count.should == 0 + aspect.reload.people(true).count.should == 0 + aspect2.reload.people(true).count.should == 0 end context 'with a post' do before do - @message = @user.post(:status_message, :message => "hi", :to => @aspect.id) - @user2.receive @message.to_diaspora_xml.to_s - @user2.unfriend @user.person - @user.unfriended_by @user2.person + @message = user.post(:status_message, :message => "hi", :to => aspect.id) + user2.receive @message.to_diaspora_xml.to_s, user.person + user2.unfriend user.person + user.unfriended_by user2.person end it "deletes the unfriended user's posts from visible_posts" do - @user.raw_visible_posts(true).include?(@message.id).should be_false + user.raw_visible_posts(true).include?(@message.id).should be_false end it "deletes the unfriended user's posts from the aspect's posts" do - @aspect2.posts(true).include?(@message).should be_false + aspect2.posts(true).include?(@message).should be_false end end end From a068ee532d8bf00d11c6896fa8477560d7cfcf18 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 12 Oct 2010 11:17:29 -0700 Subject: [PATCH 04/26] almost all green --- spec/models/person_spec.rb | 3 ++- spec/models/photo_spec.rb | 2 +- spec/models/user/visible_posts_spec.rb | 19 +++++++++---------- spec/user_encryption_spec.rb | 7 ++++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index b8738f934..6e69721ae 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -43,6 +43,7 @@ describe Person do it 'should have a profile in its xml' do @xml.include?("first_name").should == true + end end @@ -54,7 +55,7 @@ describe Person do person_two.owns?(person_message).should be false end - it 'should delete all of user except comments upon user deletion' do + it 'should delete all of user posts except comments upon user deletion' do person = Factory.create(:person) Factory.create(:status_message, :person => person) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index a239ec1c4..de70ce030 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -115,7 +115,7 @@ describe Photo do id = @photo.id @photo.destroy - @user.receive xml + @user.receive xml, @photo.person new_photo = Photo.first(:id => id) new_photo.url.nil?.should be false diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index c4cf40797..6f4345251 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -10,11 +10,15 @@ describe User do let!(:second_aspect) { user.aspect(:name => 'losers') } let!(:user2) { Factory(:user_with_aspect) } + let!(:user3) { Factory(:user_with_aspect) } + let!(:user4) { Factory(:user_with_aspect) } let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id } let!(:status_message2) { user2.post :status_message, :message => "hey", :public => true , :to => user2.aspects.first.id } let!(:status_message3) { user2.post :status_message, :message => "va", :to => user2.aspects.first.id } let!(:status_message4) { user2.post :status_message, :message => "da", :public => true , :to => user2.aspects.first.id } + let!(:status_message5) { user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id} + let!(:status_message6) { user4.post :status_message, :message => "yooo", :to => user4.aspects.first.id} before do @@ -44,20 +48,15 @@ describe User do end it "queries by aspect" do - user3 = Factory(:user_with_aspect) - status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id - user4 = Factory(:user_with_aspect) - status_message3 = user4.post :status_message, :message => "yooo", :to => user4.aspects.first.id - friend_users(user, second_aspect, user3, user3.aspects.first) friend_users(user, second_aspect, user4, user4.aspects.first) - user.receive status_message1.to_diaspora_xml - user.receive status_message2.to_diaspora_xml - user.receive status_message3.to_diaspora_xml + user.receive status_message4.to_diaspora_xml, user2.person + user.receive status_message5.to_diaspora_xml, user3.person + user.receive status_message6.to_diaspora_xml, user4.person - user.visible_posts(:by_members_of => first_aspect).should =~ [status_message1] - user.visible_posts(:by_members_of => second_aspect).should =~ [status_message2, status_message3] + user.visible_posts(:by_members_of => first_aspect).should =~ [status_message4] + user.visible_posts(:by_members_of => second_aspect).should =~ [status_message5, status_message6] end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index f222a7674..645563b9a 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -43,11 +43,12 @@ describe 'user encryption' do xml = request.to_diaspora_xml - remote_user.person.destroy - remote_user.destroy + remote_user.person.delete + remote_user.delete person_count = Person.all.count - proc {@user.receive xml}.should_not raise_error /ignature was not valid/ + @user.receive xml, remote_user.person + Person.all.count.should == person_count + 1 new_person = Person.first(:id => id) new_person.exported_key.should == original_key From d8439c82ee4fb25a10e254783b6f5582b54b4932 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 12 Oct 2010 12:21:57 -0700 Subject: [PATCH 05/26] going calling by webfinger only once --- lib/diaspora/user/receiving.rb | 10 ++++------ lib/salmon/salmon.rb | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index d5eb0e49d..b23cbcf52 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -14,14 +14,13 @@ module Diaspora Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}") Rails.logger.debug("From: #{object.person.inspect}") if object.person - sender_in_xml = sender(object, xml) if (salmon_author == sender_in_xml) if object.is_a? Retraction receive_retraction object, xml elsif object.is_a? Request - receive_request object, xml + receive_request object, sender_in_xml elsif object.is_a? Profile receive_profile object, xml elsif object.is_a?(Comment) @@ -30,7 +29,7 @@ module Diaspora receive_post object, xml end else - raise "Possibly 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} " + 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 end @@ -38,7 +37,7 @@ module Diaspora if object.is_a? Retraction sender = object.person elsif object.is_a? Request - sender = Diaspora::Parser.parse_or_find_person_from_xml( xml ) + sender = object.person elsif object.is_a? Profile sender = Diaspora::Parser.owner_id_from_xml xml elsif object.is_a?(Comment) @@ -62,8 +61,7 @@ module Diaspora end end - def receive_request request, xml - person = Diaspora::Parser.parse_or_find_person_from_xml( xml ) + def receive_request request, person person.serialized_public_key ||= request.exported_key request.person = person request.person.save diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index 728524b4d..26d2673d3 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -113,7 +113,7 @@ HEADER if @author @author else - Person.by_webfinger @author_email + @author ||= Person.by_webfinger @author_email end end From 6177362c4a2f832cedda95e574872ebabd2fe0d6 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 12 Oct 2010 21:22:49 +0200 Subject: [PATCH 06/26] Adding the ubuntu install package, initial version. T --- .gitignore | 1 + pkg/fedora/diaspora.spec | 35 ++++++++++ pkg/fedora/make-dist.sh | 13 ++-- pkg/ubuntu/README.md | 57 ++++++++++++++++ pkg/ubuntu/add-bundle.diff | 11 ++++ pkg/ubuntu/diaspora-bundle-install | 26 ++++++++ pkg/ubuntu/diaspora-install | 68 +++++++++++++++++++ pkg/ubuntu/diaspora-install-deps | 14 ++++ pkg/ubuntu/diaspora-reset | 12 ++++ pkg/ubuntu/diaspora-setup | 53 +++++++++++++++ pkg/ubuntu/diaspora-wsd | 102 +++++++++++++++++++++++++++++ pkg/ubuntu/diaspora.logrotate | 13 ++++ pkg/ubuntu/make-dist.sh | 1 + 13 files changed, 400 insertions(+), 6 deletions(-) create mode 100644 pkg/ubuntu/README.md create mode 100644 pkg/ubuntu/add-bundle.diff create mode 100755 pkg/ubuntu/diaspora-bundle-install create mode 100755 pkg/ubuntu/diaspora-install create mode 100755 pkg/ubuntu/diaspora-install-deps create mode 100755 pkg/ubuntu/diaspora-reset create mode 100755 pkg/ubuntu/diaspora-setup create mode 100755 pkg/ubuntu/diaspora-wsd create mode 100644 pkg/ubuntu/diaspora.logrotate create mode 120000 pkg/ubuntu/make-dist.sh diff --git a/.gitignore b/.gitignore index 67221f5e4..8482dc230 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ nbproject gpg/diaspora-development/*.gpg gpg/diaspora-production/*.gpg gpg/*/random_seed +patches-* public/uploads/* public/source.tar tmp/**/* diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index 0d07ddb43..ba2456a43 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -34,6 +34,10 @@ find . -perm /u+x -type f -exec \ %build rm -rf master/vendor/bundle +<<<<<<< HEAD +mkdir master/tmp || : +======= +>>>>>>> upstream/master %install rm -fr $RPM_BUILD_ROOT @@ -55,7 +59,14 @@ cp %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora +<<<<<<< HEAD +cp -ar master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master +cp diaspora-setup $RPM_BUILD_ROOT/%{_datadir}/diaspora +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 +>>>>>>> upstream/master mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads @@ -80,8 +91,25 @@ sed -i -e '\|.*/master/config.ru"$|d' \ %post +<<<<<<< HEAD +rm -f %{_datadir}/diaspora/master/vendor/bundle +rm -f %{_datadir}/diaspora/master/log +rm -f %{_datadir}/diaspora/master/public/uploads +rm -rf %{_datadir}/diaspora/master/tmp + +ln -s %{_localstatedir}/log/diaspora \ + %{_datadir}/diaspora/master/log || : +ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \ + %{_datadir}/diaspora/master/vendor || : +ln -s %{_localstatedir}/lib/diaspora/uploads \ + %{_datadir}/diaspora/master/public/uploads || : +ln -s %{_localstatedir}/lib/diaspora/tmp \ + %{_datadir}/diaspora/master/tmp || : +/sbin/chkconfig --add diaspora-ws || : +======= /sbin/chkconfig --add diaspora-wsd +>>>>>>> upstream/master %preun if [ $1 -eq 0 ] ; then @@ -96,15 +124,22 @@ rm -fr $RPM_BUILD_ROOT %files -f files %defattr(-, root, root, 0755) +<<<<<<< HEAD +%doc README.md GNU-AGPL-3.0 +======= %doc AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT README-Fedora.md +>>>>>>> upstream/master %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config.ru %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config/environment.rb %attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp +<<<<<<< HEAD +======= %{_datadir}/diaspora/master/tmp %{_datadir}/diaspora/master/public/uploads %{_datadir}/diaspora/master/log +>>>>>>> upstream/master %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-wsd diff --git a/pkg/fedora/make-dist.sh b/pkg/fedora/make-dist.sh index 3a24635ed..2ab4ccac5 100755 --- a/pkg/fedora/make-dist.sh +++ b/pkg/fedora/make-dist.sh @@ -126,8 +126,7 @@ function checkout() git clone --quiet $GIT_REPO; ( cd diaspora; - git remote add upstream \ - git://github.com/diaspora/diaspora.git + git remote add upstream $GIT_REPO for p in ../../*.patch; do git apply --whitespace=fix $p > /dev/null done &> /dev/null || : @@ -159,7 +158,6 @@ function make_src cd dist mkdir ${RELEASE_DIR}/master cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master - mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR} ( cd ${RELEASE_DIR}/master git show --name-only > config/gitversion @@ -168,6 +166,9 @@ function make_src find $PWD -name .git\* | xargs rm -rf rm -rf .bundle /usr/bin/patch -p1 -s <../../../add-bundle.diff + for p in ../../../*.patch; do + /usr/bin/patch -p1 -s < $p + done &> /dev/null || : ) tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ rm -rf ${RELEASE_DIR} @@ -203,7 +204,8 @@ function make_bundle() cd .. } echo - echo "Bundle: dist/$bundle_name.tar.gz" + echo "Repo: $GIT_REPO" + echo "Bundle: dist/$bundle_name.tar.gz" } @@ -278,9 +280,8 @@ function usage() EOF } - commit='HEAD' -while getopts ":r:c:h" opt +while getopts ":r:c:u:h" opt do case $opt in u) GIT_REPO="$OPTARG" diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md new file mode 100644 index 000000000..3aeaaab01 --- /dev/null +++ b/pkg/ubuntu/README.md @@ -0,0 +1,57 @@ +## Package-oriented install for ubuntu. + +Here are some scripts to install diaspora on Ubuntu. They are designed to +work as a first step towards packaging, but should be usable as is. + +### Synopsis + +Bootstrap the distribution from git: + git clone git://github.com/diaspora/diaspora.git + cd diaspora/pkg/ubuntu + +Install the dependencies (a good time for a coffe break) + ./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; + sudo ./diaspora-setup + sudo su - diaspora + cd /usr/share/diaspora/master + ./script/server + +### Notes + +The application lives in /usr/share/diaspora/master. All writable areas +(log, uploads, tmp) are links to /var/lib/diaspora. The config file lives +in /etc/diaspora. All files in /usr/share are read-only, owned by root. + +The bundle lives in /usr/lib/diaspora-bundle, readonly,owned by root. +Application finds it through the patched .bundle/config in root dir. + +The user diaspora is added during install. + +The 'make-dist-source' prints a message about the version of the bundle +it needs. Normally, it doesn't change and it's a fast procedure to generate +and install the source tarball. Generating the bundle takes some time, though. + +make-dist.sh accepts arguments to get a specified commit and/or use another +repo. + +This has been tested on a Ubuntu 32-bit 10.10 , clean server. Since this +is a very small dist, the dependencies should possibly be complete. + +The diaspora-wsd is just placeholder FTM, it does **not** work. + +Please, report any problems! + + + + + + diff --git a/pkg/ubuntu/add-bundle.diff b/pkg/ubuntu/add-bundle.diff new file mode 100644 index 000000000..24c0f6035 --- /dev/null +++ b/pkg/ubuntu/add-bundle.diff @@ -0,0 +1,11 @@ +diff --git a/.bundle/config b/.bundle/config +new file mode 100644 +index 0000000..1c3e2ce +--- /dev/null ++++ b/.bundle/config +@@ -0,0 +1,5 @@ ++--- ++BUNDLE_FROZEN: "1" ++BUNDLE_DISABLE_SHARED_GEMS: "1" ++BUNDLE_WITHOUT: test:rdoc ++BUNDLE_PATH: vendor/bundle diff --git a/pkg/ubuntu/diaspora-bundle-install b/pkg/ubuntu/diaspora-bundle-install new file mode 100755 index 000000000..caf95d4e8 --- /dev/null +++ b/pkg/ubuntu/diaspora-bundle-install @@ -0,0 +1,26 @@ +#!/bin/sh + +test "$(perl -e 'print $>')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +test $# = "1" || { + echo "Usage: diaspora-bundle-install " + exit 1 +} + +test -r "$1" || { + echo "Cannot open $1" + exit 2 +} + +rm -rf /usr/lib/diaspora-bundle +tar xf $1 -C /usr/lib + +cd /usr/lib +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 /usr/share/doc/diaspora-bundle diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install new file mode 100755 index 000000000..53d09acc6 --- /dev/null +++ b/pkg/ubuntu/diaspora-install @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Install a fedora source package +# +# Usage diaspora-install + +test "$(perl -e 'print $>')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +set -x + +getent group diaspora >/dev/null || groupadd -r diaspora +getent passwd diaspora >/dev/null || \ + useradd -r -g diaspora \ + -md /var/lib/diaspora \ + -s /bin/bash \ + -c "Diaspora daemon" diaspora + +sudo tar -C /usr/share -xzf $1 + +cd /usr/share; +rm -rf /usr/share/diaspora +mv $( basename $1 .tar.gz) diaspora +cd /usr/share/diaspora +find . -perm /u+x -type f -exec \ + sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null +rm -rf master/vendor/bundle master/public/uploads master/tmp master/log +sed -i '/BUNDLE_PATH/s|:.*|: /usr/lib/diaspora-bundle/bundle|' \ + master/.bundle/config + +cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS . +cp master/config/app_config.yml.example ./app_config.yml +cp master/pkg/ubuntu/diaspora-wsd /etc/init.d + +sed -i '/^cd /s|.*|cd /usr/share/diaspora/master|' /etc/init.d/diaspora-wsd + +cp master/pkg/ubuntu/diaspora.logrotate /etc/logrotate.d/diaspora + +cp master/pkg/ubuntu/diaspora-setup . + +mkdir -p /var/log/diaspora +mkdir -p /var/lib/diaspora/uploads +mkdir -p /var/lib/diaspora/tmp +mkdir -p /etc/diaspora + +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/bundle master/vendor + +rm -rf /usr/share/doc/diaspora +mkdir -p /usr/share/doc/diaspora +mv AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT /usr/share/doc/diaspora + +find ./ -print | xargs chown root:root +rm -rf /usr/share/doc/diaspora +mkdir /usr/share/doc/diaspora + +chown diaspora:diaspora /usr/share/diaspora/master/config.ru +chown diaspora:diaspora /usr/share/diaspora/master/config/environment.rb +chown diaspora:diaspora /var/log/diaspora +chown diaspora:diaspora /var/lib/diaspora/uploads +chown diaspora:diaspora /var/lib/diaspora/tmp +chown diaspora:diaspora /var/lib/diaspora diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps new file mode 100755 index 000000000..b919370d0 --- /dev/null +++ b/pkg/ubuntu/diaspora-install-deps @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Install diaspora dependencies i. e., what apt-get will do +# +set -x + +sudo apt-get update +sudo apt-get install -qy build-essential libxslt1-dev libxml2 ruby-full mongodb \ +rake python-software-properties git imagemagick libmagick9-dev +[starts mongodb] +sudo add-apt-repository ppa:maco.m/ruby +sudo apt-get update +sudo apt-get install -qy rubygems +sudo gem install bundler --bindir /usr/local/bin diff --git a/pkg/ubuntu/diaspora-reset b/pkg/ubuntu/diaspora-reset new file mode 100755 index 000000000..a5919a635 --- /dev/null +++ b/pkg/ubuntu/diaspora-reset @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Try to revert to pristine state, deleting all users and +# configuration +# + +set -x +service mongodb stop +rm -rf /var/lib/mongodb/* +cp /usr/share/diaspora/master/config/app_config.yml.example \ + /usr/share/diaspora/master/config/app_config.yml +service mongodb start diff --git a/pkg/ubuntu/diaspora-setup b/pkg/ubuntu/diaspora-setup new file mode 100755 index 000000000..56940491f --- /dev/null +++ b/pkg/ubuntu/diaspora-setup @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Do what's needed to initiate diaspora. +# + +test "$( perl -e 'print $<')" = "0" || { + echo "You need to be root to do this, giving up" + exit 2 +} + +services=$( netstat -nl | grep '[^:]:3000[ \t]') +test -n "$services" && { + echo "Warning: something is already using port 3000" + echo " $services" +} + +/usr/sbin/service mongodb start || : + +cd /usr/share/diaspora/master + +test -e config/app_config.yml || + cp config/app_config.yml.example config/app_config.yml + +if rake db:seed:dev; then + echo "Database config OK, new user tom/evankorth in place" +else + cat <<- EOF + + Database config failed. You might want to remove all db files with + 'rm -rf /var/lib/mongodb/*' and/or resetting the config file by + 'cp config/app_config.yml.example config/app_config.yml' before + making a new try. Also, make sure the mongodb server is running + e. g., using '/sbin/service mongod status'. + EOF + exit 1 +fi + +chmod 777 /var/lib/diaspora/uploads +chown -R diaspora /var/log/diaspora + +hostname=$( awk '/pod_url:/ { print $2; exit }' >$logfile 2>&1 &" + RETVAL=$? + echo + if test $RETVAL = 0; then + touch $lockfile + pgrep -f "$ruby_cmd" > $pidfile || { + echo "Warning: cannot find running diaspora-webserver" + exit 7 + } + fi +} + +stop() { + [ $UID -eq 0 ] || exit 4 + echo -n $"Stopping $prog: " + killproc -p $pidfile $exec + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $lockfile + echo +} + +# +# See how we were called. +# +case "$1" in + start) + start + ;; + stop) + stop + ;; + force-reload|restart) + stop + sleep 1 + start + RETVAL=$? + ;; + condrestart|try-restart) + if [ -f $lockfile ]; then + stop + sleep 3 + start + fi + ;; + status) + status -p $pidfile $exec + RETVAL=$? + ;; + *) + echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|force-reload|status}" + RETVAL=2 + [ "$1" = 'usage' ] && RETVAL=0 +esac + +exit $RETVAL diff --git a/pkg/ubuntu/diaspora.logrotate b/pkg/ubuntu/diaspora.logrotate new file mode 100644 index 000000000..28f158d2c --- /dev/null +++ b/pkg/ubuntu/diaspora.logrotate @@ -0,0 +1,13 @@ +/var/log/diaspora/*.log { + create 755 diaspora diaspora + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok + postrotate + ( /sbin/service diaspora-wsd condrestart ) >/dev/null 2>&1 + endscript +} diff --git a/pkg/ubuntu/make-dist.sh b/pkg/ubuntu/make-dist.sh new file mode 120000 index 000000000..f6ba9c6a2 --- /dev/null +++ b/pkg/ubuntu/make-dist.sh @@ -0,0 +1 @@ +../fedora/make-dist.sh \ No newline at end of file From 5bc174da151e9ba764f3136ebf641b93cd891e91 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 12 Oct 2010 21:24:21 +0200 Subject: [PATCH 07/26] Well, another gitignore ;) --- pkg/ubuntu/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pkg/ubuntu/.gitignore diff --git a/pkg/ubuntu/.gitignore b/pkg/ubuntu/.gitignore new file mode 100644 index 000000000..cb1bf7741 --- /dev/null +++ b/pkg/ubuntu/.gitignore @@ -0,0 +1,3 @@ +patches-* +dist +series From fac76296106134ba546ddc9bbb63a2120b98f7e3 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 12 Oct 2010 23:10:08 +0200 Subject: [PATCH 08/26] Minor bugfixes, discovered after checking in ubuntu stuff. --- pkg/ubuntu/README.md | 35 +++++++++++++++++++++++++++++------ pkg/ubuntu/diaspora-install | 3 +++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 3aeaaab01..3dd722626 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -1,11 +1,12 @@ ## Package-oriented install for ubuntu. -Here are some scripts to install diaspora on Ubuntu. They are designed to +Here are somediaspora-installdiaspora-install scripts to install diaspora on Ubuntu. They are designed to work as a first step towards packaging, but should be usable as is. ### Synopsis Bootstrap the distribution from git: + sudo apt-get install git git clone git://github.com/diaspora/diaspora.git cd diaspora/pkg/ubuntu @@ -25,20 +26,42 @@ Initiate and start the server; cd /usr/share/diaspora/master ./script/server +### Upgrading +Once diaspora ins installed ,makedist.sh et. al. are available in +/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout +the stuff using git in this case. + +The normal procedure to update is to just + $ sudo su - diaspora + $ cd /usr/share/diaspora/master/pkg/ubuntu + $ ./make-dist.sh bundle + $ ./make-dist.sh source + +And then use diaspore-install and diaspora-install-bundle as above. + +It's necessary to always have the correct bundle. The easy way is to just + $ ./make-dist.sh bundle + + Repo: http://github.com/diaspora/diaspora.git + Bundle: dist/diaspora-bundle-0.0-1010111342_afad554.tar.gz + +The command will return the last built bundle (which is cached) if it's +OK to use. If it's not, it will build a new. + ### Notes The application lives in /usr/share/diaspora/master. All writable areas (log, uploads, tmp) are links to /var/lib/diaspora. The config file lives in /etc/diaspora. All files in /usr/share are read-only, owned by root. -The bundle lives in /usr/lib/diaspora-bundle, readonly,owned by root. +The bundle lives in /usr/lib/diaspora-bundle, readonly, owned by root. Application finds it through the patched .bundle/config in root dir. -The user diaspora is added during install. +Once diaspora ins installed ,makedist.sh et. al. are available in +/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout +the stuff using git in this case. -The 'make-dist-source' prints a message about the version of the bundle -it needs. Normally, it doesn't change and it's a fast procedure to generate -and install the source tarball. Generating the bundle takes some time, though. +The user diaspora is added during install. make-dist.sh accepts arguments to get a specified commit and/or use another repo. diff --git a/pkg/ubuntu/diaspora-install b/pkg/ubuntu/diaspora-install index 53d09acc6..8717f8d56 100755 --- a/pkg/ubuntu/diaspora-install +++ b/pkg/ubuntu/diaspora-install @@ -44,6 +44,7 @@ mkdir -p /var/log/diaspora mkdir -p /var/lib/diaspora/uploads mkdir -p /var/lib/diaspora/tmp mkdir -p /etc/diaspora +mkdir -p /usr/share/diaspora/master/pkg/ubuntu/dist ln -sf /var/log/diaspora ./master/log cp master/config/app_config.yml.example /etc/diaspora/app_config.yml @@ -66,3 +67,5 @@ chown diaspora:diaspora /var/log/diaspora chown diaspora:diaspora /var/lib/diaspora/uploads chown diaspora:diaspora /var/lib/diaspora/tmp chown diaspora:diaspora /var/lib/diaspora +chown diaspora:diaspora /usr/share/diaspora/master/pkg/ubuntu/dist + From 00bcfaf34519ffe361af956b861b251360e8496a Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 12 Oct 2010 23:10:29 +0200 Subject: [PATCH 09/26] Check for universe enabled in diaspora-install-deps --- pkg/ubuntu/diaspora-install-deps | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps index b919370d0..56caa7200 100755 --- a/pkg/ubuntu/diaspora-install-deps +++ b/pkg/ubuntu/diaspora-install-deps @@ -2,12 +2,19 @@ # # Install diaspora dependencies i. e., what apt-get will do # -set -x + +grep -v '^#' /etc/apt/sources.list | grep -q universe || { + cat <<- EOF + "Warning: it looks like you have not enabled universe in your + /etc/apt/sources.list. Most likely, this means trouble. + But I will try anyway. + EOF + sleep 2 +} sudo apt-get update sudo apt-get install -qy build-essential libxslt1-dev libxml2 ruby-full mongodb \ -rake python-software-properties git imagemagick libmagick9-dev -[starts mongodb] + rake python-software-properties git imagemagick libmagick9-dev sudo add-apt-repository ppa:maco.m/ruby sudo apt-get update sudo apt-get install -qy rubygems From ca571432c2b9abe9688e283308cefabda245ac04 Mon Sep 17 00:00:00 2001 From: Shawn McGuire Date: Tue, 12 Oct 2010 12:20:22 -0700 Subject: [PATCH 10/26] Changed remaining http:// to git:// --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 0e74b4f45..63a350ef8 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'devise', '1.1.3' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' gem 'devise_invitable', '~> 0.3.4' #Mongo -gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git' +gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git' gem 'bson_ext', '1.1' gem 'bson', '1.1' @@ -32,7 +32,7 @@ gem 'thin' #Websocket gem 'em-websocket' -gem 'magent', :git => 'http://github.com/dcu/magent.git' +gem 'magent', :git => 'git://github.com/dcu/magent.git' #File uploading gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch From b5485205916eb61a6c45c5b65909d553d7a04a91 Mon Sep 17 00:00:00 2001 From: Shawn McGuire Date: Tue, 12 Oct 2010 16:40:10 -0500 Subject: [PATCH 11/26] Changed div.info color and font size to be larger and darker Issue #285 --- public/stylesheets/sass/application.sass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index d47f0d16f..1691755b3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -266,8 +266,8 @@ li.message :size 14px div.info - :color #eee - :font-size 11px + :color #444 + :font-size 14px a :color #ccc .time From 900a085124a0c7b8f22a678479e3d8650fa4a2a7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 12 Oct 2010 15:09:32 -0700 Subject: [PATCH 12/26] Merging in bigbash's fixes --- Gemfile.lock | 38 +++++++++++++++--------------- public/stylesheets/application.css | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a2a905cc5..d68bf5ce1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,6 +13,15 @@ GIT devise-mongo_mapper (0.0.1) devise (~> 1.1.0) +GIT + remote: git://github.com/dcu/magent.git + revision: fe08cc6e9d4c1772035f84bcfb665d17b00ac625 + specs: + magent (1.0.0) + em-websocket + mongo + uuidtools + GIT remote: git://github.com/igrigorik/em-http-request.git revision: bf62d67fc72d6e701be5037e239dd470194b8e45 @@ -22,6 +31,16 @@ GIT addressable (>= 2.0.0) eventmachine (>= 0.12.9) +GIT + remote: git://github.com/jnunemaker/mongomapper.git + revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d + branch: rails3 + specs: + mongo_mapper (0.8.4) + activemodel (~> 3.0.0) + activesupport (~> 3.0.0) + plucky (~> 0.3.6) + GIT remote: git://github.com/rsofaer/carrierwave.git revision: 9edb8bdddd2236742a85bfd7b260387498d01f88 @@ -47,25 +66,6 @@ GIT capistrano (>= 2.5.5) highline (>= 1.4.0) -GIT - remote: http://github.com/dcu/magent.git - revision: 5d664351b305141158fc69fc495456414821adb3 - specs: - magent (1.0.0) - em-websocket - mongo - uuidtools - -GIT - remote: http://github.com/jnunemaker/mongomapper.git - revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d - branch: rails3 - specs: - mongo_mapper (0.8.4) - activemodel (~> 3.0.0) - activesupport (~> 3.0.0) - plucky (~> 0.3.6) - GEM remote: http://rubygems.org/ specs: diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 15419a488..93f2efcf0 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -195,8 +195,8 @@ li.message { li.message .content .from a { font-weight: bold; } li.message .content div.info { - color: #eeeeee; - font-size: 11px; } + color: #444444; + font-size: 14px; } li.message .content div.info a { color: #cccccc; } li.message .content div.info .time { From 0896052b809c00e28028cabf6ac2f8e416a3b626 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 12 Oct 2010 15:31:54 -0700 Subject: [PATCH 13/26] remote comment spec, which passed surprisingly, the comment contains the person --- spec/models/comments_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 6a60086d5..b2f2d3c61 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -53,6 +53,30 @@ describe Comment do @user.reload end + it 'should receive a comment from a person not on the pod' do + user3 = Factory.create :user + aspect3 = user3.aspect(:name => "blah") + + friend_users(@user, @aspect, user3, aspect3) + + comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => @user_status) + comment.creator_signature = comment.sign_with_key(user3.encryption_key) + + + comment.post_creator_signature = comment.sign_with_key(@user.encryption_key) + xml = @user.salmon(comment).xml_for(@user2) + + user3.person.delete + user3.delete + + + @user_status.reload + @user_status.comments.should == [] + @user2.receive_salmon(xml) + @user_status.reload + @user_status.comments.include?(comment).should be true + end + it 'should have the post in the aspects post list' do aspect = Aspect.first(:id => @aspect.id) aspect.people.size.should == 2 From c818885b6eeaf632980b6d85389fa755a33788e0 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 00:35:50 +0200 Subject: [PATCH 14/26] Fixes after more tests --- pkg/ubuntu/README.md | 5 +---- pkg/ubuntu/diaspora-install-deps | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index 3dd722626..ff82a4c29 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -6,7 +6,7 @@ work as a first step towards packaging, but should be usable as is. ### Synopsis Bootstrap the distribution from git: - sudo apt-get install git + sudo apt-get install git-core git clone git://github.com/diaspora/diaspora.git cd diaspora/pkg/ubuntu @@ -27,9 +27,6 @@ Initiate and start the server; ./script/server ### Upgrading -Once diaspora ins installed ,makedist.sh et. al. are available in -/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout -the stuff using git in this case. The normal procedure to update is to just $ sudo su - diaspora diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps index 56caa7200..f4fd6be8b 100755 --- a/pkg/ubuntu/diaspora-install-deps +++ b/pkg/ubuntu/diaspora-install-deps @@ -13,8 +13,9 @@ grep -v '^#' /etc/apt/sources.list | grep -q universe || { } sudo apt-get update -sudo apt-get install -qy build-essential libxslt1-dev libxml2 ruby-full mongodb \ - rake python-software-properties git imagemagick libmagick9-dev +sudo apt-get install -qy --ignore-missing build-essential libxslt1-dev \ + libxml2 ruby-full mongodb rake python-software-properties git-core \ + imagemagick libmagick9-dev sudo add-apt-repository ppa:maco.m/ruby sudo apt-get update sudo apt-get install -qy rubygems From 9b249281a1c2abf49559c5b043b465e2cdcca3d2 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 12 Oct 2010 16:01:36 -0700 Subject: [PATCH 15/26] moved verify comment sig before any saving goes on --- lib/diaspora/user/receiving.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index b23cbcf52..3a8fc5fa6 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -79,12 +79,12 @@ module Diaspora def receive_comment comment, xml comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil? + raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature self.visible_people = self.visible_people | [comment.person] self.save Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil? comment.person.save Rails.logger.debug("From: #{comment.person.inspect}") if comment.person - raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature comment.save unless owns?(comment) dispatch_comment comment From 2a153316ced027b784dab7eb81ca0651aa0e9ed8 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 01:41:28 +0200 Subject: [PATCH 16/26] Not used --- pkg/ubuntu/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index ff82a4c29..bbf70362a 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -11,7 +11,7 @@ Bootstrap the distribution from git: cd diaspora/pkg/ubuntu Install the dependencies (a good time for a coffe break) - ./diaspora-install-deps + sudo ./diaspora-install-deps Create and install the diaspora bundle and application: ./make-dist.sh bundle @@ -60,6 +60,9 @@ the stuff using git in this case. The user diaspora is added during install. +Tools used for building package are installed globally. All of diasporas +dependencies lives in the nothing is insalled by user or on system level. + make-dist.sh accepts arguments to get a specified commit and/or use another repo. From fe0120cc0d1dca5859a5c768129cfc7d92a5b200 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 12 Oct 2010 18:18:03 -0700 Subject: [PATCH 17/26] Return everyone on an empty search --- app/models/person.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/person.rb b/app/models/person.rb index 2798ac3fb..8382c9d34 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -34,6 +34,7 @@ class Person /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix def self.search(query) + return Person.all if query.to_s.empty? qTokens = query.to_s.strip.split(" ") fullQueryText = Regexp.escape( query.to_s.strip ) p = [] From 3b82001a423772c35862ce2f87273dd952ed6e8b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 12 Oct 2010 18:19:31 -0700 Subject: [PATCH 18/26] Step down font size 1px in info --- public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 93f2efcf0..6bacdffbb 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -196,7 +196,7 @@ li.message { font-weight: bold; } li.message .content div.info { color: #444444; - font-size: 14px; } + font-size: 13px; } li.message .content div.info a { color: #cccccc; } li.message .content div.info .time { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 1691755b3..c70992407 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -267,7 +267,7 @@ li.message div.info :color #444 - :font-size 14px + :font-size 13px a :color #ccc .time From bbf396be42fa72a94707ed6e18f25a9b0cb66c8b Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Tue, 12 Oct 2010 19:08:50 -0700 Subject: [PATCH 19/26] Remove Gemfile.lock before each bundle install --- ci.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci.sh b/ci.sh index e631517e1..dd78a9b2c 100755 --- a/ci.sh +++ b/ci.sh @@ -4,6 +4,7 @@ echo "************************************************************************** echo "* ruby 1.8.7-p249 build *" && echo "*************************************************************************************************" && echo "" && +rm Gemfile.lock && source /usr/local/rvm/scripts/rvm && rvm use ruby-1.8.7-p249 && bundle install && @@ -13,8 +14,8 @@ echo "************************************************************************** echo "* ruby 1.9.2-p0 build *" && echo "*************************************************************************************************" && echo "" && +rm Gemfile.lock && source /usr/local/rvm/scripts/rvm && rvm use ruby-1.9.2-p0 && bundle install && -bundle exec rake ci && -rm Gemfile.lock \ No newline at end of file +bundle exec rake ci From 56c6688c8185cad5810b73e21fd93bc06ece79ba Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Tue, 12 Oct 2010 20:54:00 -0700 Subject: [PATCH 20/26] Take out reloads so specs run on 1.9.2 --- Gemfile.lock | 4 ++-- spec/models/user/user_friending_spec.rb | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d68bf5ce1..c92fae55d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,7 @@ GEM activemodel (= 3.0.0) activesupport (= 3.0.0) activesupport (3.0.0) - addressable (2.2.1) + addressable (2.2.2) arel (1.0.1) activesupport (~> 3.0.0) aws (2.3.21) @@ -172,7 +172,7 @@ GEM mini_fb (1.1.3) hashie rest-client - mini_magick (2.1) + mini_magick (2.3) subexec (~> 0.0.4) mocha (0.9.8) rake diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index e5ff6ad77..d2070a2f9 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -166,19 +166,22 @@ describe User do describe 'unfriending' do before do friend_users(user,aspect, user2, aspect2) + user.reload + user2.reload end it 'should unfriend the other user on the same seed' do - user.friends(true).count.should == 1 - user2.friends(true).count.should == 1 + user.friends.count.should == 1 + user2.friends.count.should == 1 user2.unfriend user.person + user2.reload - user2.friends(true).count.should == 0 + user2.friends.count.should == 0 user.unfriended_by user2.person - aspect.reload.people(true).count.should == 0 - aspect2.reload.people(true).count.should == 0 + aspect.reload.people.count.should == 0 + aspect2.reload.people.count.should == 0 end context 'with a post' do @@ -189,10 +192,10 @@ describe User do user.unfriended_by user2.person end it "deletes the unfriended user's posts from visible_posts" do - user.raw_visible_posts(true).include?(@message.id).should be_false + user.reload.raw_visible_posts.include?(@message.id).should be_false end it "deletes the unfriended user's posts from the aspect's posts" do - aspect2.posts(true).include?(@message).should be_false + aspect2.posts.include?(@message).should be_false end end end From e922a3be5c8f3553a728bb931284c9f1d668e82a Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 08:29:24 +0200 Subject: [PATCH 21/26] Ubuntu 10.10 desktop fixes --- pkg/ubuntu/diaspora-install-deps | 2 +- pkg/ubuntu/diaspora-setup | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/ubuntu/diaspora-install-deps b/pkg/ubuntu/diaspora-install-deps index f4fd6be8b..e3a307ef7 100755 --- a/pkg/ubuntu/diaspora-install-deps +++ b/pkg/ubuntu/diaspora-install-deps @@ -15,7 +15,7 @@ grep -v '^#' /etc/apt/sources.list | grep -q universe || { sudo apt-get update sudo apt-get install -qy --ignore-missing build-essential libxslt1-dev \ libxml2 ruby-full mongodb rake python-software-properties git-core \ - imagemagick libmagick9-dev + imagemagick libmagick9-dev xulrunner-1.9 sudo add-apt-repository ppa:maco.m/ruby sudo apt-get update sudo apt-get install -qy rubygems diff --git a/pkg/ubuntu/diaspora-setup b/pkg/ubuntu/diaspora-setup index 56940491f..9e7da6fc2 100755 --- a/pkg/ubuntu/diaspora-setup +++ b/pkg/ubuntu/diaspora-setup @@ -14,7 +14,9 @@ test -n "$services" && { echo " $services" } -/usr/sbin/service mongodb start || : +service mongodb stop || : +rm -f /var/lib/mongodb/mongod.lock +service mongodb start || : cd /usr/share/diaspora/master @@ -26,11 +28,13 @@ if rake db:seed:dev; then else cat <<- EOF - Database config failed. You might want to remove all db files with - 'rm -rf /var/lib/mongodb/*' and/or resetting the config file by - 'cp config/app_config.yml.example config/app_config.yml' before - making a new try. Also, make sure the mongodb server is running - e. g., using '/sbin/service mongod status'. + Database config failed. You might want to + - Just remove the db lock file: rm /var/lib/mongodb/mongod.lock + - Remove all db files: rm -rf /var/lib/mongodb/* + - Reset the config file by + cp config/app_config.yml.example config/app_config.yml + Also, make sure the mongodb server is running e. g., using + 'service mongod status'. EOF exit 1 fi From ea185ccf6a147a95d0753fa89ffbfee69b0fed5d Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 10:23:06 +0200 Subject: [PATCH 22/26] Resolving merge conflict... My bad, apologies --- pkg/fedora/diaspora.spec | 44 +++++----------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/pkg/fedora/diaspora.spec b/pkg/fedora/diaspora.spec index ba2456a43..b4bd62b5d 100644 --- a/pkg/fedora/diaspora.spec +++ b/pkg/fedora/diaspora.spec @@ -1,9 +1,9 @@ %global debug_package %{nil} -%define git_release HEAD +%define git_release 1010092232_b313272 Summary: A social network server Name: diaspora -Version: 0.0.1 +Version: 0.0 Release: 1.%{git_release}%{?dist} License: AGPLv3 Group: Applications/Communications @@ -19,7 +19,7 @@ BuildRoot: %{_rmpdir}/not-used-in-fedora/ Requires: mongodb-server Requires: ruby(abi) = 1.8 -Requires: diaspora-bundle = %{version} +Requires: diaspora-bundle = 0.0-1.1010081636_d1a4ee0.fc13 %description @@ -34,10 +34,6 @@ find . -perm /u+x -type f -exec \ %build rm -rf master/vendor/bundle -<<<<<<< HEAD -mkdir master/tmp || : -======= ->>>>>>> upstream/master %install rm -fr $RPM_BUILD_ROOT @@ -59,14 +55,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 -<<<<<<< HEAD -cp -ar master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master -cp diaspora-setup $RPM_BUILD_ROOT/%{_datadir}/diaspora -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 ->>>>>>> upstream/master mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads @@ -91,25 +80,8 @@ sed -i -e '\|.*/master/config.ru"$|d' \ %post -<<<<<<< HEAD -rm -f %{_datadir}/diaspora/master/vendor/bundle -rm -f %{_datadir}/diaspora/master/log -rm -f %{_datadir}/diaspora/master/public/uploads -rm -rf %{_datadir}/diaspora/master/tmp - -ln -s %{_localstatedir}/log/diaspora \ - %{_datadir}/diaspora/master/log || : -ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \ - %{_datadir}/diaspora/master/vendor || : -ln -s %{_localstatedir}/lib/diaspora/uploads \ - %{_datadir}/diaspora/master/public/uploads || : -ln -s %{_localstatedir}/lib/diaspora/tmp \ - %{_datadir}/diaspora/master/tmp || : -/sbin/chkconfig --add diaspora-ws || : -======= /sbin/chkconfig --add diaspora-wsd ->>>>>>> upstream/master %preun if [ $1 -eq 0 ] ; then @@ -124,27 +96,21 @@ rm -fr $RPM_BUILD_ROOT %files -f files %defattr(-, root, root, 0755) -<<<<<<< HEAD -%doc README.md GNU-AGPL-3.0 -======= %doc AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT README-Fedora.md ->>>>>>> upstream/master %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config.ru %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config/environment.rb %attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp -<<<<<<< HEAD -======= %{_datadir}/diaspora/master/tmp %{_datadir}/diaspora/master/public/uploads %{_datadir}/diaspora/master/log ->>>>>>> upstream/master %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %{_sysconfdir}/init.d/diaspora-wsd %changelog -* Fri Sep 24 2010 Alec Leamas 0.0-1.1009280542_859ec2d +* Fri Sep 24 2010 Alec Leamas 0.0-1.1010092232_b313272.fc13 + - Initial attempt to create a spec fi+le # rubygem-term-ansicolor in repo (1.0.5) From 8c2ccfc5a8fb2acf86a36e79984b7f6eae79d384 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 10:34:32 +0200 Subject: [PATCH 23/26] Updating to reflect new tests on 10.04 desktop. --- pkg/ubuntu/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/ubuntu/README.md b/pkg/ubuntu/README.md index ff82a4c29..b8f3f7987 100644 --- a/pkg/ubuntu/README.md +++ b/pkg/ubuntu/README.md @@ -63,8 +63,13 @@ The user diaspora is added during install. make-dist.sh accepts arguments to get a specified commit and/or use another repo. -This has been tested on a Ubuntu 32-bit 10.10 , clean server. Since this -is a very small dist, the dependencies should possibly be complete. +This has been tested on a Ubuntu 32-bit 10.10 , clean server and on 10.04 +Lucid desktop, also clean installation. + +mongodb is having problems occasionally. Sometimes the dependencies are not +installed, and mongod refuses to start. invoke /usr/bin/mongod -f /etc/mongodb.conf +fo test. The lockfile /var/lib/mongodb/mongod.conf is also a potential +problem. Remove to make it start again. The diaspora-wsd is just placeholder FTM, it does **not** work. From 49975d7010001be9ac6e3f5b12a52018ccb2cd32 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 12:26:52 +0200 Subject: [PATCH 24/26] Providing better message if port 3000 is in use, closing ticket 287. --- script/server | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/script/server b/script/server index c5357a32e..adfced9aa 100755 --- a/script/server +++ b/script/server @@ -1,4 +1,16 @@ #!/bin/bash +# +# Start diaspora websocket and main services +# +# See issue 287 + +# Is someone listening on 3000 already? (ipv4 only test ?) +services=$( netstat -nl | grep '[^:]:3000[ \t]') +test -n "$services" && { + echo "Warning: something is already using port 3000" + echo " $services" +} + # Check if Mongo is running From ccdc259838c3dbbc047d4b23bff2f9ce8a780ca9 Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Wed, 13 Oct 2010 12:50:29 +0200 Subject: [PATCH 26/26] Comment update --- script/server | 1 - 1 file changed, 1 deletion(-) diff --git a/script/server b/script/server index adfced9aa..130b61220 100755 --- a/script/server +++ b/script/server @@ -2,7 +2,6 @@ # # Start diaspora websocket and main services # -# See issue 287 # Is someone listening on 3000 already? (ipv4 only test ?) services=$( netstat -nl | grep '[^:]:3000[ \t]')