aboutsummaryrefslogtreecommitdiff
path: root/tools/Linux/packaging/debian/xbmc-get-orig-source
blob: 22f1a2148c30cc8b71db45b7e942d87d7f649e28 (plain)
1
2
3
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh

# This script is used to download the upstream source for xbmc and
# generate it into an orig source tarball for Debian.

USAGE="\n\
This script is used to generate the orig tarball used in building\n\
Debian packages for xbmc. This script will create an orig tarball for\n\
Debian/Ubuntu official archive by default.
Usage: xbmc-get-orig-source [OPTION]\n\
\n\
 -h, --help                 Display this help message.\n\
 --remove-upstream-tarball  Remove the upstream source tarball.\n\
 --make-debian-snapshot     Make tarball for official Debian/Ubuntu archive\n\
                            using latest SVN revision.\n\
 --make-ppa                 Make tarball for XBMC's PPA\n\
 --make-ppa-snapshot        Make tarball for XBMC's PPA using latest SVN\n\
                            revision.\n"

# Loop that parses options passed to script
while [ "$#" -gt "0" ]
do
    case "$1" in
        --remove-upstream-tarball)
            REMOVE_UPSTREAM_TARBALL=1
            shift
            ;;
        --make-debian-snapshot)
            LATEST_SVN=1
            shift
            ;;
        --make-ppa)
            PPA_ORIG_TARBALL=1
            shift
            ;;
        --make-ppa-snapshot)
            PPA_ORIG_TARBALL=1
            LATEST_SVN=1
            shift
            ;;
        -h|--help|*)
            echo "${USAGE}"
            exit 1
            ;;
    esac
done

# Common variables used to ease maintenance of this script
XBMC_TARBALL=""
XBMC_TARBALL_CHECKSUM=""
SVN_REVISION="32391"
XBMC_VERSION="10.0~svn$SVN_REVISION~deb1"
XBMC_SVN_URL="http://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk"

# export xbmc source
get_sources() {
    if [ -n "$LATEST_SVN" ]; then
        SVN_REVISION="$(svn info $XBMC_SVN_URL | \
                        grep "Last Changed Rev" | \
                        sed -e 's/^[^0-9]\+//')"
        XBMC_VERSION="10.0~svn$SVN_REVISION~deb1"
    fi
    svn export -r$SVN_REVISION $XBMC_SVN_URL xbmc-$XBMC_VERSION
}

# This will prepare the sources to create a tarball from
prepare_orig_tarball() {
    # Run bootstrap
    cd xbmc-$XBMC_VERSION
    ./bootstrap
    cd ..

    if [ -z "$PPA_ORIG_TARBALL" ]; then
        # Remove non-free components
        echo "Removing non-free components"
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/libdvd/libdvdcss
        rm -rf xbmc-$XBMC_VERSION/xbmc/xbmc/lib/UnrarXLib
        rm -rf xbmc-$XBMC_VERSION/xbmc/xbmc/lib/libXBMS

        # Remove components not needed for Linux when using external libs
        echo "Removing components not needed for Linux when using external libs"
        rm -rf xbmc-$XBMC_VERSION/lib/bzip2
        rm -rf xbmc-$XBMC_VERSION/lib/enca
        rm -rf xbmc-$XBMC_VERSION/lib/freetype
        rm -rf xbmc-$XBMC_VERSION/lib/fribidi
        rm -rf xbmc-$XBMC_VERSION/lib/libass
        rm -rf xbmc-$XBMC_VERSION/lib/libcdio
        rm -rf xbmc-$XBMC_VERSION/lib/libcrystalhd
        rm -rf xbmc-$XBMC_VERSION/lib/libcurl-OSX
        rm -rf xbmc-$XBMC_VERSION/lib/libiconv
        rm -rf xbmc-$XBMC_VERSION/lib/liblame
        rm -rf xbmc-$XBMC_VERSION/lib/libmicrohttpd
        rm -rf xbmc-$XBMC_VERSION/lib/libmodplug
        rm -rf xbmc-$XBMC_VERSION/lib/librtmp
        rm -rf xbmc-$XBMC_VERSION/lib/libSDL-OSX
        rm -rf xbmc-$XBMC_VERSION/lib/libssh_win32
        rm -rf xbmc-$XBMC_VERSION/lib/pcre
        rm -rf xbmc-$XBMC_VERSION/libmicrohttpd_win32
        rm -rf xbmc-$XBMC_VERSION/libmysql_win32
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/liba52
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/libdts
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/libfaad2
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/libmad
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/dvdplayer/Codecs/libmpeg2
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/paplayer/FLACCodec/flac-1.2.1
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/paplayer/ogg
        rm -rf xbmc-$XBMC_VERSION/xbmc/cores/paplayer/vorbisfile
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/boost
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/libenca
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/libmms
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/libPython/Python
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/libsamplerate
        rm -rf xbmc-$XBMC_VERSION/xbmc/lib/zlib
    fi

    # Remove temp files and other cruft from source tarball
    # The find command snippet here was taken from debhelper's dh_clean command
    # with some modification to delete more unneeded files.
    echo "Removing temp files and other cruft from source tarball"
    find xbmc-$XBMC_VERSION \( \( -type f -a \
        \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
        -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
        -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
        -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
        -o -name config.status -o -name config.cache -o -name config.log \
        \) -exec rm -f "{}" \; \) -o \
        \( -type d -a -name autom4te.cache -prune -exec rm -rf "{}" \; \) \)
    rm xbmc-$XBMC_VERSION/.gitignore

    # Remove empty directories
    echo "Removing empty directories"
    find xbmc-$XBMC_VERSION -type d -empty -delete
}

# Function to create tarball
create_tarball() {
    echo "Create orig tarball"
    tar -czf xbmc_$XBMC_VERSION.orig.tar.gz \
        xbmc-$XBMC_VERSION/
}

get_sources
prepare_orig_tarball
create_tarball