]> TLD Linux GIT Repositories - packages/rpm-build-tools.git/blob - fetchsrc_request.sh
8d3e5e23dd0753d9bc2c7da86ea8d71d285670a6
[packages/rpm-build-tools.git] / fetchsrc_request.sh
1 #!/bin/sh
2 # $Id$
3 #
4 # Sending by
5 MAILER='/usr/sbin/sendmail'
6 # MAILER='/usr/bin/msmtp'
7 # Sending via
8 VIA="SENDMAIL"
9 #VIA="localhost"
10 VIA_ARGS=""
11 #VIA_ARGS="some additional flags"
12 # e.g. for msmtp:
13 # VIA_ARGS='-a gmail'
14 #
15 # DISTFILES EMAIL
16 DMAIL="df@tld-linux.org"
17 #
18 # CVS LOGIN or fill it by hand :)
19 tmp=$(git config user.email)
20 LOGIN=${tmp%@*}
21 #LOGIN="djrzulf"
22 #
23 # HOST
24 HOST=`hostname -f`
25 #HOST="knycz.net"
26 #
27 # functions
28
29 usage()
30 {
31         echo "Usage: fetchsrc_request file.spec [BRANCH]"
32         echo
33 }
34
35 #------------------
36 # main()
37 if [ "$#" = 0 ]; then
38         usage
39         exit 1
40 fi
41 if [ "$2" != "" ]; then
42         BRANCH="$2"
43 else
44         BRANCH="refs/heads/master"
45 fi
46 if [[ "$BRANCH" != refs/* ]]; then
47         BRANCH="refs/heads/$BRANCH"
48 fi
49 SPEC="$(basename $1)"
50 SPEC=${SPEC%.spec}
51
52 if [ "$VIA" = "SENDMAIL" ]; then
53         echo >&2 "Requesting $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
54         cat <<EOF | "$MAILER" -t -i $VIA_ARGS
55 To: $DMAIL
56 From: $LOGIN <$LOGIN@$HOST>
57 Subject: fetchsrc_request notify
58 X-distfiles-request: yes
59 X-Login: $LOGIN
60 X-Package: $SPEC
61 X-Branch: $BRANCH
62 X-Flags: force-reply
63
64 .
65 EOF
66 else
67         echo >&2 "Requesting $SPEC:$BRANCH via SMTP ($VIA:25)"
68         cat <<EOF | /usr/bin/nc $VIA 25 > /dev/null
69 EHLO $HOST
70 MAIL FROM: $LOGIN <$LOGIN@$HOST>
71 RCPT TO: $DMAIL
72 DATA
73 To: $DMAIL
74 Subject: fetchsrc_request notify
75 X-distfiles-request: yes
76 X-Login: $LOGIN
77 X-Package: $SPEC
78 X-Branch: $BRANCH
79 X-Flags: force-reply
80
81 .
82 QUIT
83 EOF
84 fi
85