Bundle: add licenses, handle git gems

Adding a docs dir collexting README and licenses from contained gems.
git gems, which bundler does not handle well today, are handled
by a hacked parsing of Gemfile.log, gem built into the source
bundle and installed on target system
This commit is contained in:
Alec Leamas 2010-10-25 04:04:34 +02:00
parent b17ae0bf38
commit 31b3d739c0
6 changed files with 218 additions and 52 deletions

99
pkg/Licenses Normal file
View file

@ -0,0 +1,99 @@
abstract: Ruby
actionmailer: MIT
actionpack: MIT
activemodel: MIT
activerecord: MIT
activeresource: ? (Other distros uses MIT, "Ruby-alike", no pointers)
activesupport: MIT
addressable: MIT
arel: MIT
aws MIT
bcrypt-ruby: MIT
builder: MIT
bunny: MIT
capistrano: MIT
capybara: MIT
chef: ASL 2.0
childprocess: MIT
columnize: GPLv2
crack: MIT
cucumber: MIT
cucumber-rails: MIT
culerity: MIT
daemons: Ruby+MIT
database_cleaner: MIT
devise: MIT
devise_invitable MIT
diff Ruby+GPLv2+ Artistic 2.0
em-websocket: MIT
eribus: MIT
event-machine: Ruby+GPLv2
extlib: MIT
factory_girls MIT
factory_girls_rails: MIT
ffi MIT
haml MIT
http_connection: MIT
gherkin: MIT
hashie: MIT
highline GPLv2+Ruby
json: Ruby
json-pure: Ruby
launchy: MIT
linecache: GPLv2
mail: MIT
mime-types: GPLv2+Ruby+Artistic 2.0
mini_magick: MIT
mini_fb: ?
mixlib-authentication: ASL 2.0
mixlib-cli ASL 2.0
mixlib-config ASL 2.0
mixlib-log ASL 2.0
mocha Ruby+MIT
moneta: MIT
mongo: ASL 2.0
net-scp: MIT
net-sftp: MIT
net-ssh: MIT
net-ssh-gatawey: MIT
ohai: ASL 2.0
plucky: MIT
polyglot. MIT
pubsubhubbub: ASL 2.0 http://code.google.com/p/pubsubhubbub/
rake: MIT
rack-mount: MIT
rack-test: MIT
railties: MIT
rest-client: MIT
rspec-core: MIT
rspec-expectations: MIT
rspec-mocks: MIT
rspec-rails: MIT
rack: MIT
rack-mount: MIT
ruby-debug: MIT
ruby-debug-base: MIT
rubyzip: Ruby
selenium-webdriver: ASL 2.0
subexec: MIT
term-ansicolor: GPLv2
textile. MIT
textile-warden: MIT
thin: MIT
thor: MIT
treetop: MIT
tx-info: MIT
uutdtools: MIT
iwarden: MIT
webmock: MIT
will-paginate MIT

View file

@ -1,3 +1,4 @@
TODO
dist
.stgit*
vendor

View file

