build-publicfile 3.62 KB
Newer Older
1 2
#!/bin/sh -e

3
# this file maintained using git at
Joost van Baal-Ilić's avatar
Joost van Baal-Ilić committed
4
# ssh+git://git.debian.org/git/collab-maint/publicfile-installer.git
5 6 7

#
# Copyright (C) 2006, 2007 Joost van Baal
8
# Copyright (C) 2015 Joost van Baal-Ilić
9 10 11 12 13 14 15 16
#
# This file is free software; you can redistribute it and/or modify it under
# the terms of the GNU GPL as published by the FSF; version 3 of the License,
# or any later version. You should have received a copy of the GNU GPL along
# with this file (see COPYING); if not, check
# http://www.gnu.org/copyleft/gpl.html.
#

17
for f in /etc/publicfile-installer.conf /usr/local/etc/publicfile-installer.conf $HOME/.publicfile-installer.conf
18 19 20 21
do
    test -f $f && . $f
done

22
# check wether sources are present; if not, call get-publicfile
23 24 25 26
check_sources

if test -z "$DIFFDIR"
then
27
    echo "No valid .debian.tar.gz found"
28 29 30 31
fi

if test -z "$TARDIR"
then
32
    echo "No valid upstream .tar.gz found"
33 34 35 36 37 38
fi

if test -z "$TARDIR" -o -z "$DIFFDIR"
then
    if test "$1" = "go"
    then
39
        echo "Please run get-publicfile to fetch sources."
40 41 42
        exit 1
    elif ask_user "Do you want to fetch sources now? [Yn] " 0
    then
43
        exec get-publicfile
44
    else
45
        echo "OK, you can run get-publicfile later."
46 47 48
    fi
fi

Joost van Baal-Ilić's avatar
Joost van Baal-Ilić committed
49
if test -f "$DIFFDIR/publicfile_$DEBVERSION*.deb"
50 51 52 53 54 55 56
then
    echo "File $DIFFDIR/$DEBFILE already built.  No need to rebuild."
else

    # create build dir, copy sources to build dir
    BUILDDIR=`mktemp -d` || exit 1
    cd $BUILDDIR
57

58
    if test -f "$TARDIR/$TARFILE" -a -f "$DIFFDIR/$DIFFFILE" -a -f "$DIFFDIR/$DSCFILE"
59
    then
60 61 62
        cp $TARDIR/$TARFILE .
        cp $DIFFDIR/$DIFFFILE .
        cp $DIFFDIR/$DSCFILE .
63
    else
64 65 66
        echo "File '$DIFFFILE' and/or '$DSCFILE' not found in directory '$DIFFDIR'; and/or file '$TARFILE' not found in directory '$TARDIR'."
        echo "Please run get-publicfile to fetch sources."
        exit 1
67
    fi
68

69 70 71 72 73
    if ! test -L $ORIGFILE
    then
        rm -f $ORIGFILE
        ln -s $TARFILE $ORIGFILE
    fi
74

75
    echo "Preparing build of '$DEBFILE' in '$BUILDDIR'..."
76

77
    # unpack, patch and build
78 79 80 81 82 83
    dpkg-source -x publicfile*.dsc

    ## tar zxf $TARFILE
    ## cd publicfile-?.??/
    ## zcat ../$DIFFFILE | patch -p1 --quiet
    ## chmod a+x debian/rules
84

85 86 87
    cd publicfile-?.??/

    echo "Building $DEBFILE in `pwd` (if you won't get a message $DEBFILE is"
88 89 90 91 92
    echo "ready, inspect the build log in $BUILDDIR/build.log to see"
    echo "what went wrong)..."
    dpkg-buildpackage -rfakeroot -b -uc >$BUILDDIR/build.log 2>&1

    # clean up build dir
93 94 95 96 97 98
    if ! cp ../publicfile_$DEBVERSION*.deb $DIFFDIR
    then
        echo "Error copying ../publicfile_$DEBVERSION*.deb to $DIFFDIR."
        echo "Inspect `pwd` and $DIFFDIR to see what went wrong."
        exit 1
    fi
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

    echo " ---------------"
    echo "| $DIFFDIR/$DEBFILE ready, build log in $BUILDDIR/build.log."
    echo " ---------------"

    if test "$1" = "go"
    then
        rm -rf $BUILDDIR
    elif ask_user "Do you want to keep build stuff in $BUILDDIR, e.g. for debugging? [Ny] " 1
    then
        echo "OK, keeping $BUILDDIR.  You can remove it manually later."
    else
        rm -rf $BUILDDIR
    fi
fi

115 116
#test -d /tmp/publicfile-installer/ || mkdir /tmp/publicfile-installer/
#cp $DIFFDIR/publicfile_$DEBVERSION*.deb /tmp/publicfile-installer/
117

118
install_publicfile="sudo dpkg -i $DIFFDIR/publicfile_$DEBVERSION*.deb"
119 120 121
if test "$1" = "go"
then
    # non-interactive mode, called from within dpkg
122
    echo "Remember to run $install_publicfile later."
123
elif ask_user "Do you want to install the publicfile package now? [Yn] " 0
124
then
125 126
    # exec install-publicfile
    exec $install_publicfile
127
else
128
    echo "OK, you can run $install_publicfile later."
129
fi