50_debian.zsh 4.3 KB

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