Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / bin / unpack-sources
blob0fe4499c3197c1355493b90ba22ccac676779d3b
1 #!/usr/bin/env bash
3 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License or as specified alternatively below. You may obtain a copy of
8 # the License at http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Initial Developer of the Original Code is
16 # Petr Mladek <pmladek@suse.cz>
17 # Portions created by the Initial Developer are Copyright (C) 2011 the
18 # Initial Developer. All Rights Reserved.
20 # Major Contributor(s):
21 # Ted <ted@bear.com>
22 # Portions created by the Ted are Copyright (C) 2010 Ted. All Rights Reserved.
24 # For minor contributions see the git repository.
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
28 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
29 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
30 # instead of those above.
32 usage()
34 echo "Helper script to unpack the LO source tarbals"
35 echo
36 echo "Usage: ${0##*/} [--help] start-dir tarball..."
37 echo
38 echo "Options:"
39 echo
40 echo " --help this help"
41 echo " start-dir path where the sources are unpacked (bootstrap directory)"
42 echo " tarball list of LO source tarball that need to be unpacked"
45 start_dir=
46 tarballs=
48 while test -n "$1" ; do
49 case "$1" in
50 --help)
51 usage
52 exit 0;
54 --download)
55 download="yes"
57 -*)
58 echo "Error: unknown option: $1"
59 exit 1;
62 if test -z "$start_dir" ; then
63 start_dir="$1"
64 else
65 tarballs="$tarballs $1"
68 esac
69 shift
70 done
72 if test -z "$start_dir" ; then
73 echo "Error: Please, define where to unpack sources, try --help"
76 if ! test -f $start_dir/Repository.mk -a -f $start_dir/solenv/inc/target.mk ; then
77 echo "Error: $start_dir is not a valid LibreOffice core source directory"
78 exit 1;
81 if test ! -f $start_dir/sources.ver -o -d $start_dir/.git ; then
82 echo "Warning: sources are from git and not from tarball"
83 echo " Do nothing."
84 exit 0;
87 lo_src_dir="$start_dir/src"
88 mkdir -p "$lo_src_dir"
90 for tarball in $tarballs ; do
91 tarname=`basename $tarball | sed -e "s/\.tar\..*//"`
92 if test -d $lo_src_dir/$tarname ; then
93 echo "Warning: $lo_src_dir/$tarname already exists => skipping"
94 continue;
97 echo "Unpacking $tarname..."
98 echo tar -xf "$tarball" -C "$lo_src_dir"
99 tar -xf "$tarball" -C "$lo_src_dir"
101 # create symlinks for module directories; ignore git-hooks directory
102 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
103 ln -sf "src/$dir" "$start_dir"
104 done
105 done