XRM r104: Add scripts for binary distributions.

URL: https://svn.lrde.epita.fr/svn/xrm/trunk ChangeLog: 2007-01-08 SIGOURE Benoit <tsuna@lrde.epita.fr> Add scripts for binary distributions. * Makefile.am (EXTRA_DIST): Add the scripts. (bin-dist): Generate a binary distribution. * bin-dist.sh: New. * hook.sh.in: New. * install-xrm.sh.in: New. Makefile.am | 8 ++++- bin-dist.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ hook.sh.in | 4 ++ install-xrm.sh.in | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+), 1 deletion(-) Property changes on: . ___________________________________________________________________ Name: svn:ignore - Makefile.in configure _build autom4te.cache aclocal.m4 Makefile.in diffs.patch + Makefile.in configure _build autom4te.cache aclocal.m4 Makefile.in diffs.patch _static Index: bin-dist.sh =================================================================== --- bin-dist.sh (revision 0) +++ bin-dist.sh (revision 0) @@ -0,0 +1,76 @@ +#! /bin/sh +# Generate a binary distribution of XRM. + +me=`basename "$0"` +abort() +{ + echo "$me: $*." >&2 + exit 1 +} + +my_dir=`dirname "$0"` +cd "$my_dir" || abort "$my_dir: No such directory" + +test -r configure.ac || abort 'Run this script at the root of the project' +test -x configure || { + ./bootstrap || abort 'No configure and cannot bootstrap' +} + +test -d _static || { + mkdir _static || abort 'Cannot mkdir _static' +} +cd _static || abort 'Cannot cd to _static' + +prefix="`pwd`/_inst" +../configure --disable-shared --enable-static "--prefix=$prefix" \ + || abort 'configure failed' + +make all install LDFLAGS='-all-static' || abort 'Compilation failed' + +: ${DEFAULT_XTC_REPOS=:} +echo '>>> Replacing and fixing binary XTC repositories with plain-text' +cd _inst || abort 'Cannot cd to _inst' +for f in : `find share -type f -name XTC`; do + test x"$f" = x: && continue + echo -n " $f: " + mv "$f" "$f.bin" || abort "Failed to rename '$f'" + pp-aterm -i "$f.bin" -o "$f.tmp" || abort "pp-aterm failed on '$f.bin'" + sed "s,$prefix,@prefix@,g" "$f.tmp" >"$f" || abort "Failed to sed '$f.tmp'" + rm -f "$f.tmp" + echo 'OK' + test x"$DEFAULT_XTC_REPOS" = x: && DEFAULT_XTC_REPOS=$f +done +cd .. || abort 'Cannot cd ..' + +echo ">>> Hooking binary programs with shell scripts +Assuming that $DEFAULT_XTC_REPOS is the default XTC repository." +for f in : `find _inst/bin -type f`; do + test x"$f" = x: && continue + test -x "$f" || continue + echo -n " $f: " + mv "$f" "$f.bin" || abort "Failed to rename '$f'" + cp ../hook.sh.in "$f" || abort 'Failed to copy the hook script for '$f'' + chmod a+x "$f" || abort "Failed to make '$f' executable" + echo 'OK' +done + +echo -n '>>> Generating the install script: ' +sed >_inst/install-xrm.sh "s,@DEFAULT_XTC_REPOS@,$DEFAULT_XTC_REPOS,g" \ + ../install-xrm.sh.in || abort 'Failed to generate the install script' +chmod a+x _inst/install-xrm.sh \ + || abort 'Failed to make the install script executable' +echo 'OK' + +tarname=`sed '/^PACKAGE_\(TARNAME\|VERSION\) = /!d;s///' Makefile \ + | xargs | sed 's/ /-/g'` +mv _inst "$tarname" || abort 'mv failed' +echo -n '>>> Generating binary distribution... gzip: ' +tar cpfz "$tarname.tar.gz" "$tarname" || abort 'Failed to create gzip tarball' +echo -n 'OK, bzip2: ' +tar cpfj "$tarname.tar.bz2" "$tarname" || abort 'Failed to create bzip2 tarball' +echo 'OK' +mv $tarname.tar.{gz,bz2} .. || abort 'Failed to move tarballs' +cd .. || abort 'Failed to cd back to parent directory' +rm -rf _static || abort 'Failed to clean the _static directory' + +echo "Binary distribution ready in $tarname.tar.gz and $tarname.tar.bz2" Property changes on: bin-dist.sh ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Index: install-xrm.sh.in =================================================================== --- install-xrm.sh.in (revision 0) +++ install-xrm.sh.in (revision 0) @@ -0,0 +1,71 @@ +#! /bin/sh +# Installer for XRM that relocates a binary distribution. + +test x"$1" = x && { + echo 'Usage: install-xrm.sh <prefix> +Installs XRM under <prefix>.' >&2 + exit 1 +} + +me=`basename "$0"` +abort() +{ + echo "$me: $*." >&2 + exit 1 +} + +prefix=$1 +DEFAULT_XTC_REPOS='@DEFAULT_XTC_REPOS@' +test -d "$prefix" || abort "'$prefix' is not a directory or doesn't exist" + +case "$prefix" in + [\\/]* | ?:[\\/]* ) # Absolute + ;; + *) + abort "'$prefix' is not an absolute path" + ;; +esac + +my_dir=`dirname "$0"` +cd "$my_dir" || abort "$my_dir: No such directory" + +echo '>>> Relocating XTC repositories' +for f in : `find share -type f -name XTC`; do + test x"$f" = x: && continue + echo -n " $f" + cp "$f" "$f.tmp" || abort "Failed to cp '$f'" + sed "s,@prefix@,$prefix,g" "$f.tmp" >"$f" || abort "Failed to sed '$f.tmp'" + rm -f "$f.tmp" + echo ' [ OK ]' +done + +echo '>>> Relocating hook scripts' +for f in : `find . -type f -name '*.bin'`; do + test x"$f" = x: && continue + p=${f%%.bin} + test -f "$p" || continue + echo -n " $p" + cp "$p" "$p.tmp" || abort "Failed to cp '$p'" + sed "s,@XTC_REPOSITORY@,$prefix/$DEFAULT_XTC_REPOS," "$p.tmp" >"$p" + rm -f "$p.tmp" + echo ' [ OK ]' +done + +echo ">>> Installing files under '$prefix'" +cp -r -p -f */ "$prefix" || abort 'Install failed' + +uninstall="$prefix/bin/uninstall-xrm.sh" +echo -n ">>> Generating uninstall script in $uninstall" +echo '#! /bin/sh -x' >"$uninstall" \ + || abort 'Failed to create uninstall script' +find . -type f >>"$uninstall" || abort 'Failed to find files' +cp "$uninstall" "$uninstall.tmp" || abort 'Failed to cp uninstall script' +sed "s,^\.,rm -f $prefix," "$uninstall.tmp" >"$uninstall" \ + || abort 'Failed to generate uninstall script for files' +find . -type d >>"$uninstall" || abort 'Failed to find directories' +cp "$uninstall" "$uninstall.tmp" || abort 'Failed to cp uninstall script' +sed "s,^\.,rmdir $prefix," "$uninstall.tmp" >"$uninstall" \ + || abort 'Failed to generate uninstall script for directories' +rm -f "$uninstall.tmp" +chmod a+x "$uninstall" || abort 'Failed to make uninstall script executable' +echo ' [ OK ]' Index: Makefile.am =================================================================== --- Makefile.am (revision 103) +++ Makefile.am (working copy) @@ -28,7 +28,10 @@ EXTRA_DIST = \ PRISM.notes \ prism \ - vcs + vcs \ + bin-dist.sh \ + hook.sh.in \ + install-xrm.sh.in pkgconfig_DATA = xrm.pc DISTCLEANFILES = $(pkgconfig_DATA) $(BUILD_REPOSITORY) @@ -47,3 +50,6 @@ # Remove the .svn folders included in the tarball dist-hook: find $(distdir) -type d -name '.svn' | xargs rm -rf + +bin-dist: + $(SHELL) ./bin-dist.sh Index: hook.sh.in =================================================================== --- hook.sh.in (revision 0) +++ hook.sh.in (revision 0) @@ -0,0 +1,4 @@ +#! /bin/sh +# Set proper environment variables before running a Stratego program. + +exec env XTC_REPOSITORY=@XTC_REPOSITORY@ "$0.bin" "$@" -- SIGOURE Benoit aka Tsuna (SUSv3 compliant) _____ "On a long enough timeline, the survival rate /EPITA\ Promo 2008.CSI/ACU for everyone drops to zero" -- Jack.
participants (1)
-
SIGOURE Benoit