Merge branch 'master' into ohai-javascript-improvements

Conflicts:
	pkg/ubuntu/dist
This commit is contained in:
Raphael 2010-11-01 16:34:21 -07:00
commit de52e59727
53 changed files with 830 additions and 592 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -11,6 +11,8 @@ class StatusMessage < Post
key :message, String
validates_presence_of :message
attr_accessible :message
def to_activity
<<-XML
<entry>

View file

@ -40,8 +40,11 @@ class User
validates_presence_of :username
validates_uniqueness_of :username, :case_sensitive => false
validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/
validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?}
validates_length_of :username, :maximum => 32
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?}
validates_associated :person
one :person, :class_name => 'Person', :foreign_key => :owner_id
@ -142,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)
@ -198,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

View file

@ -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

View file

@ -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')

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -44,7 +44,7 @@
.submit_block
= link_to t('.cancel'), edit_user_path(current_user)
or
= t('.or')
= f.submit t('.change_password')
%h3

View file

@ -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:

View file

@ -4,4 +4,8 @@
# 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
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

View file

@ -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: ".فيه بلوى كبيرة حصلت"

View file

@ -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"

View file

@ -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:

View file

@ -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")

View file

@ -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

View file

@ -21,17 +21,22 @@ 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|
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} "
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 +55,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,13 +68,10 @@ 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
else
object.person = webfingered_person
if object.is_a?(Comment)
sender = (owns?(object.post))? object.person : object.post.person
else
@ -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)
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
request.save

2
pkg/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
dist
*.log

15
pkg/README.md Normal file
View file

@ -0,0 +1,15 @@
## 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.
- bootstrap-fedora-diaspora.sh. does the same for Fedora.
- 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

View file

@ -1,48 +1,127 @@
#!/bin/bash
#
# Install diaspora, its dependencies and start.
#
# Usage: pkg/bootstrap-fedora-diaspora.sh [external hostname]
#
# Synopsis, install:
# $ git clone git@github.com:diaspora/diaspora.git
# $ cd diaspora
# $ 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
# 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.
#
# Must run as root
export DIASPORADIR=`pwd`
GIT_REPO='git@github.com:leamas/diaspora.git'
DIASPORA_HOSTNAME=${1:-'mumin.dnsalias.net'}
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"
test $UID = "0" || {
echo "You need to be root to do this, giving up"
exit 2
}
echo "####"
echo "Installing RVM ..."
echo "####"
sleep 3
[[ -d config && -d script ]] || {
echo Error: "this is not a diaspora base directory"
exit 3
}
yum install -y git bison sqlite-devel gcc-c++ patch \
readline-devel zlib-devel libyaml-devel libffi-devel \
ImageMagick libxslt-devel libxml2-devel \
openssl-devel mongodb-server wget \
make autoconf automake
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
getent group diaspora >/dev/null || groupadd diaspora
getent passwd diaspora >/dev/null || {
useradd -g diaspora -s /bin/bash -m diaspora
echo "Created user diaspora"
}
echo "####"
echo "Installing RVM into bashrc and sourcing bash ..."
echo "####"
sleep 3
home=$( getent passwd diaspora | cut -d: -f6)
[ -e $home/diaspora ] && {
echo "Moving existing $home/diaspora out of the way"
mv $home/diaspora $home/diaspora.$$
}
mkdir $home/diaspora
cp -ar * $home/diaspora
chown -R diaspora $home/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
service mongod start
su - diaspora << EOF
#set -x
cd diaspora
[ -e "\$HOME/.rvm/scripts/rvm" ] || {
echo '#### Installing rvm ####'
wget http://rvm.beginrescueend.com/releases/rvm-install-head
bash < rvm-install-head && rm rvm-install-head
if [[ -s "\$HOME/.rvm/scripts/rvm" ]]; then
. "\$HOME/.rvm/scripts/rvm"
else
echo "Error: rvm installation failed";
exit 1;
fi
touch \$HOME/.bashrc
grep -q "rvm/scripts/rvm" \$HOME/.bashrc || {
echo '[[ -s "\$HOME/.rvm/scripts/rvm" ]] && \
source "\$HOME/.rvm/scripts/rvm"' \
>> \$HOME/.bashrc
}
}
source \$HOME/.bashrc
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
bundle install
rvm install ruby-1.8.7-p302
rvm --default ruby-1.8.7
#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 "####"
echo "Installing bundler ..."
echo "####"
sleep 3
gem install bundler
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
echo "Starting server"
script/server
EOF
echo "####"
echo "Installing deps with bundle ..."
echo "####"
sleep 3
pushd $DIASPORADIR && bundle install && popd

