init
This commit is contained in:
41
.zprezto/modules/dpkg/README.md
Normal file
41
.zprezto/modules/dpkg/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
Dpkg
|
||||
====
|
||||
|
||||
Defines [dpkg][1] aliases and functions.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
- `debc` cleans the cache.
|
||||
- `debf` displays a file's package.
|
||||
- `debi` installs packages from repositories.
|
||||
- `debI` installs packages from files.
|
||||
- `debq` displays package information.
|
||||
- `debu` updates the package lists.
|
||||
- `debU` upgrades outdated packages.
|
||||
- `debx` removes packages.
|
||||
- `debX` removes packages, their configuration, and unneeded dependencies.
|
||||
- `debs` searches for packages.
|
||||
- `deb-build` creates a basic deb package.
|
||||
- `deb-kclean` removes all kernel images and headers, except for the ones in
|
||||
use.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `deb-clone` generates a script that can be used to duplicate a dpkg-based
|
||||
system.
|
||||
- `deb-history` displays dpkg history.
|
||||
- `deb-kbuild` makes a dpkg Linux kernel package.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the [issue tracker][2].*
|
||||
|
||||
- [Daniel Bolton](https://github.com/dbb)
|
||||
- [Benjamin Boudreau](https://github.com/dreur)
|
||||
- [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||
|
||||
[1]: http://wiki.debian.org/Teams/Dpkg
|
||||
[2]: https://github.com/sorin-ionescu/prezto/issues
|
25
.zprezto/modules/dpkg/functions/deb-clone
Normal file
25
.zprezto/modules/dpkg/functions/deb-clone
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Generates a script that can be used to duplicate a dpkg-based system.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <danielbarrettbolton@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local clone_script="${0}.sh"
|
||||
local package_list=$(
|
||||
perl \
|
||||
-m 'AptPkg::Cache' \
|
||||
-e '
|
||||
$c=AptPkg::Cache->new;
|
||||
for (keys %$c) {
|
||||
push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';
|
||||
}
|
||||
print "$_ " for sort @a;
|
||||
'
|
||||
)
|
||||
|
||||
rm "$clone_script"
|
||||
print '#!/bin/sh\n' > "$clone_script"
|
||||
print "aptitude install ${package_list}\n" >> "$clone_script"
|
||||
chmod +x "$clone_script"
|
36
.zprezto/modules/dpkg/functions/deb-history
Normal file
36
.zprezto/modules/dpkg/functions/deb-history
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Displays dpkg history.
|
||||
#
|
||||
# Authors:
|
||||
# Peter Leung <commandolinux@gmail.com>
|
||||
# Benjamin Boudreau <boudreau.benjamin@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
case "$1" in
|
||||
(install)
|
||||
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(upgrade|remove)
|
||||
zgrep --no-filename "$1" $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(rollback)
|
||||
zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) \
|
||||
| grep "$2" -A10000000 \
|
||||
| grep "$3" -B10000000 \
|
||||
| awk '{print $4"="$5}'
|
||||
;;
|
||||
(list)
|
||||
zcat $(ls -rt /var/log/dpkg*)
|
||||
;;
|
||||
(*)
|
||||
cat >&2 <<EOF
|
||||
Commands:
|
||||
install - List installed packages
|
||||
upgrade - List upgraded packages
|
||||
remove - List removed packages
|
||||
rollback - List rollback information
|
||||
list - Display contents of dpkg logs
|
||||
EOF
|
||||
;;
|
||||
esac
|
14
.zprezto/modules/dpkg/functions/deb-kbuild
Normal file
14
.zprezto/modules/dpkg/functions/deb-kbuild
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Makes a dpkg Linux kernel package.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <dbb@9y.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
make-kpkg clean
|
||||
MAKEFLAGS='' time fakeroot make-kpkg \
|
||||
--append-to-version '-custom' \
|
||||
--revision "$(date +"%Y%m%d")" \
|
||||
kernel_image \
|
||||
kernel_headers
|
57
.zprezto/modules/dpkg/init.zsh
Normal file
57
.zprezto/modules/dpkg/init.zsh
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Defines dpkg aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Daniel Bolton <dbb@9y.com>
|
||||
# Benjamin Boudreau <boudreau.benjamin@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[dpkg] && ! $+commands[apt-get] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
# Cleans the cache.
|
||||
alias debc='sudo apt-get clean && sudo apt-get autoclean'
|
||||
|
||||
# Displays a file's package.
|
||||
alias debf='apt-file search --regexp'
|
||||
|
||||
# Installs packages from repositories.
|
||||
alias debi='sudo apt-get install'
|
||||
|
||||
# Installs packages from files.
|
||||
alias debI='sudo dpkg -i'
|
||||
|
||||
# Displays package information.
|
||||
alias debq='apt-cache show'
|
||||
|
||||
# Updates the package lists.
|
||||
alias debu='sudo apt-get update'
|
||||
|
||||
# Upgrades outdated packages.
|
||||
alias debU='sudo apt-get update && sudo apt-get dist-upgrade'
|
||||
|
||||
# Removes packages.
|
||||
alias debx='sudo apt-get remove'
|
||||
|
||||
# Removes packages, their configuration, and unneeded dependencies.
|
||||
alias debX='sudo apt-get remove --purge && sudo apt-get autoremove --purge'
|
||||
|
||||
# Searches for packages.
|
||||
if (( $+commands[aptitude] )); then
|
||||
alias debs='aptitude -F "* %p -> %d \n(%v/%V)" --no-gui --disable-columns search'
|
||||
else
|
||||
alias debs='apt-cache search'
|
||||
fi
|
||||
|
||||
# Creates a basic deb package.
|
||||
alias deb-build='time dpkg-buildpackage -rfakeroot -us -uc'
|
||||
|
||||
# Removes all kernel images and headers, except for the ones in use.
|
||||
alias deb-kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))"'
|
Reference in New Issue
Block a user