|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2014 Jolla Ltd. |
| 3 | +# Contact: Islam Amer <islama.amer@jollamobile.com> |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# This program is free software; you can redistribute it and/or |
| 7 | +# modify it under the terms of the GNU General Public License |
| 8 | +# as published by the Free Software Foundation; either version 2 |
| 9 | +# of the License, or (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with this program; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | + |
| 20 | +# Convenience script for initial setup of a subtree based packaging repository |
| 21 | +# Dependencies: git subtree |
| 22 | +#set -x |
| 23 | +set -e |
| 24 | + |
| 25 | +usage () { |
| 26 | + |
| 27 | + echo "$0 <tarball> <upstream reference (tag or branch)> <subtree prefix>" |
| 28 | + echo "$0 <submodule clone url> <upstream reference (tag or branch)>" |
| 29 | + exit 1 |
| 30 | + |
| 31 | +} |
| 32 | + |
| 33 | +test $# -ge 2 || usage |
| 34 | +test -d .git || ( echo "Current working directory is not a git repository" ; exit 1 ) |
| 35 | + |
| 36 | +git commit --allow-empty -m "initial empty commit" |
| 37 | + |
| 38 | +if test -f "$1" ; then |
| 39 | + git checkout -b upstream || git checkout upstream |
| 40 | + tar -xvf $1 --strip-components=1 |
| 41 | + git add -A |
| 42 | + git commit -a -m "import from upstream tarball $(basename $1)" |
| 43 | + if test -n "$2"; then |
| 44 | + git tag upstream/$2 |
| 45 | + fi |
| 46 | + if test -x $(which pristine-tar); then |
| 47 | + pristine-tar commit $1 |
| 48 | + fi |
| 49 | + git checkout master |
| 50 | + git clean -fdx |
| 51 | + if test -n "$3"; then |
| 52 | + git subtree add --squash --prefix=$3 upstream |
| 53 | + else |
| 54 | + echo "git subtree add --squash --prefix=<name> upstream" |
| 55 | + fi |
| 56 | + |
| 57 | +else |
| 58 | + |
| 59 | + git submodule add $1 upstream |
| 60 | + pushd upstream |
| 61 | + git checkout -B reference-branch $2 |
| 62 | + popd |
| 63 | + git commit -a -m "add upstream submodule" |
| 64 | + |
| 65 | + git remote add -f --no-tags upstream upstream |
| 66 | + git branch reference-branch upstream/reference-branch |
| 67 | + |
| 68 | + git subtree add --squash --prefix=$(basename $1 .git) upstream reference-branch |
| 69 | + |
| 70 | +fi |
| 71 | + |
| 72 | +mkdir -p rpm |
0 commit comments