aboutsummaryrefslogtreecommitdiffstats
path: root/dist/build_debian.sh
blob: 44ebf0446fcfdaf5497132d94755c6c4525e3c02 (about) (plain) (blame)
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
#!/bin/bash

test -z "$DEBFULLNAME" && export DEBFULLNAME="Alexander Pozdnyakov"
test -z "$DEBEMAIL" && export DEBEMAIL="kvircbot@gmail.com"

#export DEBEMAIL="kvircbot@gmail.com"
#export GPGPASS=secret
#export AESPASS=secret

bin_debuild=$(which debuild 2>/dev/null)

while getopts "p" Option
do
    case $Option in
        p) PPA=1 ;;
    esac
done
shift $((OPTIND - 1))

if [ ! -x "$bin_debuild" ]
then
    echo "Please install debuild (package devscripts)."
    exit 1
fi

DIR=$(pwd)
BUILDDIR="${DIR}/build"
cd .. && GITDIR=$(pwd)
PKG_NAME=kvirc
SVNGITBZR="~git-"
VERSION='4:5.2.10'
VERSION1='5.2.10'
TMPFILE=$(mktemp)
TMPGPG=$(mktemp)
DIST_PPA="xenial bionic cosmic"
PPANAME=kvirc

dchppa_pkg(){
NEW_VER=$(dpkg-parsechangelog | awk '/^Version: / {print $2}')
cd "$BUILDDIR/${PKG_NAME}-${VERSION1}${SVNGITBZR}${dat}/" || exit 1
cp -f debian/changelog "${TMPFILE}"
for i in ${DIST_PPA}
do
cp -f "${TMPFILE}" debian/changelog
dch -b --force-distribution --distribution "$i" -v "${NEW_VER}ppa1~${i}1" \
  "Automated backport upload; no source changes."
echo "$SOURCEUP" | grep -q YES && debuild --no-lintian -p"gpg --passphrase-file $TMPGPG --batch --no-use-agent" -S -sa
echo "$SOURCEUP" | grep -q YES || debuild --no-lintian -p"gpg --passphrase-file $TMPGPG --batch --no-use-agent" -S -sd
SOURCEUP=YES
done
unset SOURCEUP
for i in ${DIST_PPA}
do
dput "${PPANAME}" "../${PKG_NAME}_*${i}1_source.changes"
sleep 10
done
cp -f "${TMPFILE}" debian/changelog
}

dputcf(){
cat > ~/.dput.cf << EOF
[kvirc]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~kvirc/kvirc/ubuntu/
login = anonymous
allow_unsigned_uploads = 0

EOF
}

tmpgpg(){
cat > "$TMPGPG" << EOF
$GPGPASS
EOF
}
gpgkey(){
openssl enc -d -aes-256-cbc -in "${DIR}/secret.enc" -out "${DIR}/secret.gpg" -k "${AESPASS}"
gpg --import "${DIR}/public.gpg"
gpg --allow-secret-key-import --import "${DIR}/secret.gpg"
}

test -d "$BUILDDIR" && rm -rf "${BUILDDIR}"
mkdir -p "$BUILDDIR"
cd "$GITDIR" || exit 1
abbrevcommit=$(git log -1 --abbrev-commit | grep -i "^commit" | awk '{print $2}')
numcommit=$(git log | grep -c "^Date:")
dat="${numcommit}-${abbrevcommit}"
#dat=$(git describe --dirty)
branch=$(git branch | grep "\*" | sed 's/\* //g')
commit=$(git log -1 | grep -i "^commit" | awk '{print $2}')
datct=$(git log -n 1 --format=%ct)

test -z "${dat}" && dat="git-99999-$(git describe --always)"
test -z "${branch}" && branch="travis_debian"

if [ ! -z "$PPA" ]
then
    branch="${TRAVIS_BRANCH}"
fi

tar -cpf  "${BUILDDIR}/${PKG_NAME}_${VERSION1}${SVNGITBZR}${dat}.orig.tar" --exclude ".git" --exclude "dist" .
cd "${BUILDDIR}" || exit 1
xz -9 "${PKG_NAME}_${VERSION1}${SVNGITBZR}${dat}.orig.tar"
mkdir "${PKG_NAME}-${VERSION1}${SVNGITBZR}${dat}"
tar -xpJf "${PKG_NAME}_${VERSION1}${SVNGITBZR}${dat}.orig.tar.xz" -C "${PKG_NAME}-${VERSION1}${SVNGITBZR}${dat}"
cd "$DIR" || exit 1
cp -r debian "$BUILDDIR/${PKG_NAME}-${VERSION1}${SVNGITBZR}${dat}/debian"
cd "$BUILDDIR/${PKG_NAME}-${VERSION1}${SVNGITBZR}${dat}/" || exit 1
dch -v "${VERSION}${SVNGITBZR}${dat}-1" -D "unstable" --force-distribution "Compile"
dch -a "Branch: $branch"
dch -a "Commit: $commit"
dch -a "Date: $datct"

if [ -z "$PPA" ]
then
    if [ ! -z "${TRAVIS_BRANCH}" ]
    then
        sed -i '/^ cmake (>= 3.1),/d' debian/control
        debuild --no-lintian --preserve-env --prepend-path="${PATH}" -us -uc
    else
        debuild --no-lintian -us -uc
    fi
else
    gpgkey
    tmpgpg
    test -f ~/.dput.cf || dputcf
    dchppa_pkg
fi