Skip to content

Instantly share code, notes, and snippets.

@buzztaiki
Created May 14, 2014 15:55
Show Gist options
  • Save buzztaiki/ac95810f6908152300e5 to your computer and use it in GitHub Desktop.
Save buzztaiki/ac95810f6908152300e5 to your computer and use it in GitHub Desktop.
Tracのプラグイン開発のときに使えそうなRakefile
require 'open-uri'
TRAC = File.expand_path('~/opt/trac')
TRAC_VERSION = ">=1.0"
TRAC_PORT = 5678
TRAC_LOGO = 'https://dl.dropboxusercontent.com/s/332tsy8usmpmynm/trac_logo.png'
# TRAC = File.expand_path('~/opt/trac-0.12')
# TRAC_VERSION = '==0.12'
def tracadmin(args)
sh "trac-admin #{TRAC} #{args}"
end
namespace :trac do
desc 'install trac'
task :install do
sh "pip install trac#{TRAC_VERSION}"
if TRAC_VERSION.include?('0.1')
sh "pip install --upgrade Genshi==0.6"
end
tracadmin "initenv"
open("#{TRAC}/htdocs/trac_logo.png", 'w') do |f|
open(TRAC_LOGO, 'rb') {|r| FileUtils.copy_stream(r, f)}
end
end
desc 'uninstall trac'
task :uninstall do
rm_rf TRAC
["trac", "Genshi"].each do |pkg|
sh "pip uninstall -y #{pkg}" do |ok, res|
# ignore error
end
end
end
desc 'configure trac'
task :configure do
tracadmin "permission add anonymous TRAC_ADMIN"
tracadmin "config set logging log_level INFO"
tracadmin "config set logging log_type stderr"
tracadmin "config set components tracopt.versioncontrol.git.* enabled"
tracadmin "config set header_logo alt Trac"
tracadmin "config set header_logo src site/logo.png"
tracadmin "config set trac repository_dir #{TRAC}/repo"
tracadmin "config set trac repository_type git"
end
end
desc 'install plugin'
task :install do
sh "python setup.py develop -mxd #{TRAC}/plugins"
end
desc 'run tracd'
task :run do
sh "tracd -p #{TRAC_PORT} #{TRAC}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment