aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xqi234
-rw-r--r--setup/qi_libs.rb521
-rw-r--r--setup/qi_libs_base.rb345
4 files changed, 1102 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 34ee93ad..5dec69fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
\#*
*.gem
*.gemspec
+*.qi
+*.qi.rb
diff --git a/qi b/qi
new file mode 100755
index 00000000..27516a67
--- /dev/null
+++ b/qi
@@ -0,0 +1,234 @@
+#!/usr/bin/env ruby
+=begin
+ Common Rakefile, Rantfile installer for SiSU
+ softlink Rakefile and Rantfile to this file
+
+ * Homepage: <http://www.jus.uio.no/sisu/SiSU>
+ <http://search.sisudoc.org>
+ * Download: <http://www.jus.uio.no/sisu/download>
+
+ Copyright (C) 2007 Ralph Amissah
+
+ * License: LGPL - GNU Lesser General Public License
+ [same license as Rant provided within the Rant package]
+
+ * Ralph Amissah <ralph@amissah.com>
+ Ralph Amissah <ralph.amissah@gmail.com>
+
+ Rake is a Ruby build program by Jim Weirich
+ * Rake may be downloaded and installed from:
+ <http://rake.rubyforge.org/>
+
+ Rant is a Ruby build program by Stefan Lang
+ * Rant may be downloaded and installed from:
+ <http://make.rubyforge.org/>
+
+ Notes on use:
+ [if rake is preferred and installed]
+ rake -T
+ [if rant is preferred and installed]
+ rant -T
+
+ SiSU can also be Setup/Installation using:
+ * Minero Aoki's setup.rb, provided along with SiSU, or
+
+=end
+#%% produce a makefile suitable for the target platform
+#require 'mkmf'
+#create_makefile("sisu")
+#% manual settings, edit/update as required (note current default settings are obtained from sisu version yml file)
+begin
+ require 'thor'
+rescue LoadError
+ puts 'thor (package ruby-thor) not found'
+end
+require_relative 'setup/sisu_version' # setup/sisu_version.rb
+ include SiSUversion
+require_relative 'setup/qi_libs' # setup/qi_libs.rb
+require 'find'
+require 'fileutils'
+ include FileUtils
+require 'pathname'
+require 'rbconfig.rb'
+require 'yaml'
+module SiSUconf
+ class Configure < Thor
+ class_option :verbose, :type => :boolean
+ desc 'setup --all --bin --lib --conf --data --alt',
+ 'setup sisu'
+ options \
+ :all => :boolean,
+ :bin => :boolean,
+ :lib => :boolean,
+ :conf => :boolean,
+ :data => :boolean,
+ :share => :boolean,
+ :man => :boolean,
+ :vim => :boolean,
+ :alt => :boolean
+ def setup
+ unless options.length >= 1 \
+ and not (options[:bin] \
+ or options[:lib] \
+ or options[:conf] \
+ or options[:data] \
+ or options[:share] \
+ or options[:man] \
+ or options[:vim])
+ puts 'setup --all --bin --lib --conf --data --share --man --vim'
+ end
+ if not options[:alt]
+ if options[:all] \
+ or options[:bin]
+ exclude_files=['sisugem']
+ Install.setup_find_create('bin',Project_details.dir.bin,exclude_files) \
+ if File.directory?('bin')
+ end
+ if options[:all] \
+ or options[:lib]
+ Install.setup_find_create('lib',Project_details.dir.lib) \
+ if File.directory?('lib')
+ end
+ if options[:all] \
+ or options[:conf]
+ Install.setup_find_create('conf',Project_details.dir.conf) \
+ if File.directory?('conf')
+ end
+ if options[:all] \
+ or options[:data]
+ Install.setup_find_create('data',Project_details.dir.data) \
+ if File.directory?('data')
+ end
+ if options[:all] \
+ or options[:share]
+ Install.setup_find_create('data/sisu',Project_details.dir.share) \
+ if File.directory?('data/sisu')
+ end
+ if options[:all] \
+ or options[:man]
+ Install.setup_find_create('man',Project_details.dir.man) \
+ if File.directory?('man')
+ end
+ if options[:all] \
+ or options[:vim]
+ Install.setup_find_create('data/vim',Project_details.dir.vim) \
+ if File.directory?('data/vim')
+ end
+ else
+ if options[:all] \
+ or options[:bin]
+ Install.setup_find_cp_r('bin',Project_details.dir.bin) \
+ if File.directory?('bin')
+ end
+ if options[:all] \
+ or options[:bin]
+ Install.setup_find_cp_r('lib',Project_details.dir.lib) \
+ if File.directory?('lib')
+ end
+ if options[:all] \
+ or options[:conf]
+ Install.setup_find_cp_r('conf',Project_details.dir.conf) \
+ if File.directory?('conf')
+ end
+ if options[:all] \
+ or options[:data]
+ Install.setup_find_cp_r('data',Project_details.dir.data) \
+ if File.directory?('data')
+ end
+ if options[:all] \
+ or options[:share]
+ Install.setup_find_cp_r('data/sisu',Project_details.dir.share) \
+ if File.directory?('data/sisu') #
+ end
+ if options[:all] \
+ or options[:man]
+ Install.setup_find_cp_r('man',Project_details.dir.man) \
+ if File.directory?('man')
+ end
+ #if options[:all] \
+ #or options[:vim]
+ # Install.setup_find_cp_r('data/vim',"#{Project_details.dir.data}/vim") \
+ # if File.directory?('data/vim')
+ #end
+ end
+ end
+ desc 'gem --create --build --install --stable --unstable',
+ 'gem create build and install'
+ options \
+ :stable => :boolean,
+ :unstable => :boolean,
+ :create => :boolean,
+ :build => :boolean,
+ :install => :boolean
+ def gem
+ if options[:unstable]
+ if options[:create]
+ Gemspecs::Current.create_unstable
+ #Gemspecs::Next.create_unstable
+ puts 'created gemspec, version: unstable' \
+ if options[:verbose]
+ end
+ if options[:build]
+ Gemspecs::Current.build_unstable
+ #Gemspecs::Next.build_unstable
+ puts 'built gem, version: unstable' \
+ if options[:verbose]
+ end
+ if options[:install]
+ Gemspecs::Current.install_unstable
+ #Gemspecs::Next.install_unstable
+ puts 'installed gem, version: unstable' \
+ if options[:verbose]
+ end
+ end
+ if options[:stable] \
+ or not options[:unstable]
+ if options[:create]
+ Gemspecs::Current.create_stable
+ #Gemspecs::Current.create_unstable
+ puts 'created gemspec, version: stable' \
+ if options[:verbose]
+ end
+ if options[:build]
+ Gemspecs::Current.build_stable
+ #Gemspecs::Next.build_stable
+ puts 'built gem, version: stable' \
+ if options[:verbose]
+ end
+ if options[:install]
+ Gemspecs::Current.install_stable
+ #Gemspecs::Next.install_stable
+ puts 'installed gem, version: stable' \
+ if options[:verbose]
+ end
+ end
+ if options.length < 2
+ system("#{$called_as} help gem")
+ end
+ end
+ desc 'pkg',
+ 'package maintenance tasks, of no general interest (maintainer specific for package maintainer\'s convenience)'
+ options \
+ :update_version=> :boolean,
+ :tip => :boolean
+ def pkg
+ if options[:tip]
+ Package.sequence
+ end
+ if options[:update_version]
+ Version_info::Update.update_stable
+ Version_info::Update.update_unstable
+ end
+ if options.length == 0
+ system("#{$called_as} help pkg")
+ system("#{$called_as} pkg --tip")
+ end
+ end
+ end
+end
+begin
+ $called_as,$argv=$0,$*
+ SiSUconf::Configure.start(ARGV)
+rescue
+end
+__END__
diff --git a/setup/qi_libs.rb b/setup/qi_libs.rb
new file mode 100644
index 00000000..1778be6b
--- /dev/null
+++ b/setup/qi_libs.rb
@@ -0,0 +1,521 @@
+require_relative 'qi_libs_base'
+module Project_details
+ require_relative 'sisu_version'
+ include SiSUversion
+ def self.name
+ 'SiSU'
+ end
+ def self.thor
+ "ruby-thor files for the installation/setup of #{name}"
+ end
+ def self.platform_notice
+ "[#{name} is for Linux/Unix Platforms]"
+ end
+ def self.env
+ RbConfig::CONFIG
+ end
+ def self.host
+ env['host']
+ end
+ def self.dir
+ def self.proj
+ Project_details.name.downcase
+ end
+ def self.arch
+ env['archdir']
+ end
+ def self.sitearch
+ env['sitearchdir']
+ end
+ def self.bin
+ env['bindir']
+ end
+ def self.lib
+ env['sitelibdir']
+ end
+ def self.data
+ env['datadir']
+ end
+ def self.share
+ "#{env['datadir']}/sisu"
+ end
+ def self.conf
+ env['sysconfdir']
+ end
+ def self.man
+ env['mandir']
+ end
+ def self.vim
+ "#{env['datadir']}/sisu/vim"
+ end
+ def self.out
+ "#{env['localstatedir']}/#{proj}"
+ end
+ def self.rubylib
+ env['LIBRUBYARG_SHARED']
+ end
+ def self.pwd
+ Dir.pwd #ENV['PWD']
+ end
+ self
+ end
+ def self.version
+ stamp={}
+ v="#{dir.pwd}/conf/sisu/version.yml"
+ if File.exist?(v)
+ stamp=YAML::load(File::open(v))
+ stamp[:version]
+ else ''
+ end
+ end
+ def self.system_info
+ ##{Project_details.platform_notice}
+ puts <<-WOK
+ Host
+ host: #{Project_details.host}
+ arch: #{Project_details.dir.arch}
+ sitearch: #{Project_details.dir.sitearch}
+ Directories for installation
+ bin: #{Project_details.dir.bin}
+ lib (site-ruby): #{Project_details.dir.lib}/#{Project_details.dir.proj}/v*
+ conf [etc]: #{Project_details.dir.conf}/#{Project_details.dir.proj}
+ data (odf, shared images): #{Project_details.dir.share}
+ vim (vim syntax, highlighting, ftplugin): #{Project_details.dir.data}/sisu/vim
+ data (README, version_manifest): #{Project_details.dir.data}/doc/#{Project_details.dir.proj}
+ man (manual pages): #{Project_details.dir.man}
+ output: #{Project_details.dir.out}
+ processing: #{Project_details.dir.out}/processing
+ www: #{Project_details.dir.out}/www
+ rubylib: #{Project_details.dir.rubylib}
+
+ WOK
+ end
+ def self.gem_env
+ system("gem env")
+ end
+end
+module Utils
+ def self.answer?(ask)
+ resp='redo'
+ print ask + " ['yes', 'no' or 'quit']: "
+ resp=File.new('/dev/tty').gets.strip #resp=gets.strip
+ if resp == 'yes' then true
+ elsif resp == 'no' then false
+ elsif resp =~/^quit|exit$/ then exit
+ else puts "[please type: 'yes', 'no' or 'quit']"
+ answer?(ask)
+ end
+ end
+ def self.default_notice # local help not implemented description incorrect
+ ans= %{#{Project_details.thor}
+ Information on alternative actions is available using:
+ [if ruby-thor is installed:]
+ "#{$called_as} help")
+ Default action selected - "install #{Project_details.name}" proceed? }
+ resp=answer?(ans)
+ exit unless resp
+ end
+ def self.chmod_file(place)
+ if place =~/\/bin/; File.chmod(0755,place)
+ else File.chmod(0644,place)
+ end
+ end
+ def self.chmod_util(place)
+ if place =~/\/bin/; chmod(0755,place)
+ else chmod(0644,place)
+ end
+ end
+ def self.system_date
+ `date "+%Y-%m-%d"`.strip
+ end
+ def self.system_date_stamp
+ `date "+%Yw%W/%u"`.strip
+ end
+ def self.program_found?(prog)
+ found=`which #{prog}` #`whereis #{make}`
+ (found =~/bin\/#{prog}\b/) ? :true : :false
+ end
+end
+module Install
+ #%% using a directory and its mapping
+ def self.setup_find_create(dir_get,dir_put,exclude_files=['']) #primary,
+ begin
+ Find.find("#{Project_details.dir.pwd}/#{dir_get}") do |f|
+ stub=f.scan(/#{Project_details.dir.pwd}\/#{dir_get}\/(\S+)/).join
+ place="#{dir_put}/#{stub}"
+ action=case
+ when File.file?(f)
+ unless f =~/#{exclude_files.inspect}/
+ cp(f,place)
+ Utils.chmod_file(place)
+ "-> #{dir_put}/"
+ end
+ when File.directory?(f)
+ FileUtils.mkpath(place) \
+ unless FileTest.directory?(place)
+ "./#{dir_get}/"
+ else '?'
+ end
+ puts "#{action}#{stub}"
+ end
+ rescue
+ puts "\n\n[ are you root? required for install ]"
+ end
+ end
+ def self.setup_find_cp_r(dir_get,dir_put) #secondary, using recursive copy
+ begin
+ Find.find("#{Project_details.dir.pwd}/#{dir_get}") do |f|
+ stub=f.scan(/#{Project_details.dir.pwd}\/#{dir_get}\/(\S+)/).join
+ place="#{dir_put}/#{stub}"
+ case
+ when File.file?(f)
+ cp_r(f,place)
+ Utils.chmod_util(place)
+ when File.directory?(f)
+ mkdir(place) \
+ unless FileTest.directory?(place)
+ end
+ end
+ rescue
+ puts "\n\n[ are you root? required for install ]"
+ end
+ end
+end
+module Version_info
+ def self.contents(vi)
+ <<-WOK
+---
+:project: #{vi[:project]}
+:version: #{vi[:version]}
+:date_stamp: #{vi[:date_stamp]}
+:date: "#{vi[:date]}"
+ WOK
+ end
+ module Current
+ def self.yml_file_path(version)
+ "data/sisu/#{version}/v/version.yml"
+ end
+ def self.settings(file)
+ v="#{Dir.pwd}/#{file}"
+ if File.exist?(v)
+ YAML::load(File::open(v))
+ else ''
+ end
+ end
+ def self.file_stable
+ yml_file_path(SiSU_version_dir_stable)
+ end
+ def self.file_unstable
+ yml_file_path(SiSU_version_dir_unstable)
+ end
+ def self.setting_stable
+ settings(file_stable)
+ end
+ def self.setting_unstable
+ settings(file_unstable)
+ end
+ def self.content_stable
+ Version_info.contents(setting_stable)
+ end
+ def self.content_unstable
+ Version_info.contents(setting_unstable)
+ end
+ end
+ module Next
+ def self.settings(v)
+ {
+ project: "#{Project_details.name}",
+ version: "#{v}",
+ date: "#{Utils.system_date}",
+ date_stamp: "#{Utils.system_date_stamp}",
+ }
+ end
+ def self.setting_stable
+ settings(SiSU_version_next_stable)
+ end
+ def self.setting_unstable
+ settings(SiSU_version_next_unstable)
+ end
+ def self.content_stable
+ Version_info.contents(setting_stable)
+ end
+ def self.content_unstable
+ Version_info.contents(setting_unstable)
+ end
+ end
+ module Update
+ def self.version_info_update_commit(filename,vi_hash_current,vi_content_current,vi_hash_next,vi_content_next)
+ ans=%{update #{Project_details.name.downcase} version info replacing:
+ #{vi_hash_current.sort}
+with:
+ #{vi_hash_next.sort}
+
+#{vi_content_current} becoming:
+#{vi_content_next}
+proceed? }
+ resp=Utils.answer?(ans)
+ if resp
+ fn="#{Dir.pwd}/#{filename}"
+ if File.writable?("#{Dir.pwd}/.")
+ file_version=File.new(fn,'w+')
+ file_version << vi_content_next
+ file_version.close
+ else
+ puts %{*WARN* is the file or directory writable? could not create #{filename}}
+ end
+ end
+ end
+ def self.update_stable
+ version_info_update_commit(
+ Version_info::Current.file_stable,
+ Version_info::Current.setting_stable,
+ Version_info::Current.content_stable,
+ Version_info::Next.setting_stable,
+ Version_info::Next.content_stable
+ )
+ end
+ def self.update_unstable
+ version_info_update_commit(
+ Version_info::Current.file_unstable,
+ Version_info::Current.setting_unstable,
+ Version_info::Current.content_unstable,
+ Version_info::Next.setting_unstable,
+ Version_info::Next.content_unstable
+ )
+ end
+ def self.changelog_header(vi)
+ <<-WOK
+%% #{vi[:version]}.orig.tar.xz (#{vi[:date]}:#{vi[:date_stamp].gsub(/20\d\dw/,'')})
+http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_#{vi[:version]}
+http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_#{vi[:version]}-1
+http://www.jus.uio.no/sisu/pkg/src/sisu_#{vi[:version]}.orig.tar.xz
+ sisu_#{vi[:version]}.orig.tar.xz
+ sisu_#{vi[:version]}-1.dsc
+ WOK
+ end
+ def self.changelog_header_stable
+ changelog_header(Version_info::Current.setting_stable)
+ end
+ def self.changelog_header_unstable
+ changelog_header(Version_info::Current.setting_unstable)
+ end
+ end
+ self
+end
+module GitExtractTaggedVersionBuild
+ def upstream
+ system(%{ git checkout upstream })
+ end
+ def self.git_tagged_versions(tag=nil)
+ if tag
+ v=if tag =~/sisu_[0-9](?:\.[0-9]){0,2}$/ then tag
+ elsif tag =~/^[0-9](?:\.[0-9]){0,2}$/ then 'sisu_' + tag
+ else 'sisu_'
+ end
+ system(%{ git tag -l | ag --nocolor '^#{v}' })
+ end
+ end
+ def self.git_checkout_and_build_and_install_version(tag,options)
+ begin
+ ver=if tag =~/sisu_[0-9]\.[0-9]+\.[0-9]+/ then tag
+ elsif tag =~/^[0-9]\.[0-9]+\.[0-9]+/ then 'sisu_' + tag
+ else branch
+ end
+ stable=options[:stable] ? '--stable ' : ''
+ unstable=options[:unstable] ? '--unstable ' : ''
+ create=options[:create] ? '--create ' : ''
+ build=options[:build] ? '--build ' : ''
+ install=options[:install] ? '--install ' : ''
+ commands =<<-WOK
+ git checkout #{ver} &&
+ #{$called_as} gem #{ver} #{stable}#{unstable}#{create}#{build}#{install};
+ WOK
+ puts commands
+ begin
+ system(commands)
+ rescue # shell error not caught by ruby, using rake
+ #install_branches=[]
+ #install_branches << 'gem_create_build_stable' \
+ # if options[:stable]
+ #install_branches << 'gem_create_build_unstable' \
+ # if options[:unstable]
+ #commands =%{git checkout #{ver} && }
+ #install_branches.each do |install_branch|
+ # commands += %{rake #{install_branch};}
+ #end
+ #puts commands
+ #system(commands)
+ end
+ rescue
+ ensure
+ system(%{
+ git checkout upstream
+ })
+ end
+ end
+end
+module Gemspecs
+ def self.info(vi)
+ puts <<-WOK
+--
+name: #{vi[:project].downcase}
+version: #{vi[:version]}
+date: #{vi[:date]}
+summary: #{vi[:project]}
+ WOK
+ end
+ def self.contents(vi,version)
+ <<-WOK
+Gem::Specification.new do |s|
+ s.name = '#{vi[:project].downcase}'
+ s.version = '#{vi[:version]}'
+ s.date = '#{vi[:date]}'
+ s.summary = '#{vi[:project]}'
+ s.description = '#{Project_details.name} gem'
+ s.authors = ["Ralph Amissah"]
+ s.email = 'ralph.amissah@gmail.com'
+ s.files = Dir['lib/#{Project_details.name.downcase}/#{version}/*.rb'] +
+ Dir['data/#{Project_details.name.downcase}/#{version}/v/version.yml'] +
+ Dir['data/#{Project_details.name.downcase}/image/*'] +
+ Dir['bin/#{Project_details.name.downcase}gem'] +
+ Dir['bin/#{Project_details.name.downcase}']
+ s.license = 'GPL3'
+ s.executables << '#{Project_details.name.downcase}gem' << '#{Project_details.name.downcase}'
+end
+ WOK
+ end
+ def self.create(filename,gemspec)
+ fn="#{Dir.pwd}/#{filename}.gemspec"
+ if File.writable?("#{Dir.pwd}/.")
+ file_sisu_gemspec=File.new(fn,'w+')
+ file_sisu_gemspec << gemspec
+ file_sisu_gemspec.close
+ else
+ puts %{*WARN* is the file or directory writable? could not create #{filename}}
+ end
+ end
+ def self.build(fn)
+ system(%{ gem build #{fn}.gemspec })
+ end
+ def self.install(fn)
+ system(%{
+ sudo gem install --no-document --verbose #{fn}.gem
+ })
+ end
+ module Current
+ def self.filename_stable
+ Project_details.name.downcase \
+ + '-' \
+ + Version_info::Current.setting_stable[:version]
+ end
+ def self.filename_unstable
+ Project_details.name.downcase \
+ + '-' \
+ + Version_info::Current.setting_unstable[:version]
+ end
+ def self.info_stable
+ Gemspecs.info(Version_info::Current.setting_stable)
+ end
+ def self.info_unstable
+ Gemspecs.info(Version_info::Current.setting_unstable)
+ end
+ def self.current_stable
+ Gemspecs.contents(
+ Version_info::Current.setting_stable,
+ SiSU_version_dir_stable
+ )
+ end
+ def self.current_unstable
+ Gemspecs.contents(
+ Version_info::Current.setting_unstable,
+ SiSU_version_dir_unstable
+ )
+ end
+ def self.create_stable
+ Gemspecs.create(filename_stable,current_stable)
+ Gemspecs.create(
+ "#{Project_details.name.downcase}-stable",
+ current_stable
+ )
+ end
+ def self.create_unstable
+ Gemspecs.create(filename_unstable,current_unstable)
+ Gemspecs.create(
+ "#{Project_details.name.downcase}-unstable",
+ current_unstable
+ )
+ end
+ def self.build_stable
+ Gemspecs.build(filename_stable)
+ end
+ def self.build_unstable
+ Gemspecs.build(filename_unstable)
+ end
+ def self.install_stable
+ Gemspecs.install(filename_stable)
+ end
+ def self.install_unstable
+ Gemspecs.install(filename_unstable)
+ end
+ end
+ module Next
+ def self.filename_stable
+ Project_details.name.downcase \
+ + '-' \
+ + Version_info::Next.setting_stable[:version]
+ end
+ def self.filename_unstable
+ Project_details.name.downcase \
+ + '-' \
+ + Version_info::Next.setting_unstable[:version]
+ end
+ def self.setting_stable
+ Gemspecs.contents(
+ Version_info::Next.setting_stable,
+ SiSU_version_dir_stable
+ )
+ end
+ def self.setting_unstable
+ Gemspecs.contents(
+ Version_info::Next.setting_unstable,
+ SiSU_version_dir_unstable
+ )
+ end
+ def self.create_stable
+ Gemspecs.create(filename_stable,setting_stable)
+ end
+ def self.create_unstable
+ Gemspecs.create(filename_unstable,setting_unstable)
+ end
+ def self.build_stable
+ Gemspecs.build(filename_stable)
+ end
+ def self.build_unstable
+ Gemspecs.build(filename_unstable)
+ end
+ def self.install_stable
+ Gemspecs.install(filename_stable)
+ end
+ def self.install_unstable
+ Gemspecs.install(filename_unstable)
+ end
+ end
+end
+module Package
+ def self.sequence
+ puts <<-WOK
+ --update-version # update package version
+ # not included:
+ # --tag # git tags upstream version
+ # --merge # git merge upstream tag into debian/sid
+ # --dch # dch create and edit
+ # --dch-commit # dch commit
+ # --build # git-buildpackage
+ # --git_push # git push changes
+ # --dput # dput package
+ # --reprepro_update # reprepro update
+ # --reprepro_push # reprepro rsync changes
+ WOK
+ end
+end
+
diff --git a/setup/qi_libs_base.rb b/setup/qi_libs_base.rb
new file mode 100644
index 00000000..cd411d63
--- /dev/null
+++ b/setup/qi_libs_base.rb
@@ -0,0 +1,345 @@
+module Project_details
+ require_relative 'sisu_version'
+ include SiSUversion
+ def self.name
+ 'SiSU'
+ end
+ def self.thor
+ "ruby-thor files for the installation/setup of #{name}"
+ end
+ def self.platform_notice
+ "[#{name} is for Linux/Unix Platforms]"
+ end
+ def self.env
+ RbConfig::CONFIG
+ end
+ def self.host
+ env['host']
+ end
+ def self.dir
+ def self.proj
+ Project_details.name.downcase
+ end
+ def self.arch
+ env['archdir']
+ end
+ def self.sitearch
+ env['sitearchdir']
+ end
+ def self.bin
+ env['bindir']
+ end
+ def self.lib
+ env['sitelibdir']
+ end
+ def self.data
+ env['datadir']
+ end
+ def self.share
+ "#{env['datadir']}/sisu"
+ end
+ def self.conf
+ env['sysconfdir']
+ end
+ def self.man
+ env['mandir']
+ end
+ def self.vim
+ "#{env['datadir']}/sisu/vim"
+ end
+ def self.out
+ "#{env['localstatedir']}/#{proj}"
+ end
+ def self.rubylib
+ env['LIBRUBYARG_SHARED']
+ end
+ def self.pwd
+ Dir.pwd #ENV['PWD']
+ end
+ self
+ end
+ def self.version
+ stamp={}
+ v="#{dir.pwd}/conf/sisu/version.yml"
+ if File.exist?(v)
+ stamp=YAML::load(File::open(v))
+ stamp[:version]
+ else ''
+ end
+ end
+ def self.system_info
+ ##{Project_details.platform_notice}
+ puts <<-WOK
+ Host
+ host: #{Project_details.host}
+ arch: #{Project_details.dir.arch}
+ sitearch: #{Project_details.dir.sitearch}
+ Directories for installation
+ bin: #{Project_details.dir.bin}
+ lib (site-ruby): #{Project_details.dir.lib}/#{Project_details.dir.proj}/v*
+ conf [etc]: #{Project_details.dir.conf}/#{Project_details.dir.proj}
+ data (odf, shared images): #{Project_details.dir.share}
+ vim (vim syntax, highlighting, ftplugin): #{Project_details.dir.data}/sisu/vim
+ data (README, version_manifest): #{Project_details.dir.data}/doc/#{Project_details.dir.proj}
+ man (manual pages): #{Project_details.dir.man}
+ output: #{Project_details.dir.out}
+ processing: #{Project_details.dir.out}/processing
+ www: #{Project_details.dir.out}/www
+ rubylib: #{Project_details.dir.rubylib}
+
+ WOK
+ end
+end
+module Utils
+ def self.answer?(ask)
+ resp='redo'
+ print ask + " ['yes', 'no' or 'quit']: "
+ resp=File.new('/dev/tty').gets.strip #resp=gets.strip
+ if resp == 'yes' then true
+ elsif resp == 'no' then false
+ elsif resp =~/^quit|exit$/ then exit
+ else puts "[please type: 'yes', 'no' or 'quit']"
+ answer?(ask)
+ end
+ end
+ def self.default_notice # local help not implemented description incorrect
+ ans= %{#{Project_details.thor}
+ Information on alternative actions is available using:
+ [if ruby-thor is installed:]
+ "#{$called_as} help")
+ Default action selected - "install #{Project_details.name}" proceed? }
+ resp=answer?(ans)
+ exit unless resp
+ end
+ def self.chmod_file(place)
+ if place =~/\/bin/; File.chmod(0755,place)
+ else File.chmod(0644,place)
+ end
+ end
+ def self.chmod_util(place)
+ if place =~/\/bin/; chmod(0755,place)
+ else chmod(0644,place)
+ end
+ end
+ def self.system_date
+ `date "+%Y-%m-%d"`.strip
+ end
+ def self.system_date_stamp
+ `date "+%Yw%W/%u"`.strip
+ end
+ def self.program_found?(prog)
+ found=`which #{prog}` #`whereis #{make}`
+ (found =~/bin\/#{prog}\b/) ? :true : :false
+ end
+end
+module Version_info
+ def self.contents(vi)
+ <<-WOK
+---
+:project: #{vi[:project]}
+:version: #{vi[:version]}
+:date_stamp: #{vi[:date_stamp]}
+:date: "#{vi[:date]}"
+ WOK
+ end
+ module Current
+ def self.yml_file_path(version)
+ "data/sisu/#{version}/v/version.yml"
+ end
+ def self.settings(file)
+ v="#{Dir.pwd}/#{file}"
+ if File.exist?(v)
+ YAML::load(File::open(v))
+ else ''
+ end
+ end
+ def self.file_stable
+ yml_file_path(SiSU_version_dir_stable)
+ end
+ def self.file_unstable
+ yml_file_path(SiSU_version_dir_unstable)
+ end
+ def self.setting_stable
+ settings(file_stable)
+ end
+ def self.setting_unstable
+ settings(file_unstable)
+ end
+ def self.content_stable
+ Version_info.contents(setting_stable)
+ end
+ def self.content_unstable
+ Version_info.contents(setting_unstable)
+ end
+ end
+ module Next
+ def self.settings(v)
+ {
+ project: "#{Project_details.name}",
+ version: "#{v}",
+ date: "#{Utils.system_date}",
+ date_stamp: "#{Utils.system_date_stamp}",
+ }
+ end
+ def self.setting_stable
+ settings(SiSU_version_next_stable)
+ end
+ def self.setting_unstable
+ settings(SiSU_version_next_unstable)
+ end
+ def self.content_stable
+ Version_info.contents(setting_stable)
+ end
+ def self.content_unstable
+ Version_info.contents(setting_unstable)
+ end
+ end
+ module Update
+ def self.version_info_update_commit(filename,vi_hash_current,vi_content_current,vi_hash_next,vi_content_next)
+ ans=%{update #{Project_details.name.downcase} version info replacing:
+ #{vi_hash_current.sort}
+with:
+ #{vi_hash_next.sort}
+
+#{vi_content_current} becoming:
+#{vi_content_next}
+proceed? }
+ resp=Utils.answer?(ans)
+ if resp
+ fn="#{Dir.pwd}/#{filename}"
+ if File.writable?("#{Dir.pwd}/.")
+ file_version=File.new(fn,'w+')
+ file_version << vi_content_next
+ file_version.close
+ else
+ puts %{*WARN* is the file or directory writable? could not create #{filename}}
+ end
+ end
+ end
+ def self.update_stable
+ version_info_update_commit(
+ Version_info::Current.file_stable,
+ Version_info::Current.setting_stable,
+ Version_info::Current.content_stable,
+ Version_info::Next.setting_stable,
+ Version_info::Next.content_stable
+ )
+ end
+ def self.update_unstable
+ version_info_update_commit(
+ Version_info::Current.file_unstable,
+ Version_info::Current.setting_unstable,
+ Version_info::Current.content_unstable,
+ Version_info::Next.setting_unstable,
+ Version_info::Next.content_unstable
+ )
+ end
+ def self.changelog_header(vi)
+ <<-WOK
+%% #{vi[:version]}.orig.tar.xz (#{vi[:date]}:#{vi[:date_stamp].gsub(/20\d\dw/,'')})
+http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_#{vi[:version]}
+http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_#{vi[:version]}-1
+http://www.jus.uio.no/sisu/pkg/src/sisu_#{vi[:version]}.orig.tar.xz
+ sisu_#{vi[:version]}.orig.tar.xz
+ sisu_#{vi[:version]}-1.dsc
+ WOK
+ end
+ def self.changelog_header_stable
+ changelog_header(Version_info::Current.setting_stable)
+ end
+ def self.changelog_header_unstable
+ changelog_header(Version_info::Current.setting_unstable)
+ end
+ end
+ self
+end
+module Package
+ def self.sequence
+ puts <<-WOK
+ --update-version # update package version
+ --tag # git tags upstream version
+ --merge # git merge upstream tag into debian/sid
+ --dch # dch create and edit
+ --dch-commit # dch commit
+ --build # git-buildpackage
+ --git_push # git push changes
+ --dput # dput package
+ --reprepro_update # reprepro update
+ --reprepro_push # reprepro rsync changes
+ WOK
+ end
+ def self.tag_upstream_and_merge_into_debian_sid
+ system(%{
+ git tag -a sisu_#{SiSU_VERSION} -m"SiSU #{SiSU_VERSION}" &&
+ git checkout debian/sid &&
+ git merge sisu_#{SiSU_VERSION}
+ })
+
+ end
+ def self.tag_upstream
+ system(%{
+ git tag -a sisu_#{SiSU_VERSION} -m"SiSU #{SiSU_VERSION}"
+ })
+ end
+ def self.merge_into_debian_sid
+ system(%{
+ git checkout debian/sid &&
+ git merge sisu_#{SiSU_VERSION}
+ })
+ end
+ def self.debian_changelog_create
+ if File.directory?('./debian')
+ system(%{
+ git-dch -R -N #{SiSU_VERSION}-1 --full
+ })
+ else puts 'not in git branch: debian/sid ?'
+ end
+ end
+ def self.debian_changelog_commit
+ system(%{
+ git commit -a -m"debian/changelog (#{SiSU_VERSION}-1)"
+ })
+ end
+ def self.debian_package_build
+ system(%{
+ git-buildpackage --git-upstream-tag=sisu_%(version)s --git-debian-tag=debian/sisu_%(version)s --git-tag --git-keyid=#{Dev::GPGpubKey}
+ })
+ end
+ def self.debian_package_dput
+ #system(%{
+ # dput -s sisu_#{SiSU_VERSION}-1_amd64.changes
+ #})
+ system(%{
+ dput sisu_#{SiSU_VERSION}-1_amd64.changes
+ })
+ end
+ def self.debian_package_push
+ system(%{
+ git push --all &&
+ git push --tags
+ })
+ end
+ def self.reqprepro_update
+ dir_repo=Pathname.new(
+ "#{Dir.home}/grotto/repo/deb.repo/debian/rep"
+ )
+ dir_build=Pathname.new(
+ "#{Dir.home}/grotto/repo/git.repo/code/builds/sisu_#{SiSU_VERSION}-1_amd64.changes"
+ )
+ system(%{
+ cd #{dir_repo.dirname} &&
+ reprepro -Vb . include unstable #{dir_build}
+ cd -
+ })
+ end
+ def self.reprepro_push
+ dir_repo=Pathname.new(
+ "#{Dir.home}/grotto/repo/deb.repo/debian/rep"
+ )
+ system(%{
+ cd #{dir_repo} &&
+ rsync -av --delete-after {dists,pool} sisudoc:/srv/www/sisu/archive/. &&
+ rsync -av --delete-after {dists,pool} ralpha@uio:./sisu/archive/.
+ })
+ end
+end