lok: avoid expensive fetching of a property.
[LibreOffice.git] / bin / unpack-sources
blob2408eda1e14c46ed514b9dea374675ee203c889c
1 #!/usr/bin/env bash
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 usage()
13 echo "Helper script to unpack the LO source tarballs"
14 echo
15 echo "Usage: ${0##*/} [--help] start-dir tarball..."
16 echo
17 echo "Options:"
18 echo
19 echo " --help this help"
20 echo " start-dir path where the sources are unpacked (bootstrap directory)"
21 echo " tarball list of LO source tarball that need to be unpacked"
24 start_dir=
25 tarballs=
27 while test -n "$1" ; do
28 case "$1" in
29 --help)
30 usage
31 exit 0;
33 --download)
34 download="yes"
36 -*)
37 echo "Error: unknown option: $1"
38 exit 1;
41 if test -z "$start_dir" ; then
42 start_dir="$1"
43 else
44 tarballs="$tarballs $1"
47 esac
48 shift
49 done
51 if test -z "$start_dir" ; then
52 echo "Error: Please, define where to unpack sources, try --help"
55 if ! test -f $start_dir/Repository.mk ; then
56 echo "Error: $start_dir is not a valid LibreOffice core source directory"
57 exit 1;
60 if test ! -f $start_dir/sources.ver -o -d $start_dir/.git ; then
61 echo "Warning: sources are from git and not from tarball"
62 echo " Do nothing."
63 exit 0;
66 lo_src_dir="$start_dir/src"
67 mkdir -p "$lo_src_dir"
69 for tarball in $tarballs ; do
70 tarname=`basename $tarball | sed -e "s/\.tar\..*//"`
71 if test -d $lo_src_dir/$tarname ; then
72 echo "Warning: $lo_src_dir/$tarname already exists => skipping"
73 continue;
76 echo "Unpacking $tarname..."
77 echo mkdir -p "$lo_src_dir/$tarname"
78 if ! mkdir -p "$lo_src_dir/$tarname" ; then
79 echo "Error: could not create directory $lo_src_dir/$tarname"
81 echo tar -xf "$tarball" -C "$lo_src_dir/$tarname" --strip-components=1
82 if ! tar -xf "$tarball" -C "$lo_src_dir/$tarname" --strip-components=1; then
83 echo "Error: could not unpack $tarname"
84 exit 1
87 # create symlinks for module directories; ignore git-hooks directory
88 for dir in `find "$lo_src_dir/$tarname" -mindepth 1 -maxdepth 1 -type d -path $lo_src_dir/$tarname/git-hooks -o -printf "$tarname/%f\n"` ; do
89 ln -sf "src/$dir" "$start_dir"
90 done
91 done