|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# script control variables |
| 4 | + |
| 5 | +reponame="cap1xxx" # leave this blank for auto-detection |
| 6 | +libname="cap1xxx" # leave this blank for auto-detection |
| 7 | + |
| 8 | +debianlog="debian/changelog" |
| 9 | +debcontrol="debian/control" |
| 10 | +debcopyright="debian/copyright" |
| 11 | +debrules="debian/rules" |
| 12 | +debreadme="debian/README" |
| 13 | + |
| 14 | +debdir="$(pwd)" |
| 15 | +rootdir="$(dirname $debdir)" |
| 16 | +libdir="$rootdir/library" |
| 17 | + |
| 18 | +FLAG=false |
| 19 | + |
| 20 | +# function define |
| 21 | + |
| 22 | +success() { |
| 23 | + echo "$(tput setaf 2)$1$(tput sgr0)" |
| 24 | +} |
| 25 | + |
| 26 | +inform() { |
| 27 | + echo "$(tput setaf 6)$1$(tput sgr0)" |
| 28 | +} |
| 29 | + |
| 30 | +warning() { |
| 31 | + echo "$(tput setaf 1)$1$(tput sgr0)" |
| 32 | +} |
| 33 | + |
| 34 | +newline() { |
| 35 | + echo "" |
| 36 | +} |
| 37 | + |
| 38 | +# assessing repo and library variables |
| 39 | + |
| 40 | +if [ -z "$reponame" ] || [ -z "$libname" ]; then |
| 41 | + inform "detecting reponame and libname..." |
| 42 | +else |
| 43 | + inform "using reponame and libname overrides" |
| 44 | +fi |
| 45 | + |
| 46 | +if [ -z "$reponame" ]; then |
| 47 | + if [[ $rootdir == *"python"* ]]; then |
| 48 | + repodir="$(dirname $rootdir)" |
| 49 | + reponame="$(basename $repodir)" |
| 50 | + else |
| 51 | + repodir="$rootdir" |
| 52 | + reponame="$(basename $repodir)" |
| 53 | + fi |
| 54 | +fi |
| 55 | + |
| 56 | +if [ -z "$libname" ]; then |
| 57 | + cd "$libdir" |
| 58 | + libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev) |
| 59 | + cd "$debdir" |
| 60 | +fi |
| 61 | + |
| 62 | +echo "reponame is $reponame and libname is $libname" |
| 63 | + |
| 64 | +# checking generating changelog file |
| 65 | + |
| 66 | +./makelog.sh |
| 67 | +version=$(head -n 1 "$libdir/CHANGELOG.txt") |
| 68 | +echo "building $libname version $version" |
| 69 | + |
| 70 | +# checking debian/changelog file |
| 71 | + |
| 72 | +inform "checking debian/changelog file..." |
| 73 | + |
| 74 | +if ! head -n 1 $debianlog | grep "$libname" &> /dev/null; then |
| 75 | + warning "library not mentioned in header!" && FLAG=true |
| 76 | +elif head -n 1 $debianlog | grep "UNRELEASED"; then |
| 77 | + warning "this changelog is not going to generate a release!" |
| 78 | + warning "change distribution to 'stable'" && FLAG=true |
| 79 | +fi |
| 80 | + |
| 81 | +# checking debian/copyright file |
| 82 | + |
| 83 | +inform "checking debian/copyright file..." |
| 84 | + |
| 85 | +if ! grep "^Source" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then |
| 86 | + warning "$(grep "^Source" $debcopyright)" && FLAG=true |
| 87 | +fi |
| 88 | + |
| 89 | +if ! grep "^Upstream-Name" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then |
| 90 | + warning "$(grep "^Upstream-Name" $debcopyright)" && FLAG=true |
| 91 | +fi |
| 92 | + |
| 93 | +# checking debian/control file |
| 94 | + |
| 95 | +inform "checking debian/control file..." |
| 96 | + |
| 97 | +if ! grep "^Source" $debcontrol | grep "$libname" $debcontrol &> /dev/null; then |
| 98 | + warning "$(grep "^Source" $debcontrol)" && FLAG=true |
| 99 | +fi |
| 100 | + |
| 101 | +if ! grep "^Homepage" $debcontrol | grep "$reponame" $debcontrol &> /dev/null; then |
| 102 | + warning "$(grep "^Homepage" $debcontrol)" && FLAG=true |
| 103 | +fi |
| 104 | + |
| 105 | +if ! grep "^Package: python-$libname" $debcontrol &> /dev/null; then |
| 106 | + warning "$(grep "^Package: python-" $debcontrol)" && FLAG=true |
| 107 | +fi |
| 108 | + |
| 109 | +if ! grep "^Package: python3-$libname" $debcontrol &> /dev/null; then |
| 110 | + warning "$(grep "^Package: python3-" $debcontrol)" && FLAG=true |
| 111 | +fi |
| 112 | + |
| 113 | +if ! grep "^Priority: extra" $debcontrol &> /dev/null; then |
| 114 | + warning "$(grep "^Priority" $debcontrol)" && FLAG=true |
| 115 | +fi |
| 116 | + |
| 117 | + |
| 118 | +# checking debian/rules file |
| 119 | + |
| 120 | +inform "checking debian/rules file..." |
| 121 | + |
| 122 | +if ! grep "debian/python-$libname" $debrules &> /dev/null; then |
| 123 | + warning "$(grep "debian/python-" $debrules)" && FLAG=true |
| 124 | +fi |
| 125 | + |
| 126 | +if ! grep "debian/python3-$libname" $debrules &> /dev/null; then |
| 127 | + warning "$(grep "debian/python3-" $debrules)" && FLAG=true |
| 128 | +fi |
| 129 | + |
| 130 | +# checking debian/README file |
| 131 | + |
| 132 | +inform "checking debian/readme file..." |
| 133 | + |
| 134 | +if ! grep -e "$libname" -e "$reponame" $debreadme &> /dev/null; then |
| 135 | + warning "README does not seem to mention product, repo or lib!" && FLAG=true |
| 136 | +fi |
| 137 | + |
| 138 | +# summary of checks pre build |
| 139 | + |
| 140 | +if $FLAG; then |
| 141 | + warning "Check all of the above and correct!" && exit 1 |
| 142 | +else |
| 143 | + inform "we're good to go... bulding!" |
| 144 | +fi |
| 145 | + |
| 146 | +# building deb and final checks |
| 147 | + |
| 148 | +./makedeb.sh |
| 149 | + |
| 150 | +inform "running lintian..." |
| 151 | +lintian -v $(find -name "python*$version*.deb") |
| 152 | +lintian -v $(find -name "python3*$version*.deb") |
| 153 | + |
| 154 | +inform "checking signatures..." |
| 155 | +gpg --verify $(find -name "*$version*changes") |
| 156 | +gpg --verify $(find -name "*$version*dsc") |
| 157 | + |
| 158 | +exit 0 |
0 commit comments