#!/bin/bash # usage : packager VERSION [BRANCH] # VERSION is the version number of the package to create, we expect # there is a tag named mathcomp-$VERSION which archive we can # download from github # BRANCH is the name of a branch where we can find accurate local opam # files. Actually, this may only matter for the Coq version dependencies # located in the ssreflect package. set -e set -x if [ -z $2 ] then BRANCH="mathcomp-$1" else BRANCH=$2 fi # shows $BRANCH for debugging, fails if the branch does not exist git show $BRANCH # we build the url file content and the list of packages, and where to put them if [ $1 == "dev" ] then # variables useful for package construction URLLINE="git: \"https://github.com/math-comp/math-comp.git\"" PKGS=$(sed -r "s/.*mathcomp\.([^\.]*)*.*/\1/" $(git root)/mathcomp/all/all.v \ | paste -sd " " -) PKGPREFIX="$(git root)/opam/extra-dev/packages" else ARCHIVE=$(mktemp) wget -O $ARCHIVE "http://github.com/math-comp/math-comp/archive/mathcomp-$1.tar.gz" SUM=$(md5sum $ARCHIVE | cut -d " " -f 1) EXTRACTED=$(mktemp -d) tar -C $EXTRACTED -zxvf $ARCHIVE # variables useful for package construction URLLINE="http: \"http://github.com/math-comp/math-comp/archive/mathcomp-$1.tar.gz\"" CHECKSUMLINE="checksum: \"$SUM\"" PKGS=$(ls -fs -d -1 $EXTRACTED/*/mathcomp/*/ \ | sed -r "s?.*mathcomp/([^/]+)/?\1?" \ | paste -sd " " -) PKGPREFIX="$(git root)/opam/released/packages" fi # for each package, we pick the corresponding opam and descr file and # rewrite them to adapt them to single package construction and # version numbers for pkg in $PKGS do pkgdir="$PKGPREFIX/coq-mathcomp-$pkg/coq-mathcomp-$pkg.$1" mkdir -p $pkgdir if [ $1 == "dev" ] then cp $(git root)/mathcomp/$pkg/opam $pkgdir/opam cp $(git root)/mathcomp/$pkg/descr $pkgdir/descr else git show "$BRANCH:mathcomp/$pkg/opam" > $pkgdir/opam git show "$BRANCH:mathcomp/$pkg/descr" > $pkgdir/descr sed -r "/^version/s?dev?$1?" -i $pkgdir/opam sed -r "/^depends.*coq-mathcomp.*/s?dev?$1?" -i $pkgdir/opam fi sed -r "/^(build|install)/s?make?make \"-C\" \"mathcomp/$pkg\"?" -i $pkgdir/opam echo $URLLINE > $pkgdir/url if [ $1 != "dev" ] then echo $CHECKSUMLINE >> $pkgdir/url fi done