aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Cohen2017-10-19 20:40:10 +0200
committerCyril Cohen2017-10-19 20:50:06 +0200
commit6a2e6d2f6a1aeec7255a4a874dece7f3664bb469 (patch)
treeff7fca3e7fbd49291d618d9815a1e5873c54401c
parent5466772ab7a59081aed4bcf990bef74e9bd48965 (diff)
new script to create opam meta packages
- the opam files in the branch where the script is launched should be correct - if not, the second argument to the script should be a branch in which the opam files are correct
-rwxr-xr-xetc/utils/packager74
1 files changed, 54 insertions, 20 deletions
diff --git a/etc/utils/packager b/etc/utils/packager
index f0c1d5b..af3c777 100755
--- a/etc/utils/packager
+++ b/etc/utils/packager
@@ -1,28 +1,62 @@
#!/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
-for pkg in ssreflect fingroup algebra field solvable character real_closed odd_order
-do
-pkgdir="$(git root)/opam/extra-dev/packages/coq-mathcomp-$pkg/coq-mathcomp-$pkg.dev"
-mkdir -p $pkgdir
-cp $(git root)/mathcomp/$pkg/opam $pkgdir/opam
-cp $(git root)/mathcomp/$pkg/descr $pkgdir/descr
-sed -r "/^(build|install)/s?make?make \"-C\" \"mathcomp/$pkg\"?" -i $pkgdir/opam
-echo "git: \"https://github.com/math-comp/math-comp.git\"" > $pkgdir/url
-done
+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
-for pkg in ssreflect fingroup algebra field solvable character odd_order
-do
-pkgdir="$(git root)/opam/released/packages/coq-mathcomp-$pkg/coq-mathcomp-$pkg.1.6"
-mkdir -p $pkgdir
-cp $(git root)/mathcomp/$pkg/opam $pkgdir/opam
-cp $(git root)/mathcomp/$pkg/descr $pkgdir/descr
-sed -r "/^version/s?dev?1.6?" -i $pkgdir/opam
-sed -r "/^depends.*coq-mathcomp.*/s?dev?1.6?" -i $pkgdir/opam
-sed -r "/^(build|install)/s?make?make \"-C\" \"mathcomp/$pkg\"?" -i $pkgdir/opam
-echo "http: \"http://github.com/math-comp/math-comp/archive/mathcomp-1.6.tar.gz\"" > $pkgdir/url
-echo "checksum: \"038ba80c0d6b430428726ae4d00affcf\"" >> $pkgdir/url
+# 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