View file

@ -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:
@ -18,16 +17,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/tree/master/pkg/source/)
Setup links from tarballs to RPM source directory and create spec files:
% ./prepare-rpm.sh
Build rpms:
rpmbuild -ba dist/diaspora.spec
@ -51,75 +54,21 @@ 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.
prepare-rpm.sh prepare creates links also for all files listed in SOURCES.
Typically, this is secondary sources. *make-dist.sh source*
#### Notes
The source tarball is as retrieved from diaspora with following differences:
prepare-rpm.sh prepare creates links also for all files listed in SOURCES.
Typically, this is secondary sources.
- 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*
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
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*.
The spec-files in dist/ are patched by *./prepare-rpm.sh to reference
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 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
@ -128,17 +77,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
@ -154,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:

169
pkg/fedora/prepare-rpm.sh Executable file
View file

@ -0,0 +1,169 @@
#!/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 <file> <version> <commit_id> <release>
# Patches:\
# * Fri Sep 24 2010 name surname <email@com> 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 <specfile> <version> <commit>
# 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 <version> <commit> <release>
{
sed -e "/^%define/s|HEAD|$2|" \
-e '/^Version:/s|.*|Version: '$1'|' \
<diaspora.spec >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.
-u uri Git repository URI, defaults to
$GIT_REPO.
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:u:h" opt
do
case $opt in
r) RELEASE="$OPTARG:"
;;
h) usage
exit 0
;;
u) GIT_REPO="$OPTARG"
;;
*) 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

74
pkg/source/README.md Normal file
View file

@ -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.

108
pkg/source/funcs.sh Normal file
View file

@ -0,0 +1,108 @@
#
# 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 checkout Gemfile Gemfile.lock
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 init_appconfig
# Edit pod_url in hostname
# Silently uses argumetn if present, else run dialog.
# Usage: init_appconfig <app_config.yml> [hostname]
{
config=$1
arg_hostname="$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
}

View file

@ -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 <file> <version> <commit_id> <release>
# Patches:\
# * Fri Sep 24 2010 name surname <email@com> 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 <specfile> <version> <commit>
# 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 <version> <commit> <release>
{
sed -e "/^%define/s|HEAD|$2|" \
-e '/^Version:/s|.*|Version: '$1'|' \
<diaspora.spec >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 <commit>
{
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 <Gemfile> <tmpdir> <gemdir>
@ -213,6 +46,38 @@ function build_git_gems()
# rm -rf gem-tmp
}
function make_src
# Create a distribution tarball
# Usage: make src <commit>
{
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]
@ -280,6 +146,7 @@ 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
@ -289,65 +156,16 @@ function make_bundle()
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] <dist|bundle|prepare>
Usage: make-dist [options] <dist|bundle>
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
;;

View file

@ -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/tree/master/pkg/source/)
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

View file

@ -1,11 +0,0 @@
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

View file

@ -43,12 +43,20 @@ mkdir -p /var/lib/diaspora/tmp
mkdir -p /var/run/diaspora
mkdir -p /etc/diaspora
bundle='/usr/lib/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
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

1
pkg/ubuntu/dist Symbolic link
View file

@ -0,0 +1 @@
../source/dist/

View file

View file

@ -1 +0,0 @@
../fedora/make-dist.sh

View file

@ -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
lambda {post :create, status_message_hash}.should raise_error /failed save/
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

View file

@ -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

View file

@ -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,17 @@ describe Diaspora::Parser do
end
it "should create a new person upon getting a person request" do
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
new_person = Factory.build(:person)
xml = request.to_diaspora_xml
user3.destroy
person.destroy
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
Person.should_receive(:by_account_identifier).and_return(new_person)
request = Request.instantiate(:to =>"http://www.google.com/", :from => new_person)
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
lambda { user.receive xml, new_person }.should change(Person, :count).by(1)
end
end
it "should activate the Person if I initiated a request to that url" do
@ -73,13 +62,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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -106,6 +106,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

View file