Browse Source

Moved utils script to utils/ (instead of trunk)

Andrea Luzzardi 18 years ago
parent
commit
f1b0752900
2 changed files with 152 additions and 0 deletions
  1. +82
    -0
      utils/fetch_doc.rb
  2. +70
    -0
      utils/roll_release.sh

+ 82
- 0
utils/fetch_doc.rb View File

@ -0,0 +1,82 @@
#!/usr/bin/env ruby
#
# fetch_doc.rb
#
# Fetch the documentation from the wiki and translate it
# to be human readable.
#
require 'open-uri'
BASE_URI = 'http://www.pamusb.org/wiki/doc/'
DOC_PATH = '../doc/'
DOCS = [ 'installation', 'upgrading', 'configuration', 'faq' ]
MANS = [ 'pusb_hotplug', 'pusb_conf', 'pusb_check' ]
REPLACE_LIST = [
# Remove wiki links [[link|name]]
{ :pattern => /\[\[.+\|(.+)\]\]/, :with => '\1' },
# Remove misc xhtml/wiki characters
{ :pattern => /\/\//, :with => '' },
{ :pattern => /\\\\ /, :with => '' },
{ :pattern => /\*\*/, :with => '' },
{ :pattern => /&lt;/, :with => '<' },
{ :pattern => /&gt;/, :with => '>' },
{ :pattern => /&quot;/, :with => '"' },
{ :pattern => /<code .+>.*\n/, :with => '' },
{ :pattern => /<\/code>.*\n/, :with => '' },
{ :pattern => /<file>(.+)<\/file>/m, :with => '\1' },
# Remove trailing whitespaces
{ :pattern => /^ /, :with => '' },
# Fit 80 colums
{ :pattern => /(.{1,80})( +|$\n?)|(.{1,80})/, :with => "\\1\\3\n" },
]
def fetch_raw_doc(name)
uri = BASE_URI + name + '?do=edit'
body = open(uri) { |f| f.read }
body.gsub!(/.*<textarea .+>\n(.*)<\/textarea>.*/m, '\1')
body.gsub(/\r\n/, "\n")
end
def fetch_doc(name)
body = fetch_raw_doc(name)
REPLACE_LIST.each { |r| body.gsub!(r[:pattern], r[:with]) }
body
end
Dir.chdir(File.dirname($0))
DOCS.each do |doc|
print "Fetching doc:#{doc}... "
STDOUT.flush
text = fetch_doc(doc)
File.open(File.join(DOC_PATH, doc.upcase), 'w') { |f| f.write(text) }
puts "Done."
end
MANS.each do |man|
print "Fetching man:#{man}... "
STDOUT.flush
doc = fetch_doc("man/#{man}")
cmd = "txt2man -v \"PAMUSB\" -s1 -t#{man}"
cmd += ' | sed "s/\\\\\\\\\\\\\\\\/\\\\\\/g"'
File.popen("#{cmd} > #{File.join(DOC_PATH, man)}.1", 'w') do |f|
f.write(doc)
end
begin
File.unlink("#{File.join(DOC_PATH, man)}.1.gz")
rescue Exception
end
system("gzip #{File.join(DOC_PATH, man)}.1")
puts "Done."
end

+ 70
- 0
utils/roll_release.sh View File

@ -0,0 +1,70 @@
#!/bin/sh
#
# roll_release.sh
#
# Rolls a distribution tarball from the svn trunk
# and performs basic QA checks.
#
TRUNK_PATH="../"
clean_sources()
{
cd $TRUNK_PATH
make clean >> /dev/null || exit
if [ "`svn st`" ] ; then
echo "! Directory $TRUNK_PATH is not clean !"
svn st
exit
fi
cd - > /dev/null
}
create_release()
{
BUILD_ENV=`mktemp -d /tmp/build.XXXXXX`
SRC_PATH=${BUILD_ENV}/pam_usb-${1}
TARBALL=pam_usb-${1}.tar.gz
if [ -d "../tags/${1}" -o -f $TARBALL ] ; then
rm -rf $BUILD_ENV
echo "! Release $1 already exists !"
exit
fi
echo "* Rolling release $1 on $BUILD_ENV..."
cp -r $TRUNK_PATH ${SRC_PATH}
echo "* Cleaning up..."
find "$SRC_PATH" -type d -name ".svn" -exec rm -rf "{}" +
rm -rf $SRC_PATH/utils
echo "* Tagging release \"$1\""
sed -ri "s/(PUSB_VERSION) \"[^\"]*\"/\1 \"${1}\"/" ${SRC_PATH}/src/version.h
echo "* Creating tarball..."
cd $BUILD_ENV
tar -zcf $TARBALL pam_usb-${1}
cd - > /dev/null
cp -a $SRC_PATH ${TRUNK_PATH}/../../tags/${1}
cp ${BUILD_ENV}/${TARBALL} .
rm -rf $BUILD_ENV
echo "* Release $1 successfully rolled."
echo "* Tarball stored on `pwd`/${TARBALL}"
md5sum $TARBALL
}
if [ "x$1" = "x" ] ; then
echo "Usage: roll_release.sh <version>"
exit
fi
cd `dirname $0`
clean_sources
create_release "$1"

Loading…
Cancel
Save