Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[c593d3]: devel / release Maximize Restore History

Download this file

release    158 lines (135 with data), 5.2 kB

#! /bin/sh

## Copyright (C) 2012 Luca Favatella <slackydeb@gmail.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; If not, see <http://www.gnu.org/licenses/>.

## Ease the preparation of Octave-Forge package and function
## reference, automating the steps described at:
##   http://octave.sourceforge.net/developers.html
##
## This script:
## - Must be executed from the root directory of the package
## (i.e. where the DESCRIPTION file is placed);
## - Extracts package name and version from the DESCRIPTION file;
## - Extracts code from the current directory (git-svn is assumed at
## the moment, code for svn is disabled ATM) to a sandbox dir;
## - Creates package and function reference in the sandbox dir;
## - Lists created files in the sandbox dir.
##
## Comment/uncomment the relevant lines in the the vcs_export()
## function in order to use svn or hg or git-svn (default).
##
##
## This is an alternative for releasePKG, available at:
##   http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/admin/releasePKG.m?view=log
## Usage of and contribution to releasePKG is recommended.
##
## Reference: http://sourceforge.net/mailarchive/message.php?msg_id=29010854


## Functions

usage() {
    echo "Usage: $(basename $0)"
    echo "Create Octave-Forge package and function reference"
    echo ""
    echo "Code is taken from the current dir."
    echo "Release files are created in a sandbox dir whose details are printed at the end of the script execution."
}

mktempd() {
    TemplateCore=$1
    Template="/tmp/${TemplateCore}.XXXXXX"
    mktemp -d $Template
}

## John W. Eaton, David Bateman, Søren Hauberg, "GNU Octave - Free
## Your Numbers", Edition 3 for Octave version 3.6.1, February 2011
##
## 37.4.1 The DESCRIPTION File
##
## The ‘DESCRIPTION’ file contains various information about the
## package, such as its name, author, and version. This file has a
## very simple format
## • Lines starting with ‘#’ are comments.
## • Lines starting with a blank character are continuations from the
## • previous line.
## • Everything else is of the form NameOfOption: ValueOfOption.
## The following is a simple example of a ‘DESCRIPTION’ file
##   Name: The name of my package
##   Version: 1.0.0
## [...]
## The package manager currently recognizes the following keywords
##   Name	Name of the package.
##   Version	Version of the package. A package version must be 3
##          	numbers separated by a dot.
value_of_option() {
    DescriptionFile=$1
    NameOfOption=$2
    grep -v "^[# ]" $DescriptionFile | grep "^${NameOfOption}" | cut -d " " -f 2
}

vcs_export() {
    Path=$1
    #svn export . $Path ## svn ## svn is untested TODO: test
    #hg archive $Path ## hg. Reference: http://sourceforge.net/mailarchive/message.php?msg_id=29008793
    git archive master | tar -x -C $Path ## git-svn
}

targz_md5_uue() {
    ArchiveFile=$1
    File=$2 ## Could also be a dir

    tar czf $ArchiveFile $File
    md5 $ArchiveFile > ${ArchiveFile}.md5
    uuencode $ArchiveFile < $ArchiveFile > ${ArchiveFile}.uue
}


## Main

## References:
## http://octave.sourceforge.net/developers.html

## Assumption: this script is run in the root directory of the
## Octave-Forge to be released
DescriptionFile=$(pwd)/DESCRIPTION
if [ ! -r $DescriptionFile ]; then
    usage
    exit
fi

## Infer package name
Pkg=$(value_of_option $DescriptionFile "Name")

## Create temporary sandbox dir
TmpDir=$(mktempd $Pkg)
## Create an unversioned copy of the package in the sandbox dir
mkdir ${TmpDir}/${Pkg}
vcs_export ${TmpDir}/${Pkg}
#rm -r ${TmpDir}/${Pkg}/devel ## Do not release the devel/ folder

## Move to sandbox dir
cd $TmpDir

## You have already manually bumped the `Version' number (and
## optionally the `SVNRelease') in the package DESCRIPTION file
##
## Infer package version
Version=$(value_of_option $DescriptionFile "Version")

## produce a tar.gz of the package, take note of its md5 checksum and
## encode it with uuencode
PkgTarGz="${Pkg}-${Version}.tar.gz"
targz_md5_uue $PkgTarGz $Pkg

## generate the function reference HTML files with the command
## generate_package_html from the package `generate_html'
##
## Assumption: package generate_html is already installed
octave -q --eval \
    "pkg install ${PkgTarGz}"
Doc="${Pkg}-html"
octave -q --eval \
    "pkg load generate_html; generate_package_html ('${Pkg}', '${Doc}', 'octave-forge')"
octave -q --eval \
    "pkg uninstall ${Pkg}"

## produce a tarball, take note of its checksum and encode it with
## uuencode
DocTarGz="${Doc}.tar.gz"
targz_md5_uue $DocTarGz $Doc

## List produced files in sandbox dir
echo $TmpDir
ls -l $TmpDir