@ -38,9 +38,16 @@ Source file usede to compile native libraries in diaspora-bundle.
%setup -q -n %{name}-%{version}-%{git_release}
%build
mkdir -p vendor/cache
mv *.gem vendor/cache
bundle install --local --deployment --without ri rdoc
bundle install --local --deployment --without ri rdoc test
for gem in vendor/git/*; do
gem install --local \
--force \
--no-rdoc \
--no-ri \
--install-dir vendor/bundle/ruby/1.8/bundler \
$gem
done
pushd vendor/bundle/ruby/1.8/gems
# In repo (2.2.4)
@ -200,7 +207,7 @@ popd
}
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle
cp -ar vendor/bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle
cp -ar vendor $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle
find %{buildroot}/%{_libdir}/diaspora-bundle \
-type d -fprintf dirs '%%%dir "%%p"\n'
@ -218,7 +225,7 @@ cat files >> dirs && cp dirs files
%files -f files
%defattr(-, diaspora, diaspora, 0755)
%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0
%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0 docs
%files -f dev-files devel
%defattr(-, root, root, 0644)

View file

@ -49,13 +49,12 @@ find . -perm /u+x -type f -exec \
%build
rm -rf master/vendor/bundle
mkdir master/tmp || :
%install
rm -fr $RPM_BUILD_ROOT
sed -i \
'/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/bundle|' \
'/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/vendor/bundle|' \
master/.bundle/config
cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS .

View file

@ -138,7 +138,7 @@ function checkout()
cd diaspora;
git fetch --quiet upstream
git merge --quiet upstream/master
git checkout --quiet ${1:-'HEAD'}
[ -n "$1" ] && git reset --hard --quiet $1
git_id -n
)
}
@ -175,41 +175,91 @@ function make_src
echo "Required bundle: $(git_id dist/diaspora/Gemfile)"
}
function get_git_repos()
function build_git_gems()
# Usage: build_git_gems <Gemfile> <tmpdir> <gemdir>
# Horrible hack, in wait for bundler handling git gems OK.
{
grep -A 2 GIT $1 |
awk ' /remote:/ { repo = $2 }
/revision:/ { printf "%s=%s\n",repo, $2}'
mkdir gem-tmp || :
cd gem-tmp
rm -rf *
grep 'git:' ../$1 | sed 's/,/ /' | awk '
/^.*git:\/\/.*$/ {
gsub( "=>", "")
gsub( ",", "")
if ( $1 != "gem") {
print "Strange git: line (ignored) :" $0
next
}
function package_git_gems()
{
gemfile="$1"
dest="$2"
rm -rf git-tmp
mkdir git-tmp
cd git-tmp
for repo in $( get_git_repos $1); do
url=${repo%%=*}
rev=${repo##*=}
name=${url##*/}
name="${name%.git}"
rm -rf "$name"
git clone "$url" "$name"
cd $name
git reset --hard $rev
sed -i '/s.date/s/Date.today/"2010-09-25"/' *.gemspec
name = $2
suffix = ""
url=""
for (i = 3; i <= NF; i += 1) {
key = $i
i += 1
if (key == ":git")
url = $i
else if ( key == ":ref") {
suffix = "; cd " name
suffix = suffix "; git reset --hard " $i
suffix = suffix "; cd .."
}
else if ( key == ":branch")
suffix = "; git checkout " $i
}
print "Running: ", cmd
cmd = sprintf( "git clone --quiet %s %s %s\n",
url, name, suffix)
system( cmd)
}'
sed -i 's/Date.today/"2010-10-24"/' carrierwave/carrierwave.gemspec
for dir in *; do
cd $dir
gem build *.gemspec
cp *.gem $dest
echo "Built GIT gem $name (*.gem)"
echo "Where: $dest"
cp *.gem ../../$2
cd ..
done
cd ..
# rm -rf gem-tmp
}
function make_docs()
{
local gemfile=$1
for url in $(read_git_urls $gemfile); do
local name=${url##*/}
name=${name%.*}
rm -rf vendor/git/$name
git clone --bare --quiet $url vendor/git/$name &&
sed -i "s#$url#vendor/git/$name#" $gemfile ||
echo "Cannot fix git repo \"$url\""
done
}
function make_docs()
{
local gems=$1
local dest=$2
for gem in $(ls $gems); do
local name=$(basename $gem)
[ -r $gems/$gem/README* ] && {
local readme=$(basename $gems/$gem/README*)
cp -a $gems/$gem/$readme $dest/$readme.$name
}
[ -r $gems/$gem/COPYRIGHT ] && \
cp -a $gems/$gem/COPYRIGHT $dest/COPYRIGHT.$name
[ -r $gems/$gem/LICENSE ] && \
cp -a $gems/$gem/LICENSE $dest/LICENSE.$name
[ -r $gems/$gem/License ] && \
cp -a $gems/$gem/License $dest/License.$name
[ -r $gems/$gem/MIT-LICENSE ] && \
cp -a $gems/$gem/MIT-LICENSE $dest/MIT-LICENSE.$name
[ -r $gems/$gem/COPYING ] && \
cp -a $gems/$gem/COPYING $dest/COPYING.$name
done
}
@ -219,8 +269,8 @@ function make_bundle()
#
{
checkout ${1:-'HEAD'} >/dev/null
bundle_id=$( git_id dist/diaspora/Gemfile)
bundle_name="diaspora-bundle-$VERSION-$bundle_id"
local bundle_id=$( git_id dist/diaspora/Gemfile)
local bundle_name="diaspora-bundle-$VERSION-$bundle_id"
test -e "dist/$bundle_name.tar.gz" || {
echo "Creating bundle $bundle_name"
cd dist
@ -231,22 +281,25 @@ function make_bundle()
rm -rf .bundle
bundle update
fi
bundle install --deployment
[ -d 'vendor/git' ] || mkdir vendor/git
bundle install
bundle package
package_git_gems "$PWD/Gemfile.lock" "$PWD/vendor/cache"
mkdir vendor/git
build_git_gems Gemfile vendor/git
mkdir -p "../$bundle_name/docs"
mkdir -p "../$bundle_name/vendor"
cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \
vendor/cache
cd vendor
mv cache $bundle_name
tar czf ../../$bundle_name.tar.gz $bundle_name
mv $bundle_name cache
cd ..
../$bundle_name
make_docs "vendor/gems" "../$bundle_name/docs"
mv vendor/cache ../$bundle_name/vendor
cd ..
tar czf $bundle_name.tar.gz $bundle_name
mv $bundle_name/vendor/cache diaspora/vendor/cache
cd ..
}
echo
echo "Bundle: dist/$bundle_name.tar.gz"
echo "Current dir:$PWD"
}

View file

@ -23,11 +23,18 @@ mv $(basename $1 .tar.gz) diaspora-bundle
mkdir -p /usr/share/doc/diaspora-bundle || :
cd /usr/lib/diaspora-bundle
cp AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \
cp -a AUTHORS GNU-AGPL-3.0 COPYRIGHT Gemfile Gemfile.lock \
/usr/share/doc/diaspora-bundle
mkdir -p vendor/cache
mv *.gem vendor/cache
cp -ar docs /usr/share/doc/diaspora-bundle
bundle install --local --deployment --without ri rdoc
for gem in vendor/git/*; do
gem install --local \
--force \
--no-rdoc \
--no-ri \
--install-dir vendor/bundle/ruby/1.8/bundler \
$gem
done