50_debian.zsh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. # fix some zpresto aliases
  21. unalias debi
  22. apt-rbdepends() {
  23. grep-dctrl -F Build-Depends "$1" -s Package /var/lib/apt/lists/*_Sources
  24. }
  25. debdoc() {
  26. cd /usr/share/doc/$1 && ls
  27. }
  28. dbug() {
  29. if [[ $# -eq 1 ]]; then
  30. case "$1" in
  31. [0-9]*)
  32. xdg-open "http://bugs.debian.org/$1"
  33. ;;
  34. *@*)
  35. xdg-open "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
  36. ;;
  37. *)
  38. xdg-open "http://bugs.debian.org/src:$*"
  39. ;;
  40. esac
  41. else
  42. print "$0 needs one argument"
  43. return 1
  44. fi
  45. }
  46. # specific completions
  47. # rdebsign is a trivial shell script wrapper around debsign
  48. #compdef rdebsign=scp
  49. # building environements
  50. cow-dist() {
  51. if [ $# -lt 2 ]; then
  52. echo "Error args."
  53. return
  54. fi
  55. DIST=${1}
  56. shift
  57. OPTS=
  58. if [ "$1" = "--update" ]; then
  59. OPTS="--no-cowdancer-update"
  60. elif [ "$1" = "--build" -a -z "$2" ]; then
  61. if [ -f debian/changelog ]; then
  62. dsc=$(egrep -v "^([[:space:]]+|$)" debian/changelog| \
  63. sed 's/\([^ ]*\) (\([^)]*\)).*/..\/\1_\2.dsc/'|head -1)
  64. if [ -f "$dsc" ]; then
  65. OPTS="$dsc"
  66. fi
  67. fi
  68. fi
  69. time sudo -E DIST=${DIST} cowbuilder $@ ${OPTS}
  70. return $?
  71. }
  72. cow-dist-update () {
  73. for dist in $@ ; do
  74. cow-dist ${dist} --update
  75. done
  76. }
  77. PBUILDER_PATH=/var/cache/pbuilder
  78. if [ -d "${PBUILDER_PATH}" ]; then
  79. PBUILDER_DISTS=
  80. for f in ${PBUILDER_PATH}/* ; do
  81. case "$f" in
  82. *-i386.cow|*-amd64.cow)
  83. dist=${f:t:r}
  84. PBUILDER_DISTS="${PBUILDER_DISTS} ${dist}"
  85. alias cow-${dist/-/}="cow-dist ${dist}"
  86. ;;
  87. esac
  88. done
  89. if [ -n "${PBUILDER_DISTS}" ]; then
  90. alias cow-update="cow-dist-update ${PBUILDER_DISTS}"
  91. fi
  92. unset PBUILDER_DISTS
  93. fi
  94. unset PBUILDER_PATH
  95. pdebdiff() {
  96. if [ ! -r debian/changelog ]; then
  97. echo "ERR: can't read debian/changelog"
  98. return
  99. fi
  100. egrep -v "^([[:space:]]+|$)" debian/changelog | \
  101. sed 's/[^ ]* (\([^)]*\)).*/\1/' | \
  102. head -n2 | tr '\n' $IFS | \
  103. read v1 v2
  104. if [ -z "$v1" -o -z "$v2" ]; then
  105. echo "ERR: can't find version \$n and \$n-1 of the package";
  106. return
  107. fi
  108. if [ ! -r debian/control ]; then
  109. echo "ERR: can't read debian/control"
  110. return
  111. fi
  112. egrep '^(Package|Architecture): ' debian/control | \
  113. while read line ; do
  114. pkg=$(echo $line|sed 's/Package: //')
  115. read line
  116. arch=$(echo $line|sed 's/Architecture: //')
  117. if [ $arch = 'any' ]; then
  118. arch=$(dpkg-architecture -qDEB_HOST_ARCH)
  119. fi
  120. (
  121. echo "*** DIFF ${pkg}_${v2} -> ${pkg}_${v1} ***"
  122. echo
  123. debdiff ../${pkg}_${v2}_${arch}.deb ../${pkg}_${v1}_${arch}.deb
  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. }