Debian.zsh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #
  2. # Debian stuff
  3. #
  4. # specific aliases / functions
  5. alias lintian="lintian --color=auto -IEm --pedantic"
  6. alias acp="apt-cache policy"
  7. alias acs="apt-cache search"
  8. alias acsh="apt-cache show"
  9. alias adg"sudo apt-get dist-upgrade"
  10. alias ag="sudo apt-get upgrade"
  11. alias agi="sudo apt-get install"
  12. alias au="sudo apt-get update"
  13. alias aug="sudo apt-get update && sudo apt-get upgrade"
  14. apt-rbdepends() {
  15. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  16. }
  17. debdoc() {
  18. cd /usr/share/doc/$1 && ls
  19. }
  20. dbug() {
  21. if [[ $# -eq 1 ]]; then
  22. case "$1" in
  23. [0-9]*)
  24. xdg-open "http://bugs.debian.org/$1"
  25. ;;
  26. *@*)
  27. xdg-open "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
  28. ;;
  29. *)
  30. xdg-open "http://bugs.debian.org/src:$*"
  31. ;;
  32. esac
  33. else
  34. print "$0 needs one argument"
  35. return 1
  36. fi
  37. }
  38. # specific completions
  39. # rdebsign is a trivial shell script wrapper around debsign
  40. compdef rdebsign=scp
  41. # building environements
  42. cow-dist() {
  43. if [ $# -lt 2 ]; then
  44. echo "Error args."
  45. return
  46. fi
  47. DIST=${1}
  48. shift
  49. OPTS=
  50. if [ "$1" = "--update" ]; then
  51. OPTS="--no-cowdancer-update"
  52. elif [ "$1" = "--build" -a -z "$2" ]; then
  53. if [ -f debian/changelog ]; then
  54. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  55. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  56. if [ -f "$dsc" ]; then
  57. OPTS="$dsc"
  58. fi
  59. fi
  60. fi
  61. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  62. return $?
  63. }
  64. cow-dist-update () {
  65. for dist in $@ ; do
  66. cow-dist ${dist} --update
  67. done
  68. }
  69. PBUILDER_PATH=/var/cache/pbuilder
  70. if [ -d "${PBUILDER_PATH}" ]; then
  71. PBUILDER_DISTS=
  72. for f in ${PBUILDER_PATH}/* ; do
  73. case "$f" in
  74. *-i386.cow|*-amd64.cow)
  75. dist=${f:t:r}
  76. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  77. alias cow-${dist/-/}="cow-dist ${dist}"
  78. ;;
  79. esac
  80. done
  81. if [ -n "${PBUILDER_DISTS}" ]; then
  82. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  83. fi
  84. unset PBUILDER_DISTS
  85. fi
  86. unset PBUILDER_PATH
  87. pdebdiff() {
  88. if [ ! -r debian/changelog ]; then
  89. echo "ERR: can't read debian/changelog"
  90. return
  91. fi
  92. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  93. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  94. head -n2 | tr '\n' $IFS | \
  95. read v1 v2
  96. if [ -z "$v1" -o -z "$v2" ]; then
  97. echo "ERR: can't find version \$n and \$n-1 of the package";
  98. return
  99. fi
  100. if [ ! -r debian/control ]; then
  101. echo "ERR: can't read debian/control"
  102. return
  103. fi
  104. egrep '^(Package|Architecture): ' debian/control | \
  105. while read line ; do
  106. pkg=$(echo $line|sed 's/Package: //')
  107. read line
  108. arch=$(echo $line|sed 's/Architecture: //')
  109. if [ $arch = 'any' ]; then
  110. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  111. fi
  112. (
  113. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  114. echo
  115. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  116. ) | $PAGER
  117. done
  118. }
  119. pdeblint() {
  120. if [ ! -r debian/changelog ]; then
  121. echo "ERR: can't read debian/changelog"
  122. return
  123. fi
  124. v=$(egrep -v "^([[:space:]]+|$)" debian/changelog | \
  125. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  126. head -n1)
  127. if [ ! -r debian/control ]; then
  128. echo "ERR: can't read debian/control"
  129. return
  130. fi
  131. pkg=$(grep '^Source: ' debian/control | sed 's/Source: //')
  132. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  133. changes="../${pkg}_${v}_${arch}.changes"
  134. if [ ! -r "$changes" ]; then
  135. echo "ERR: can't read changes file : ${changes}"
  136. return
  137. fi
  138. lintian --color=auto -IEm --pedantic $changes $@
  139. }