Debian.zsh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  27. return $?
  28. }
  29. cow-dist-update () {
  30. for dist in $@ ; do
  31. cow-dist ${dist} --update
  32. done
  33. }
  34. PBUILDER_PATH=/var/cache/pbuilder
  35. if [ -d "${PBUILDER_PATH}" ]; then
  36. PBUILDER_DISTS=
  37. for f in ${PBUILDER_PATH}/* ; do
  38. case "$f" in
  39. *-i386.cow|*-amd64.cow)
  40. dist=${f:t:r}
  41. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  42. alias cow-${dist/-/}="cow-dist ${dist}"
  43. ;;
  44. esac
  45. done
  46. if [ -n "${PBUILDER_DISTS}" ]; then
  47. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  48. fi
  49. unset PBUILDER_DISTS
  50. fi
  51. unset PBUILDER_PATH
  52. # tools
  53. apt-rbdepends () {
  54. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  55. }
  56. pdebdiff() {
  57. if [ ! -r debian/changelog ]; then
  58. echo "ERR: can't read debian/changelog"
  59. exit
  60. fi
  61. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  62. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  63. head -n2|tr '\n' $IFS | \
  64. read v1 v2
  65. if [ -z "$v1" -o -z "$v2" ]; then
  66. echo "ERR: can't find version \$n and \$n-1 of the package";
  67. exit
  68. fi
  69. if [ ! -r debian/control ]; then
  70. echo "ERR: can't read debian/control"
  71. exit
  72. fi
  73. egrep '^(Package|Architecture): ' debian/control | \
  74. while read line ; do
  75. pkg=$(echo $line|sed 's/Package: //')
  76. read line
  77. arch=$(echo $line|sed 's/Architecture: //')
  78. if [ $arch = 'any' ]; then
  79. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  80. fi
  81. (
  82. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  83. echo
  84. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  85. )|$PAGER
  86. done
  87. }
  88. pdeblint() {
  89. if [ ! -r debian/changelog ]; then
  90. echo "ERR: can't read debian/changelog"
  91. exit
  92. fi
  93. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  94. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  95. head -n1)
  96. if [ ! -r debian/control ]; then
  97. echo "ERR: can't read debian/control"
  98. exit
  99. fi
  100. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  101. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  102. changes="../${pkg}_${v}_${arch}.changes"
  103. if [ ! -r "$changes" ]; then
  104. echo "ERR: can't read changes file : ${changes}"
  105. exit
  106. fi
  107. lintian --color=auto -IEm --pedantic $changes $@
  108. }