summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-16 07:20:36 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-16 07:20:52 -0600
commit6527f30e24e889810c9a895508dec0c9e6309076 (patch)
treea47085492db062b9982856a625344f31e1e1e321 /bin
parent3f4c6698d56a345f7624ebc0aad4f0b041f0fc3e (diff)
add a script to generate the source tarball post submodule
To simplify things, we generate the source tarball with all the submodules included. so building from source should now be: wget the tarball and untar cd into the resulting directory ./autogen.sh + make Change-Id: Ie8e65a81309cf11728c5144c9001f7d96670f815
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lo-generate-source-tarball182
1 files changed, 182 insertions, 0 deletions
diff --git a/bin/lo-generate-source-tarball b/bin/lo-generate-source-tarball
new file mode 100755
index 000000000000..cbaace550d3d
--- /dev/null
+++ b/bin/lo-generate-source-tarball
@@ -0,0 +1,182 @@
+#!/bin/env bash
+
+if [ -n "$debug" ] ; then
+set -x
+fi
+
+BIN_DIR=$(dirname "$0")
+CORE_DIR=$(realpath "$BIN_DIR/..")
+GEN_BZ2=false
+GEN_MD5=false
+GEN_XZ=false
+OUT_DIR="${CORE_DIR?}"
+VERSION=
+
+usage()
+{
+cat <<EOF
+Usage: $0 [ --xz ] [ --bz2 ] [ --md5 ] [ --output-dir=<output location> ]
+ [ --core-dir=<core-repo-location ] [--version=<package_version] label
+
+ --xz generate a package compressed with xz (default)
+ --bz2 generate a package compressed with bz2. Note if you specify
+ both --cz and --bz2, both are created. if you specify neither
+ --xz is impliied.
+ --md5 generate a md5 signature for the generated pacakge(s)
+ --output-dir where to put the generated packages
+ --core-dir location of the core repo to extract sources from.
+ by default this is one directory up from the position
+ of this script.
+ --version version string used to generate the name of the pacakge
+ the source pacakge name is libreoffice-<version>.tar.[bz2|xz]
+
+EOF
+}
+while [ "${1}" != "" ]; do
+ parm=${1%%=*}
+ arg=${1#*=}
+ has_arg=
+ if [ "${1}" != "${parm?}" ] ; then
+ has_arg=1
+ else
+ arg=""
+ fi
+# echo "parm=!${parm}!"
+# echo "arg=!${arg}!"
+ case "${parm}" in
+ -2|--bz2)
+ GEN_BZ2=true
+ ;;
+ -x|--xz)
+ GEN_XZ=true
+ ;;
+ -5|--md5)
+ GEN_MD5=true
+ ;;
+ -o|--output-dir)
+ if [ -z "${has_arg}" ] ; then
+ shift;
+ arg="$1"
+ fi
+ if [ -z "${arg}" ] ; then
+ echo "Missing argument for option $parm" 1>&2
+ exit -1
+ else
+ OUT_DIR="$arg"
+ fi
+ ;;
+ -v|--version)
+ if [ -z "${has_arg}" ] ; then
+ shift;
+ arg="$1"
+ fi
+ if [ -z "${arg}" ] ; then
+ echo "Missing argument for option $parm" 1>&2
+ exit -1
+ else
+ VERSION="$arg"
+ fi
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ -*)
+ echo "Invalid option $1" 1>&2
+ exit -1
+ ;;
+ *)
+ if [ -z "${LABEL}" ] ; then
+ LABEL="$parm"
+ else
+ echo "Too many arguments.. $@" 1>&2
+ exit -1
+ fi
+ ;;
+ esac
+ shift
+done
+
+# we need a label
+if [ -z "${LABEL}" ] ; then
+ echo "Missing argument. we need a git label as source" 1>&2
+ exit 1
+fi
+
+# default to xz compression
+if ! ${GEN_BZ2?} && ! ${GEN_XZ?} ; then
+ GEN_XZ=true
+fi
+
+# --version= is mandatory
+if [ -z "${VERSION}" ] ; then
+ VERSION="${LABEL?}"
+fi
+
+base_name="libreoffice-${VERSION}"
+
+# --output-dir default to core-dir
+if [ -z "${OUT_DIR}" ] ; then
+ OUT_DIR="$CORE_DIR?}"
+fi
+
+if [ ! -d "${CORE_DIR?}" ] ; then
+ echo "Core repo directory $CORE_DIR does not exist or is not a directory" 1>&2
+ exit 1
+fi
+
+if [ ! -d "${CORE_DIR?}/.git" ] ; then
+ echo "Core repo $CORE_DIR is not a git repo" 1>&2
+ exit 1
+fi
+
+if [ ! -d "${OUT_DIR?}" ] ; then
+ echo "Output directory $OUT_DIR does not exist or is not a directory" 1>&2
+ exit 1
+fi
+
+
+pushd "${CORE_DIR}" > /dev/null
+
+
+echo "archiving core..."
+git archive --format=tar --prefix="${base_name?}" -o "${OUT_DIR}/${base_name}.tar" ${LABEL?}
+
+
+concatenate_list=
+for module in dictionaries helcontent2 translations ; do
+ if [ ! -f ${module?}/.git ] ; then
+ echo "Warning: module $module is not present" 1>&2
+ else
+ echo "archiving ${module?}..."
+ git archive --format=tar --prefix="${base_name?}/${module?}" -o "${OUT_DIR}/${base_name}-${module?}.tar" ${LABEL?}
+ concatenate_list="${concatenate_list?} ${OUT_DIR}/${base_name}-${module?}.tar"
+ fi
+done
+
+if [ -n "${concatenate_list?}" ] ; then
+ tar --concatenate --file="${OUT_DIR}/${base_name}.tar" ${concatenate_list?}
+ rm ${concatenate_list?}
+fi
+
+if ${GEN_BZ2?} ; then
+ echo "bzip2 compression..."
+ bzip2 -fkz "${OUT_DIR}/${base_name}.tar"
+ if ${GEN_MD5?} ; then
+ echo "md5sum..."
+ md5sum "${OUT_DIR}/${base_name}.tar.bz2" > "${OUT_DIR}/${base_name}.tar.bz2.md5"
+ fi
+fi
+
+if ${GEN_XZ?} ; then
+ echo "xz compression..."
+ xz -fz "${OUT_DIR}/${base_name}.tar"
+ if ${GEN_MD5?} ; then
+ echo "md5sum..."
+ md5sum "${OUT_DIR}/${base_name}.tar.xz" > "${OUT_DIR}/${base_name}.tar.zx.md5"
+ fi
+else
+ rm "${OUT_DIR}/${base_name}.tar"
+fi
+
+echo "Done."