roll-tarballs.sh 4.8 KB
Newer Older
1 2
#!/bin/bash

3
# Copyright (C) 2011-2016 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# Copyright (C) 2012 by Reinhard Tartler <siretart@tauware.de>
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

# Thanks to Jonas Smedegaard <dr@jones.dk> for inspiration...

# Formatting/cleanups by siretart in December 2012

set -e

usage() {
    echo "To be called at the project root of an nx-libs checkout"
    echo "usage: $(basename "$0") {<release-version>,HEAD} {server|client}"
    exit 1
}

PROJECT="nx-libs"
34
NULL=""
35

36
test -d ".git" || usage
37 38 39 40 41
RELEASE="$1"
test -n "${RELEASE}" || usage
CHECKOUT="$2"
test -n "$CHECKOUT" || usage

42 43 44 45 46 47 48 49
if [ "x$CHECKOUT" = "xserver" ] || [ "x${CHECKOUT}" = "xfull" ]; then
    MODE="full"
    CHECKOUT="redist-server/${RELEASE}"
    RELEASE_SUFFIX='-full'
elif [ "x$CHECKOUT" = "xclient" ] || [ "x${CHECKOUT}" = "xlite" ]; then
    MODE="lite"
    CHECKOUT="redist-client/${RELEASE}"
    RELEASE_SUFFIX='-lite'
50
else
51
    usage
52 53 54
fi

if [ x"$RELEASE" == "xHEAD" ]; then
55
    CHECKOUT="refs/heads/$(git rev-parse --abbrev-ref HEAD)"
56 57 58
fi

if ! git rev-parse --verify -q "$CHECKOUT" >/dev/null; then
59
    echo "   '${RELEASE}' is not a valid release number because there is no git tag named ${CHECKOUT}."
60
    echo "   Please specify one of the following releases:"
61
    echo "HEAD (on branch `git rev-parse --abbrev-ref HEAD`)"
62
    git tag -l | grep "^redist" | cut -f2 -d"/" | sort -u
63 64 65 66 67 68 69 70 71 72 73
    exit 1
fi

TARGETDIR=".."

MANIFEST="$(mktemp)"
TEMP_DIR="$(mktemp -d)"

trap "rm -f \"${MANIFEST}\"; rm -rf \"${TEMP_DIR}\"" 0

# create local copy of Git project at temp location
74
git archive --format=tar "${CHECKOUT}" --prefix="${PROJECT}-${RELEASE}/" | ( cd "$TEMP_DIR"; tar xf - )
75
git --no-pager log --after "1972-01-01" --format="%ai %aN (%h) %n%n%x09*%w(68,0,10) %s%d%n" > "${TEMP_DIR}/${PROJECT}-${RELEASE}/ChangeLog"
76 77 78

echo "Created tarball for $CHECKOUT"

79
cd "${TEMP_DIR}/${PROJECT}-${RELEASE}/"
80

81 82
# Replace symlinks by copies of the linked target files
# Note: We don't have symlinked directories!!!
83 84 85 86 87 88
find . -type "l" | while read link; do
	TARGET="$(readlink "${link}")"
	pushd "$(dirname "${link}")" >/dev/null
	if [ -f "${TARGET}" ]; then
		rm -f "$(basename "${link}")"
		cp "${TARGET}" "$(basename "${link}")"
89
	fi
90
	popd >/dev/null
91 92
done

93
mkdir -p "doc/applied-patches"
94 95 96

# prepare patches for lite and full tarball
if [ "x$MODE" = "xfull" ]; then
97
    cat "debian/patches/series" | sort | grep -v '^#' | egrep "([0-9]+(_|-).*\.(full|full\+lite)\.patch)" | while read file
98
    do
99 100
        cp -v "debian/patches/$file" "doc/applied-patches/"
        echo "${file##*/}" >> "doc/applied-patches/series"
101 102
    done
else
103
    rm -f  "bin/nxagent"
104 105 106
    rm -Rf "nxcompshad"*
    rm -Rf "nxcompext"*
    rm -Rf "nx-X11"*
107 108
    rm -Rf "etc"*
    rm -Rf "doc/nx-X11_vs_XOrg69_patches"*
109
    rm -Rf "doc/X11-symbols"*
110
    rm -f  "README.keystrokes"
111
    cat "debian/patches/series" | sort | grep -v '^#' | egrep "([0-9]+(_|-).*\.full\+lite\.patch)" | while read file
112
    do
113 114
        cp -v "debian/patches/$file" "doc/applied-patches/"
        echo "${file##*/}" >> "doc/applied-patches/series"
115 116 117 118 119
    done
fi

# apply all patches shipped in debian/patches and create a copy of them that we ship with the tarball
if [ -s "doc/applied-patches/series" ]; then
120
    QUILT_PATCHES="doc/applied-patches" quilt --quiltrc /dev/null push -a -q
121 122 123 124
else
    echo "No patches applied at all. Very old release?"
fi

125 126 127 128 129
# remove folders that we do not want to roll into the tarball
rm -Rf ".pc/"
rm -Rf "debian/"
rm -Rf "nx-libs.spec"

130 131
# very old release did not add any README
for f in $(ls README* 2>/dev/null); do
132
    mv -v "$f" "doc/";
133
done
134

135 136 137
# remove files, that we do not want in the tarballs (build cruft)
rm -Rf nx*/configure nx*/autom4te.cache*

138
cd "$OLDPWD"
139 140

# create target location for tarball
141
mkdir -p "${TARGETDIR}/_releases_/source/${PROJECT}/"
142 143 144 145

# roll the ball...
cd "$TEMP_DIR"
find "${PROJECT}-${RELEASE}" -type f | sort > "$MANIFEST"
146
cd "$OLDPWD"
147 148 149 150 151 152 153 154

tar c -C "$TEMP_DIR" \
    --owner 0 \
    --group 0 \
    --numeric-owner \
    --no-recursion \
    --files-from "$MANIFEST" \
    --gzip \
155
    > "$TARGETDIR/_releases_/source/${PROJECT}/${PROJECT}-${RELEASE}${RELEASE_SUFFIX}.tar.gz"
156 157

echo "$TARGETDIR/_releases_/source/${PROJECT}/${PROJECT}-${RELEASE}${RELEASE_SUFFIX}.tar.gz  is ready"