aboutsummaryrefslogtreecommitdiff
path: root/admin/offerbuild
blob: d06788886ef843e4773c3bcc3e3bd6f134429ffb (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
#!/bin/bash

source ~/sbostuff/sbostuff.sh

FROM_NAME="B. Watson"
FROM_EMAIL="urchlay@slackware.uk"

SELF="$( basename $0 )"

die() {
  echo "$SELF: $@" 2>&1
  exit 1
}

get_dependees() {
  local build="$1"
  local i

  i="$( git grep -l "^REQUIRES=.*\<$build\>" | cut -d/ -f1,2 )"
  echo $i
}

make_offer() {
  local i
  local j
  local mailto
  local build="$1"
  local dependees="$( get_dependees "$1" )"

  if [ "$dependees" = "" ]; then
    echo "No dependees for $build"
    return
  fi
  echo "$build dependees: $dependees"
  if [ "$dependees" = "" ]; then
    echo "=> no dependees for $build, nobody offer to!"
    return
  fi

  for i in $dependees; do
    cdsb $i
    mailto="$( git grep '^EMAIL=' *.info | cut -d\" -f2 )"

    [ "$mailto" = "NOEMAIL" ] && continue

    echo "=> Enter email address for offer [$mailto]:"
    read j
    [ "$j" = "" ] && j="$mailto"
    mailto="$j"

    tmpfile="$( mktemp $SELF.XXXXXXXXXX )"
    rm -f $tmpfile

    echo "To: $mailto"
    cat <<EOF >$tmpfile
From: $FROM_NAME <$FROM_EMAIL>
Subject: $( basename $i ) and $build on SBo

$build needs a new maintainer. Your build $( basename $i ) lists it as
a dependency, so you're the logical choice to take it over.

If you want, I can update the .info file with your contact
information, so you don't even have to submit an update.
EOF
    cat $tmpfile

    echo
    echo -n "=> Send this email[y]? "
    read j

    if [ "$j" = "y" -o "$j" = "Y" -o "$j" = "" ]; then
      j="y"
      echo "==> Sending email to $mailto"
      cat $tmpfile | msmtp "$mailto"
    fi

    rm -f $tmpfile
    [ "$j" = "y" ] && return
  done
}

### main()
hoorex --version > /dev/null || die "hoorex not installed"

cd $SBO_GITROOT || die "edit sbostuff.sh and set SBO_GITROOT"

for build in "$@"; do
  echo "checking $build"
  make_offer "$build"
done