Debian.zsh 3.2 KB

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