Commit c005c468 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith

Added release script

parent 5f2f6343
logs
htdocs/js/MochiKit/Packed.js
test/mahara-*.tar.bz2
test/mahara-*.tar.gz
test/mahara-*.zip
mahara-*.tar.bz2
mahara-*.tar.gz
mahara-*.zip
#!/bin/sh
BUILDDIR="/tmp/mahara_release"
REPODIR="/tmp/mahara_repo"
ARCHLIST="i386 amd64"
DATE="`date`"
print_usage() {
echo "Usage is debian_release.sh"
echo "(must be run from a trunk checkout of mahara)"
echo ""
exit 1;
}
if [ ! -d .git ]; then
print_usage;
fi
if [ -d ${BUILDDIR} ]; then
rm -rf ${BUILDDIR}
fi
if [ -d ${REPODIR} ]; then
rm -rf ${REPODIR}
fi
mkdir ${BUILDDIR}
# Create repo dirs
for release in stable unstable; do
mkdir -p ${REPODIR}/dists/${release}/mahara
pushd ${REPODIR}/dists/${release}/mahara
mkdir binary-all
for arch in ${ARCHLIST}; do mkdir binary-${arch}; done
popd
mkdir -p ${REPODIR}/pool/${release}
done
pushd ${BUILDDIR}
STABLE_RELEASE="`ls -1 .git/refs/tags | grep 'RELEASE$' | tail -n1`"
echo "Building ${STABLE_RELEASE} ..."
# Build Stable
cg-clone "git+ssh://git.catalyst.net.nz/git/public/mahara.git#${STABLE_RELEASE}"
rm -f *.deb
pushd ${BUILDDIR}/mahara
make
popd
cp *.deb ${REPODIR}/pool/stable/
rm ${BUILDDIR}/mahara -rf
echo "Building Trunk ..."
# Build Trunk
cg-clone "git+ssh://git.catalyst.net.nz/git/public/mahara.git"
rm -f *.deb
pushd ${BUILDDIR}/mahara
make
popd
cp *.deb ${REPODIR}/pool/unstable/
rm ${BUILDDIR}/mahara -rf
# Link other arches into all and build packages
for release in stable unstable; do
pushd ${REPODIR}/pool
for arch in all ${ARCHLIST}; do
dpkg-scanpackages ${release} /dev/null /pool/ | /bin/gzip -9 > ${REPODIR}/dists/${release}/mahara/binary-${arch}/Packages.gz
dpkg-scanpackages ${release} /dev/null /pool/ > ${REPODIR}/dists/${release}/mahara/binary-${arch}/Packages
done
popd
pushd ${REPODIR}/dists/${release}
# Create Release file
cat <<EOHDR >Release
Origin: Mahara
Label: Mahara
Suite: ${release}
Date: ${DATE}
Architectures: ${ARCHLIST}
Components: mahara
Description: Mahara ${release} repository
MD5Sum:
EOHDR
for file in `find mahara -type f -name 'Packages*'`; do
MD5="`md5sum $file | cut -c1-32`"
SIZE="`cat $file | wc -c`"
printf " %s %16d %s\n" "${MD5}" "${SIZE}" "${file}" >>Release
done
gpg --yes --armour --sign-with 1D18A55D --detach-sign --output Release.gpg Release
popd
done
popd
rsync -PIlvr --delete-after ${REPODIR}/* locke.catalyst.net.nz:/home/ftp/pub/mahara/
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
use FindBin;
use File::Find;
use Perl6::Slurp;
use HTML::Tidy;
binmode STDOUT, ':utf8';
my $projectroot = qq{$FindBin::Bin/../};
my $parser = XML::LibXML->new();
my $number = 1;
$parser->recover(1);
my $cleanup_tasks = [
sub { # Only want contents of the <body> tag
my $dom = shift;
if ($dom->findnodes('.//body')) {
$dom = @{$dom->findnodes('.//body')}[0];
}
return $dom;
},
sub { # Don't want <strong> inside h3
my $dom = shift;
foreach my $node ($dom->findnodes('.//h3//strong')) {
my $parent = $node->parentNode;
$node = $node->parentNode->removeChild($node);
foreach my $child ($node->childNodes) {
$parent->appendChild($child);
}
}
return $dom;
},
sub { # Remove empty tags
my $dom = shift;
foreach my $node ($dom->findnodes('.//*[count(node())=1]')) {
if (
$node->firstChild->nodeName eq 'text'
and $node->firstChild->toString() =~ m{ \A \s* \z }xms
) {
$node->parentNode->removeChild($node);
}
}
foreach my $node ($dom->findnodes('.//*[count(node())=0]')) {
if (
$node->nodeName eq 'strong'
) {
$node->parentNode->removeChild($node);
}
}
return $dom;
},
sub { # Ensure there is no "text" at the top level
my $dom = shift;
my $root = shift;
foreach my $node ($dom->findnodes('./node()')) {
next unless $node->nodeName eq 'text';
next unless $node->textContent =~ m{ \S }xms;
my $p = $root->createElement('p');
$node->replaceNode($p);
$p->appendChild($node);
}
return $dom;
},
sub { # Template
my $dom = shift;
return $dom;
},
];
find( \&process, $projectroot );
sub process {
my $filename = $_;
my $directory = $File::Find::dir;
return unless $directory =~ m{ lang/en\.utf8/help }xms;
return unless $filename =~ m{ html \z }xms;
my $dom = parse_file($directory . '/' . $filename);
my $root = $dom;
foreach my $cleanup ( @{$cleanup_tasks} ) {
$dom = &$cleanup($dom, $root);
return unless defined $dom;
}
unlink $directory . '/' . $filename;
my $output = '';
foreach my $child ($dom->childNodes) {
$output .= $child->toString(0, 'POSIX');
}
$output .= "\n";
$output =~ s{ \A \s* (.*?) \s* \z }{$1\n}xms;
$output =~ s/\x{A0}//g;
open OUTFILE, '>', $directory . '/' . $filename;
print OUTFILE $output;
close OUTFILE;
# check that it's okay now ...
unless ( grep { $_->nodeName ne 'p' and $_->nodeName ne 'h3' } $dom->findnodes('.//*')) {
return;
}
unless (
grep { $_->nodeName ne 'em' and $_->nodeName ne 'p' and $_->nodeName ne 'h3' } $dom->findnodes('.//*')
and not grep {
defined $_->previousSibling()
and defined $_->nextSibling()
and $_->previousSibling()->nodeName eq 'text'
and $_->nextSibling()->nodeName eq 'text'
} $dom->findnodes('.//em')
)
{
return;
}
print $directory, '/', $filename, "\n";
}
sub parse_file {
my $filename = shift;
my $filedata = slurp($filename);
$filedata =~ s{\r\n}{\n}smg;
# Trap STDERR because the parser is quite verbose and annoying
my $dom;
{
#local *STDERR;
#open STDERR, '>', '/dev/null';
$dom = $parser->parse_html_string($filedata);
}
return $dom;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment