Debian.zsh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #
  2. # Debian stuff
  3. #
  4. # specific aliases
  5. alias lintian="lintian --color=auto -IEm --pedantic"
  6. # building environements
  7. cow-dist () {
  8. if [ $# -lt 2 ]; then
  9. echo "Error args."
  10. return
  11. fi
  12. DIST=${1}
  13. shift
  14. OPTS=
  15. if [ "$1" = "--update" ]; then
  16. OPTS="--no-cowdancer-update"
  17. elif [ "$1" = "--build" -a -z "$2" ]; then
  18. if [ -f debian/changelog ]; then
  19. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  20. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  21. if [ -f "$dsc" ]; then
  22. OPTS="$dsc"
  23. fi
  24. fi
  25. fi
  26. WRAPPER=
  27. if echo ${DIST} | grep -q \^sid ; then
  28. if [ -x "$(which eatmydata)" ]; then
  29. WRAPPER="eatmydata"
  30. fi
  31. fi
  32. time sudo -E DIST=${DIST} ${WRAPPER} cowbuilder $@ ${OPTS}
  33. return $?
  34. }
  35. alias cow-sid32="cow-dist sid-32"
  36. alias cow-stable32="cow-dist stable-32"
  37. alias cow-exp64="cow-dist experimental-64"
  38. alias cow-sid64="cow-dist sid-64"
  39. alias cow-testing64="cow-dist testing-64"
  40. alias cow-stable64="cow-dist stable-64"
  41. alias cow-stablebpo="cow-dist stable-bpo-64"
  42. # tools
  43. apt-rbdepends () {
  44. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  45. }
  46. pdebdiff() {
  47. if [ ! -r debian/changelog ]; then
  48. echo "ERR: can't read debian/changelog"
  49. exit
  50. fi
  51. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  52. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  53. head -n2|tr '\n' $IFS | \
  54. read v1 v2
  55. if [ -z "$v1" -o -z "$v2" ]; then
  56. echo "ERR: can't find version \$n and \$n-1 of the package";
  57. exit
  58. fi
  59. if [ ! -r debian/control ]; then
  60. echo "ERR: can't read debian/control"
  61. exit
  62. fi
  63. egrep '^(Package|Architecture): ' debian/control | \
  64. while read line ; do
  65. pkg=$(echo $line|sed 's/Package: //')
  66. read line
  67. arch=$(echo $line|sed 's/Architecture: //')
  68. if [ $arch = 'any' ]; then
  69. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  70. fi
  71. (
  72. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  73. echo
  74. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  75. )|$PAGER
  76. done
  77. }
  78. pdeblint() {
  79. if [ ! -r debian/changelog ]; then
  80. echo "ERR: can't read debian/changelog"
  81. exit
  82. fi
  83. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  84. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  85. head -n1)
  86. if [ ! -r debian/control ]; then
  87. echo "ERR: can't read debian/control"
  88. exit
  89. fi
  90. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  91. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  92. changes="../${pkg}_${v}_${arch}.changes"
  93. if [ ! -r "$changes" ]; then
  94. echo "ERR: can't read changes file : ${changes}"
  95. exit
  96. fi
  97. lintian --color=auto -IEm --pedantic $changes $@
  98. }