From bce3c8efc7a2d187984aa0e7037307b99c217fd7 Mon Sep 17 00:00:00 2001 From: Nezmer Date: Tue, 12 Oct 2010 00:20:57 +0300 Subject: Add .in extension to files in contrib This is needed If we want to use sysconfdir,localstatedir and other variables. Signed-off-by: Nezmer Signed-off-by: Dan McGee --- contrib/PKGBUILD.vim | 259 ----------------------------------- contrib/PKGBUILD.vim.in | 259 +++++++++++++++++++++++++++++++++++ contrib/bacman | 310 ------------------------------------------ contrib/bacman.in | 310 ++++++++++++++++++++++++++++++++++++++++++ contrib/bash_completion | 115 ---------------- contrib/bash_completion.in | 115 ++++++++++++++++ contrib/pacdiff | 80 ----------- contrib/pacdiff.in | 80 +++++++++++ contrib/paclist | 88 ------------ contrib/paclist.in | 88 ++++++++++++ contrib/pacscripts | 132 ------------------ contrib/pacscripts.in | 132 ++++++++++++++++++ contrib/pacsearch | 130 ------------------ contrib/pacsearch.in | 130 ++++++++++++++++++ contrib/pactree | 322 ------------------------------------------- contrib/pactree.in | 322 +++++++++++++++++++++++++++++++++++++++++++ contrib/vimprojects | 25 ---- contrib/vimprojects.in | 25 ++++ contrib/wget-xdelta.sh | 70 ---------- contrib/wget-xdelta.sh.in | 70 ++++++++++ contrib/zsh_completion | 332 --------------------------------------------- contrib/zsh_completion.in | 332 +++++++++++++++++++++++++++++++++++++++++++++ 22 files changed, 1863 insertions(+), 1863 deletions(-) delete mode 100644 contrib/PKGBUILD.vim create mode 100644 contrib/PKGBUILD.vim.in delete mode 100755 contrib/bacman create mode 100755 contrib/bacman.in delete mode 100644 contrib/bash_completion create mode 100644 contrib/bash_completion.in delete mode 100755 contrib/pacdiff create mode 100755 contrib/pacdiff.in delete mode 100755 contrib/paclist create mode 100755 contrib/paclist.in delete mode 100755 contrib/pacscripts create mode 100755 contrib/pacscripts.in delete mode 100755 contrib/pacsearch create mode 100755 contrib/pacsearch.in delete mode 100755 contrib/pactree create mode 100755 contrib/pactree.in delete mode 100644 contrib/vimprojects create mode 100644 contrib/vimprojects.in delete mode 100755 contrib/wget-xdelta.sh create mode 100755 contrib/wget-xdelta.sh.in delete mode 100644 contrib/zsh_completion create mode 100644 contrib/zsh_completion.in (limited to 'contrib') diff --git a/contrib/PKGBUILD.vim b/contrib/PKGBUILD.vim deleted file mode 100644 index 8b40ed7c..00000000 --- a/contrib/PKGBUILD.vim +++ /dev/null @@ -1,259 +0,0 @@ -" Vim syntax file -" Language: PKGBUILD -" Maintainer: Alessio 'mOLOk' Bolognino -" Last Change: 2007/05/08 -" Version Info: PKGBUILD-0.2 (colorphobic) - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -let b:main_syntax = "sh" -runtime! syntax/sh.vim - -" case on -syn case match - -" pkgname -" FIXME if '=' is in pkgname/pkgver, it highlights whole string, not just '=' -syn keyword pb_k_pkgname pkgname contained -syn match pbValidPkgname /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgname -syn match pbIllegalPkgname /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained -syn match pbPkgnameGroup /^pkgname=.*/ contains=pbIllegalPkgname,pb_k_pkgname,shDoubleQuote,shSingleQuote - -" pkgbase -" FIXME if '=' is in pkgbase/pkgname/pkgver, it highlights whole string, not just '=' -syn keyword pb_k_pkgbase pkgbase contained -syn match pbValidPkgbase /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgbase -syn match pbIllegalPkgbase /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained -syn match pbPkgbaseGroup /^pkgbase=.*/ contains=pbIllegalPkgbase,pb_k_pkgbase,shDoubleQuote,shSingleQuote - -" pkgver -syn keyword pb_k_pkgver pkgver contained -syn match pbValidPkgver /\([[:alnum:]]\|\.\|+\|_\)/ contained contains=pbIllegalPkgver -syn match pbIllegalPkgver /[^[:alnum:]+=\.\_]\|=.*=/ contained -syn match pbPkgverGroup /^pkgver=.*/ contains=pbIllegalPkgver,pbValidPkgver,pb_k_pkgver,shDoubleQuote,shSingleQuote - -" pkgrel -syn keyword pb_k_pkgrel pkgrel contained -syn match pbValidPkgrel /[[:digit:]]*/ contained contains=pbIllegalPkgver -syn match pbIllegalPkgrel /[^[:digit:]=]\|=.*=/ contained -syn match pbPkgrelGroup /^pkgrel=.*/ contains=pbIllegalPkgrel,pbValidPkgrel,pb_k_pkgrel,shDoubleQuote,shSingleQuote - -" pkgdesc -syn keyword pb_k_desc pkgdesc contained -" 90 chars: 80 for description, 8 for pkgdesc and 2 for '' -syn match pbIllegalPkgdesc /.\{90,}\|=['"]\?.*['" ]\+[iI][sS] [aA]/ contained contains=pbPkgdescSign -syn match pbValidPkgdesc /[^='"]\.\{,80}/ contained contains=pbIllegalPkgdesc -syn match pbPkgdescGroup /^pkgdesc=.*/ contains=pbIllegalPkgdesc,pb_k_desc,pbValidPkgdesc,shDoubleQuote,shSingleQuote -syn match pbPkgdescSign /[='"]/ contained - -" url -syn keyword pb_k_url url contained -syn match pbValidUrl /['"]*\(https\|http\|ftp\)\:\/.*\.\+.*/ contained - -syn match pbIllegalUrl /[^=]/ contained contains=pbValidUrl -syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubleQuote,shSingleQuote - -" license -syn keyword pb_k_license license contained -syn keyword pbLicense APACHE CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PHP PSF PerlArtistic RALINK RUBY ZPL contained -syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained -syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicense -syn region pbLicenseGroup start=/^license=(/ end=/)/ contains=pb_k_license,pbLicenseCustom,pbLicense,pbIllegalLicense - -" backup -syn keyword pb_k_backup backup contained -syn match pbValidBackup /\.\?[[:alpha:]]*\/[[:alnum:]\{\}+._$-]*]*/ contained -syn region pbBackupGroup start=/^backup=(/ end=/)/ contains=pb_k_backup,pbValidBackup,shDoubleQuote,shSingleQuote - -" arch -syn keyword pb_k_arch arch contained -syn keyword pbArch i686 x86_64 ppc any contained -syn match pbIllegalArch /[^='"() ]/ contained contains=pbArch -syn region pbArchGroup start=/^arch=(/ end=/)/ contains=pb_k_arch,pbArch,pbIllegalArch - -" groups -syn keyword pb_k_groups groups contained -syn match pbValidGroups /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbGroupsGroup start=/^groups=(/ end=/)/ contains=pb_k_groups,pbValidGroups,shDoubleQuote,shSingleQuote - -" depends -syn keyword pb_k_depends depends contained -syn match pbValidDepends /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbDependsGroup start=/^depends=(/ end=/)/ contains=pb_k_depends,pbValidDepends,shDoubleQuote,shSingleQuote - -" makedepends -syn keyword pb_k_makedepends makedepends contained -syn match pbValidMakedepends /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbMakedependsGroup start=/^makedepends=(/ end=/)/ contains=pb_k_makedepends,pbValidMakedepends,shDoubleQuote,shSingleQuote - -" optdepends -syn keyword pb_k_optdepends optdepends contained -syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote - -" conflicts -syn keyword pb_k_conflicts conflicts contained -syn match pbValidConflicts /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbConflictsGroup start=/^conflicts=(/ end=/)/ contains=pb_k_conflicts,pbValidConflicts,shDoubleQuote,shSingleQuote - -" provides -syn keyword pb_k_provides provides contained -syn match pbValidProvides /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbProvidesGroup start=/^provides=(/ end=/)/ contains=pb_k_provides,pbValidProvides,shDoubleQuote,shSingleQuote - -" replaces -syn keyword pb_k_replaces replaces contained -syn match pbValidReplaces /\([[:alnum:]]\|+\|-\|_\)*/ contained -syn region pbReplacesGroup start=/^replaces=(/ end=/)/ contains=pb_k_replaces,pbValidReplaces,shDoubleQuote,shSingleQuote - -" install -" XXX remove install from bashStatement, fix strange bug -syn clear bashStatement -syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch - -syn keyword pb_k_install install contained -syn match pbValidInstall /\([[:alnum:]]\|\$\|+\|-\|_\)*\.install/ contained -syn match pbIllegalInstall /[^=]/ contained contains=pbValidInstall -syn match pbInstallGroup /^install=.*/ contains=pb_k_install,pbValidInstall,pbIllegalInstall,shDeref,shDoubleQuote,shSingleQuote - -" changelog -syn keyword pb_k_changelog changelog contained -syn match pbValidChangelog /\([[:alnum:]]\|\$\|+\|-\|_\)*/ contained -syn match pbIllegalChangelog /[^=]/ contained contains=pbValidChangelog -syn match pbChangelogGroup /^changelog=.*/ contains=pb_k_changelog,pbValidChangelog,pbIllegalChangelog,shDeref,shDoubleQuote,shSingleQuote - -" source: -" XXX remove source from shStatement, fix strange bug -syn clear shStatement -syn keyword shStatement xxx wait getopts return autoload whence printf true popd nohup enable r trap readonly fc fg kill ulimit umask disown stop pushd read history logout times local exit test pwd time eval integer suspend dirs shopt hash false newgrp bg print jobs continue functions exec help cd break unalias chdir type shift builtin let bind - -syn keyword pb_k_source source contained -syn match pbIllegalSource /\(http\|ftp\|https\).*\.\+\(dl\|download.\?\)\.\(sourceforge\|sf\).net/ -syn region pbSourceGroup start=/^source=(/ end=/)/ contains=pb_k_source,pbIllegalSource,shNumber,shDoubleQuote,shSingleQuote,pbDerefEmulation -syn match pbDerefEmulation /\$[{]\?[[:alnum:]_]*[}]\?/ contained -hi def link pbDerefEmulation PreProc - -" md5sums -syn keyword pb_k_md5sums md5sums contained -syn match pbIllegalMd5sums /[^='"()\/ ]/ contained contains=pbValidMd5sums -syn match pbValidMd5sums /\x\{32\}/ contained -syn region pbMd5sumsGroup start=/^md5sums/ end=/)/ contains=pb_k_md5sums,pbMd5Quotes,pbMd5Hash,pbIllegalMd5sums keepend -syn match pbMd5Quotes /'.*'\|".*"/ contained contains=pbMd5Hash,pbIllegalMd5sums -syn match pbMd5Hash /\x\+/ contained contains=pbValidMd5sums -hi def link pbMd5Quotes Keyword -hi def link pbMd5Hash Error -hi def link pbValidMd5sums Number - -" sha1sums -syn keyword pb_k_sha1sums sha1sums contained -syn match pbIllegalSha1sums /[^='"()\/ ]/ contained contains=pbValidSha1sums -syn match pbValidSha1sums /\x\{40\}/ contained -syn region pbSha1sumsGroup start=/^sha1sums/ end=/)/ contains=pb_k_sha1sums,pbSha1Quotes,pbSha1Hash,pbIllegalSha1sums keepend -syn match pbSha1Quotes /'.*'\|".*"/ contained contains=pbSha1Hash,pbIllegalSha1sums -syn match pbSha1Hash /\x\+/ contained contains=pbValidSha1sums -hi def link pbSha1Quotes Keyword -hi def link pbSha1Hash Error -hi def link pbValidSha1sums Number - -" options -syn keyword pb_k_options options contained -syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|ccache\|distcc\|makeflags\|force\)/ contained -syn match pbOptionsNeg /\!/ contained -syn match pbOptionsDeprec /no/ contained -syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption,shDoubleQuote,shSingleQuote -syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions - -" noextract -syn match pbNoextract /[[:alnum:]+._${}-]\+/ contained -syn keyword pb_k_noextract noextract contained -syn region pbNoextractGroup start=/^noextract=(/ end=/)/ contains=pb_k_noextract,pbNoextract,shDoubleQuote,shSingleQuote - -" comments -syn keyword pb_k_maintainer Maintainer Contributor contained -syn match pbMaintainerGroup /Maintainer.*/ contains=pbMaintainer contained - -syn match pbDate /[0-9]\{4}\/[0-9]\{2}\/[0-9]\{2}/ contained - -syn cluster pbCommentGroup contains=pbTodo,pb_k_maintainer,pbMaintainerGroup,pbDate -syn keyword pbTodo contained COMBAK FIXME TODO XXX -syn match pbComment "^#.*$" contains=@pbCommentGroup -syn match pbComment "[^0-9]#.*$" contains=@pbCommentGroup - -" quotes are handled by sh.vim - -hi def link pbComment Comment -hi def link pbTodo Todo - -hi def link pbIllegalPkgname Error -hi def link pb_k_pkgname pbKeywords - -hi def link pbIllegalPkgbase Error -hi def link pb_k_pkgbase pbKeywords - -hi def link pbIllegalPkgver Error -hi def link pb_k_pkgver pbKeywords - -hi def link pbIllegalPkgrel Error -hi def link pb_k_pkgrel pbKeywords - -hi def link pbIllegalPkgdesc Error -hi def link pb_k_desc pbKeywords - -hi def link pbIllegalUrl Error -hi def link pb_k_url pbKeywords - -hi def link pb_k_license pbKeywords -hi def link pbIllegalLicense Error - -hi def link pb_k_backup pbKeywords - -hi def link pb_k_arch pbKeywords -hi def link pbIllegalArch Error - -hi def link pb_k_groups pbKeywords -hi def link pb_k_makedepends pbKeywords -hi def link pb_k_optdepends pbKeywords -hi def link pb_k_depends pbKeywords -hi def link pb_k_replaces pbKeywords -hi def link pb_k_conflicts pbKeywords -hi def link pb_k_provides pbKeywords - -hi def link pbIllegalInstall Error -hi def link pb_k_install pbKeywords - -hi def link pbIllegalChangelog Error -hi def link pb_k_changelog pbKeywords - -hi def link pb_k_source pbKeywords -hi def link pbIllegalSource Error - -hi def link pb_k_md5sums pbKeywords -hi def link pbIllegalMd5sums Error - -hi def link pb_k_sha1sums pbKeywords -hi def link pbIllegalSha1sums Error - -hi def link pb_k_options pbKeywords -hi def link pbOptionsDeprec Todo -hi def link pbIllegalOption Error - -hi def link pb_k_noextract pbKeywords -hi def link pbNoextract Normal - -hi def link pb_k_maintainer pbKeywords - -hi def link pbKeywords Keyword - -hi def link pbDate Special - -"syntax include @SHELL syntax/sh.vim -"syntax region BUILD start=/^build()/ end=/^}/ contains=@SHELL -"let b:current_syntax = "PKGBUILD" - -" vim: ft=vim diff --git a/contrib/PKGBUILD.vim.in b/contrib/PKGBUILD.vim.in new file mode 100644 index 00000000..8b40ed7c --- /dev/null +++ b/contrib/PKGBUILD.vim.in @@ -0,0 +1,259 @@ +" Vim syntax file +" Language: PKGBUILD +" Maintainer: Alessio 'mOLOk' Bolognino +" Last Change: 2007/05/08 +" Version Info: PKGBUILD-0.2 (colorphobic) + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +let b:main_syntax = "sh" +runtime! syntax/sh.vim + +" case on +syn case match + +" pkgname +" FIXME if '=' is in pkgname/pkgver, it highlights whole string, not just '=' +syn keyword pb_k_pkgname pkgname contained +syn match pbValidPkgname /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgname +syn match pbIllegalPkgname /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained +syn match pbPkgnameGroup /^pkgname=.*/ contains=pbIllegalPkgname,pb_k_pkgname,shDoubleQuote,shSingleQuote + +" pkgbase +" FIXME if '=' is in pkgbase/pkgname/pkgver, it highlights whole string, not just '=' +syn keyword pb_k_pkgbase pkgbase contained +syn match pbValidPkgbase /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgbase +syn match pbIllegalPkgbase /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained +syn match pbPkgbaseGroup /^pkgbase=.*/ contains=pbIllegalPkgbase,pb_k_pkgbase,shDoubleQuote,shSingleQuote + +" pkgver +syn keyword pb_k_pkgver pkgver contained +syn match pbValidPkgver /\([[:alnum:]]\|\.\|+\|_\)/ contained contains=pbIllegalPkgver +syn match pbIllegalPkgver /[^[:alnum:]+=\.\_]\|=.*=/ contained +syn match pbPkgverGroup /^pkgver=.*/ contains=pbIllegalPkgver,pbValidPkgver,pb_k_pkgver,shDoubleQuote,shSingleQuote + +" pkgrel +syn keyword pb_k_pkgrel pkgrel contained +syn match pbValidPkgrel /[[:digit:]]*/ contained contains=pbIllegalPkgver +syn match pbIllegalPkgrel /[^[:digit:]=]\|=.*=/ contained +syn match pbPkgrelGroup /^pkgrel=.*/ contains=pbIllegalPkgrel,pbValidPkgrel,pb_k_pkgrel,shDoubleQuote,shSingleQuote + +" pkgdesc +syn keyword pb_k_desc pkgdesc contained +" 90 chars: 80 for description, 8 for pkgdesc and 2 for '' +syn match pbIllegalPkgdesc /.\{90,}\|=['"]\?.*['" ]\+[iI][sS] [aA]/ contained contains=pbPkgdescSign +syn match pbValidPkgdesc /[^='"]\.\{,80}/ contained contains=pbIllegalPkgdesc +syn match pbPkgdescGroup /^pkgdesc=.*/ contains=pbIllegalPkgdesc,pb_k_desc,pbValidPkgdesc,shDoubleQuote,shSingleQuote +syn match pbPkgdescSign /[='"]/ contained + +" url +syn keyword pb_k_url url contained +syn match pbValidUrl /['"]*\(https\|http\|ftp\)\:\/.*\.\+.*/ contained + +syn match pbIllegalUrl /[^=]/ contained contains=pbValidUrl +syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubleQuote,shSingleQuote + +" license +syn keyword pb_k_license license contained +syn keyword pbLicense APACHE CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PHP PSF PerlArtistic RALINK RUBY ZPL contained +syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained +syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicense +syn region pbLicenseGroup start=/^license=(/ end=/)/ contains=pb_k_license,pbLicenseCustom,pbLicense,pbIllegalLicense + +" backup +syn keyword pb_k_backup backup contained +syn match pbValidBackup /\.\?[[:alpha:]]*\/[[:alnum:]\{\}+._$-]*]*/ contained +syn region pbBackupGroup start=/^backup=(/ end=/)/ contains=pb_k_backup,pbValidBackup,shDoubleQuote,shSingleQuote + +" arch +syn keyword pb_k_arch arch contained +syn keyword pbArch i686 x86_64 ppc any contained +syn match pbIllegalArch /[^='"() ]/ contained contains=pbArch +syn region pbArchGroup start=/^arch=(/ end=/)/ contains=pb_k_arch,pbArch,pbIllegalArch + +" groups +syn keyword pb_k_groups groups contained +syn match pbValidGroups /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbGroupsGroup start=/^groups=(/ end=/)/ contains=pb_k_groups,pbValidGroups,shDoubleQuote,shSingleQuote + +" depends +syn keyword pb_k_depends depends contained +syn match pbValidDepends /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbDependsGroup start=/^depends=(/ end=/)/ contains=pb_k_depends,pbValidDepends,shDoubleQuote,shSingleQuote + +" makedepends +syn keyword pb_k_makedepends makedepends contained +syn match pbValidMakedepends /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbMakedependsGroup start=/^makedepends=(/ end=/)/ contains=pb_k_makedepends,pbValidMakedepends,shDoubleQuote,shSingleQuote + +" optdepends +syn keyword pb_k_optdepends optdepends contained +syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote + +" conflicts +syn keyword pb_k_conflicts conflicts contained +syn match pbValidConflicts /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbConflictsGroup start=/^conflicts=(/ end=/)/ contains=pb_k_conflicts,pbValidConflicts,shDoubleQuote,shSingleQuote + +" provides +syn keyword pb_k_provides provides contained +syn match pbValidProvides /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbProvidesGroup start=/^provides=(/ end=/)/ contains=pb_k_provides,pbValidProvides,shDoubleQuote,shSingleQuote + +" replaces +syn keyword pb_k_replaces replaces contained +syn match pbValidReplaces /\([[:alnum:]]\|+\|-\|_\)*/ contained +syn region pbReplacesGroup start=/^replaces=(/ end=/)/ contains=pb_k_replaces,pbValidReplaces,shDoubleQuote,shSingleQuote + +" install +" XXX remove install from bashStatement, fix strange bug +syn clear bashStatement +syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch + +syn keyword pb_k_install install contained +syn match pbValidInstall /\([[:alnum:]]\|\$\|+\|-\|_\)*\.install/ contained +syn match pbIllegalInstall /[^=]/ contained contains=pbValidInstall +syn match pbInstallGroup /^install=.*/ contains=pb_k_install,pbValidInstall,pbIllegalInstall,shDeref,shDoubleQuote,shSingleQuote + +" changelog +syn keyword pb_k_changelog changelog contained +syn match pbValidChangelog /\([[:alnum:]]\|\$\|+\|-\|_\)*/ contained +syn match pbIllegalChangelog /[^=]/ contained contains=pbValidChangelog +syn match pbChangelogGroup /^changelog=.*/ contains=pb_k_changelog,pbValidChangelog,pbIllegalChangelog,shDeref,shDoubleQuote,shSingleQuote + +" source: +" XXX remove source from shStatement, fix strange bug +syn clear shStatement +syn keyword shStatement xxx wait getopts return autoload whence printf true popd nohup enable r trap readonly fc fg kill ulimit umask disown stop pushd read history logout times local exit test pwd time eval integer suspend dirs shopt hash false newgrp bg print jobs continue functions exec help cd break unalias chdir type shift builtin let bind + +syn keyword pb_k_source source contained +syn match pbIllegalSource /\(http\|ftp\|https\).*\.\+\(dl\|download.\?\)\.\(sourceforge\|sf\).net/ +syn region pbSourceGroup start=/^source=(/ end=/)/ contains=pb_k_source,pbIllegalSource,shNumber,shDoubleQuote,shSingleQuote,pbDerefEmulation +syn match pbDerefEmulation /\$[{]\?[[:alnum:]_]*[}]\?/ contained +hi def link pbDerefEmulation PreProc + +" md5sums +syn keyword pb_k_md5sums md5sums contained +syn match pbIllegalMd5sums /[^='"()\/ ]/ contained contains=pbValidMd5sums +syn match pbValidMd5sums /\x\{32\}/ contained +syn region pbMd5sumsGroup start=/^md5sums/ end=/)/ contains=pb_k_md5sums,pbMd5Quotes,pbMd5Hash,pbIllegalMd5sums keepend +syn match pbMd5Quotes /'.*'\|".*"/ contained contains=pbMd5Hash,pbIllegalMd5sums +syn match pbMd5Hash /\x\+/ contained contains=pbValidMd5sums +hi def link pbMd5Quotes Keyword +hi def link pbMd5Hash Error +hi def link pbValidMd5sums Number + +" sha1sums +syn keyword pb_k_sha1sums sha1sums contained +syn match pbIllegalSha1sums /[^='"()\/ ]/ contained contains=pbValidSha1sums +syn match pbValidSha1sums /\x\{40\}/ contained +syn region pbSha1sumsGroup start=/^sha1sums/ end=/)/ contains=pb_k_sha1sums,pbSha1Quotes,pbSha1Hash,pbIllegalSha1sums keepend +syn match pbSha1Quotes /'.*'\|".*"/ contained contains=pbSha1Hash,pbIllegalSha1sums +syn match pbSha1Hash /\x\+/ contained contains=pbValidSha1sums +hi def link pbSha1Quotes Keyword +hi def link pbSha1Hash Error +hi def link pbValidSha1sums Number + +" options +syn keyword pb_k_options options contained +syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|ccache\|distcc\|makeflags\|force\)/ contained +syn match pbOptionsNeg /\!/ contained +syn match pbOptionsDeprec /no/ contained +syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption,shDoubleQuote,shSingleQuote +syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions + +" noextract +syn match pbNoextract /[[:alnum:]+._${}-]\+/ contained +syn keyword pb_k_noextract noextract contained +syn region pbNoextractGroup start=/^noextract=(/ end=/)/ contains=pb_k_noextract,pbNoextract,shDoubleQuote,shSingleQuote + +" comments +syn keyword pb_k_maintainer Maintainer Contributor contained +syn match pbMaintainerGroup /Maintainer.*/ contains=pbMaintainer contained + +syn match pbDate /[0-9]\{4}\/[0-9]\{2}\/[0-9]\{2}/ contained + +syn cluster pbCommentGroup contains=pbTodo,pb_k_maintainer,pbMaintainerGroup,pbDate +syn keyword pbTodo contained COMBAK FIXME TODO XXX +syn match pbComment "^#.*$" contains=@pbCommentGroup +syn match pbComment "[^0-9]#.*$" contains=@pbCommentGroup + +" quotes are handled by sh.vim + +hi def link pbComment Comment +hi def link pbTodo Todo + +hi def link pbIllegalPkgname Error +hi def link pb_k_pkgname pbKeywords + +hi def link pbIllegalPkgbase Error +hi def link pb_k_pkgbase pbKeywords + +hi def link pbIllegalPkgver Error +hi def link pb_k_pkgver pbKeywords + +hi def link pbIllegalPkgrel Error +hi def link pb_k_pkgrel pbKeywords + +hi def link pbIllegalPkgdesc Error +hi def link pb_k_desc pbKeywords + +hi def link pbIllegalUrl Error +hi def link pb_k_url pbKeywords + +hi def link pb_k_license pbKeywords +hi def link pbIllegalLicense Error + +hi def link pb_k_backup pbKeywords + +hi def link pb_k_arch pbKeywords +hi def link pbIllegalArch Error + +hi def link pb_k_groups pbKeywords +hi def link pb_k_makedepends pbKeywords +hi def link pb_k_optdepends pbKeywords +hi def link pb_k_depends pbKeywords +hi def link pb_k_replaces pbKeywords +hi def link pb_k_conflicts pbKeywords +hi def link pb_k_provides pbKeywords + +hi def link pbIllegalInstall Error +hi def link pb_k_install pbKeywords + +hi def link pbIllegalChangelog Error +hi def link pb_k_changelog pbKeywords + +hi def link pb_k_source pbKeywords +hi def link pbIllegalSource Error + +hi def link pb_k_md5sums pbKeywords +hi def link pbIllegalMd5sums Error + +hi def link pb_k_sha1sums pbKeywords +hi def link pbIllegalSha1sums Error + +hi def link pb_k_options pbKeywords +hi def link pbOptionsDeprec Todo +hi def link pbIllegalOption Error + +hi def link pb_k_noextract pbKeywords +hi def link pbNoextract Normal + +hi def link pb_k_maintainer pbKeywords + +hi def link pbKeywords Keyword + +hi def link pbDate Special + +"syntax include @SHELL syntax/sh.vim +"syntax region BUILD start=/^build()/ end=/^}/ contains=@SHELL +"let b:current_syntax = "PKGBUILD" + +" vim: ft=vim diff --git a/contrib/bacman b/contrib/bacman deleted file mode 100755 index 6dd78394..00000000 --- a/contrib/bacman +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/bash -# -# bacman: recreate a package from a running system -# This script rebuilds an already installed package using metadata -# stored into the pacman database and system files -# -# (c) 2008 - locci -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -readonly progname="bacman" -readonly progver="0.2.1" - -# -# User Friendliness -# -function usage(){ - echo "This program recreates a package using pacman's db and system files" - echo "Usage: $progname " - echo "Example: $progname kernel26" -} - -if [ $# -ne 1 ] ; then - usage - exit 1 -fi - -if [ "$1" = "--help" -o "$1" = "-h" ] ; then - usage - exit 0 -fi - -if [ "$1" = "--version" -o "$1" = "-v" ]; then - echo "$progname version $progver" - echo "Copyright (C) 2008 locci" - exit 0 -fi - -# -# Fakeroot support -# -if [ $EUID -gt 0 ]; then - if [ -f /usr/bin/fakeroot ]; then - echo "Entering fakeroot environment" - export INFAKEROOT="1" - /usr/bin/fakeroot -u -- $0 $1 - exit $? - else - echo "WARNING: installing fakeroot or running ${progname} as root is required to" - echo " preserve the ownership permissions of files in some packages" - echo "" - fi -fi - -# -# Setting environmental variables -# -if [ ! -r /etc/pacman.conf ]; then - echo "ERROR: unable to read /etc/pacman.conf" - exit 1 -fi - -eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) -pac_db="${DBPath:-/var/lib/pacman/}/local" - -if [ ! -r /etc/makepkg.conf ]; then - echo "ERROR: unable to read /etc/makepkg.conf" - exit 1 -fi - -source "/etc/makepkg.conf" -if [ -r ~/.makepkg.conf ]; then - source ~/.makepkg.conf -fi - -pkg_arch=${CARCH:-'unknown'} -pkg_dest="${PKGDEST:-$PWD}" -pkg_pkger=${PACKAGER:-'Unknown Packager'} - -pkg_name="$1" -pkg_dir="$(echo $pac_db/$pkg_name-[0-9]*)" -pkg_namver="${pkg_dir##*/}" - -# -# Checks everything is in place -# -if [ ! -d "$pac_db" ] ; then - echo "ERROR: pacman database directory ${pac_db} not found" - exit 1 -fi - -if [ ! -d "$pkg_dir" ] ; then - echo "ERROR: package ${pkg_name} not found in pacman database" - exit 1 -fi - -# -# Begin -# -echo Package: ${pkg_namver} -work_dir=$(mktemp -d -p /tmp) -cd "$work_dir" || exit 1 - -# -# File copying -# -echo "Copying package files..." - -cat "$pkg_dir"/files | -while read i; do - if [ -z "$i" ] ; then - continue - fi - - if [[ "$i" =~ %[A-Z]*% ]] ; then - current=$i - continue - fi - - case $current in - %FILES%) - ret=0 - if [ -e "/$i" ]; then - bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf - - - # Workaround to bsdtar not reporting a missing file as an error - if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then - echo "" - echo "ERROR: unable to add /$i to the package" - echo " If your user does not have permssion to read this file then" - echo " you will need to run $progname as root" - rm -rf "$work_dir" - exit 1 - fi - else - echo "" - echo "WARNING: package file /$i is missing" - echo "" - fi - - - ;; - esac -done - -ret=$? -if [ $ret -ne 0 ]; then - rm -rf "$work_dir" - exit 1 -fi - -pkg_size=$(du -sk | awk '{print $1 * 1024}') - -# -# .PKGINFO stuff -# -echo Generating .PKGINFO metadata... -echo "# Generated by $progname $progver" > .PKGINFO -if [ "$INFAKEROOT" = "1" ]; then - echo "# Using $(fakeroot -v)" >> .PKGINFO -fi -echo "# $(LC_ALL=C date)" >> .PKGINFO -echo "#" >> .PKGINFO - -cat "$pkg_dir"/{desc,files,depends} | -while read i; do - if [[ -z "$i" ]]; then - continue; - fi - - if [[ "$i" =~ %[A-Z]*% ]] ; then - current=$i - continue - fi - - case "$current" in - # desc - %NAME%) - echo "pkgname = $i" >> .PKGINFO - ;; - %VERSION%) - echo "pkgver = $i" >> .PKGINFO - ;; - %DESC%) - echo "pkgdesc = $i" >> .PKGINFO - ;; - %URL%) - echo "url = $i" >> .PKGINFO - ;; - %LICENSE%) - echo "license = $i" >> .PKGINFO - ;; - %ARCH%) - echo "arch = $i" >> .PKGINFO - ;; - %BUILDDATE%) - echo "builddate = $(date -u "+%s")" >> .PKGINFO - ;; - %PACKAGER%) - echo "packager = $pkg_pkger" >> .PKGINFO - ;; - %SIZE%) - echo "size = $pkg_size" >> .PKGINFO - ;; - %GROUPS%) - echo "group = $i" >> .PKGINFO - ;; - %REPLACES%) - echo "replaces = $i" >> .PKGINFO - ;; - %FORCE%) - echo "force = true" >> .PKGINFO - ;; - - # files - %BACKUP%) - # strip the md5sum after the tab - echo "backup = ${i%%$'\t'*}" >> .PKGINFO - ;; - - # depends - %DEPENDS%) - echo "depend = $i" >> .PKGINFO - ;; - %OPTDEPENDS%) - echo "optdepend = $i" >> .PKGINFO - ;; - %CONFLICTS%) - echo "conflict = $i" >> .PKGINFO - ;; - %PROVIDES%) - echo "provides = $i" >> .PKGINFO - ;; - esac -done - -comp_files=".PKGINFO" - -if [ -f "$pkg_dir/install" ] ; then - cp "$pkg_dir/install" "$work_dir/.INSTALL" - comp_files+=" .INSTALL" -fi -if [ -f $pkg_dir/changelog ] ; then - cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG" - comp_files+=" .CHANGELOG" -fi - -# -# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL -# -chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null -chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null - -# -# Generate the package -# -echo "Generating the package..." - -case "$PKGEXT" in - *tar.gz) EXT=${PKGEXT%.gz} ;; - *tar.bz2) EXT=${PKGEXT%.bz2} ;; - *tar.xz) EXT=${PKGEXT%.xz} ;; - *tar) EXT=${PKGEXT} ;; - *) echo "WARNING: '%s' is not a valid archive extension." \ - "$PKGEXT" ; EXT=$PKGEXT ;; -esac - -pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}" -ret=0 - -# when fileglobbing, we want * in an empty directory to expand to -# the null string rather than itself -shopt -s nullglob -# TODO: Maybe this can be set globally for robustness -shopt -s -o pipefail -bsdtar -cf - $comp_files * | -case "$PKGEXT" in - *tar.gz) gzip -c -f -n ;; - *tar.bz2) bzip2 -c -f ;; - *tar.xz) xz -c -z - ;; - *tar) cat ;; -esac > ${pkg_file} || ret=$? - -if [ $ret -ne 0 ]; then - echo "ERROR: unable to write package to $pkg_dest" - echo " Maybe the disk is full or you do not have write access" - rm -rf "$work_dir" - exit 1 -fi - -rm -rf "$work_dir" - -echo Done - -exit 0 - -# vim: set ts=2 sw=2 noet: - diff --git a/contrib/bacman.in b/contrib/bacman.in new file mode 100755 index 00000000..6dd78394 --- /dev/null +++ b/contrib/bacman.in @@ -0,0 +1,310 @@ +#!/bin/bash +# +# bacman: recreate a package from a running system +# This script rebuilds an already installed package using metadata +# stored into the pacman database and system files +# +# (c) 2008 - locci +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +readonly progname="bacman" +readonly progver="0.2.1" + +# +# User Friendliness +# +function usage(){ + echo "This program recreates a package using pacman's db and system files" + echo "Usage: $progname " + echo "Example: $progname kernel26" +} + +if [ $# -ne 1 ] ; then + usage + exit 1 +fi + +if [ "$1" = "--help" -o "$1" = "-h" ] ; then + usage + exit 0 +fi + +if [ "$1" = "--version" -o "$1" = "-v" ]; then + echo "$progname version $progver" + echo "Copyright (C) 2008 locci" + exit 0 +fi + +# +# Fakeroot support +# +if [ $EUID -gt 0 ]; then + if [ -f /usr/bin/fakeroot ]; then + echo "Entering fakeroot environment" + export INFAKEROOT="1" + /usr/bin/fakeroot -u -- $0 $1 + exit $? + else + echo "WARNING: installing fakeroot or running ${progname} as root is required to" + echo " preserve the ownership permissions of files in some packages" + echo "" + fi +fi + +# +# Setting environmental variables +# +if [ ! -r /etc/pacman.conf ]; then + echo "ERROR: unable to read /etc/pacman.conf" + exit 1 +fi + +eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) +pac_db="${DBPath:-/var/lib/pacman/}/local" + +if [ ! -r /etc/makepkg.conf ]; then + echo "ERROR: unable to read /etc/makepkg.conf" + exit 1 +fi + +source "/etc/makepkg.conf" +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + +pkg_arch=${CARCH:-'unknown'} +pkg_dest="${PKGDEST:-$PWD}" +pkg_pkger=${PACKAGER:-'Unknown Packager'} + +pkg_name="$1" +pkg_dir="$(echo $pac_db/$pkg_name-[0-9]*)" +pkg_namver="${pkg_dir##*/}" + +# +# Checks everything is in place +# +if [ ! -d "$pac_db" ] ; then + echo "ERROR: pacman database directory ${pac_db} not found" + exit 1 +fi + +if [ ! -d "$pkg_dir" ] ; then + echo "ERROR: package ${pkg_name} not found in pacman database" + exit 1 +fi + +# +# Begin +# +echo Package: ${pkg_namver} +work_dir=$(mktemp -d -p /tmp) +cd "$work_dir" || exit 1 + +# +# File copying +# +echo "Copying package files..." + +cat "$pkg_dir"/files | +while read i; do + if [ -z "$i" ] ; then + continue + fi + + if [[ "$i" =~ %[A-Z]*% ]] ; then + current=$i + continue + fi + + case $current in + %FILES%) + ret=0 + if [ -e "/$i" ]; then + bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf - + + # Workaround to bsdtar not reporting a missing file as an error + if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then + echo "" + echo "ERROR: unable to add /$i to the package" + echo " If your user does not have permssion to read this file then" + echo " you will need to run $progname as root" + rm -rf "$work_dir" + exit 1 + fi + else + echo "" + echo "WARNING: package file /$i is missing" + echo "" + fi + + + ;; + esac +done + +ret=$? +if [ $ret -ne 0 ]; then + rm -rf "$work_dir" + exit 1 +fi + +pkg_size=$(du -sk | awk '{print $1 * 1024}') + +# +# .PKGINFO stuff +# +echo Generating .PKGINFO metadata... +echo "# Generated by $progname $progver" > .PKGINFO +if [ "$INFAKEROOT" = "1" ]; then + echo "# Using $(fakeroot -v)" >> .PKGINFO +fi +echo "# $(LC_ALL=C date)" >> .PKGINFO +echo "#" >> .PKGINFO + +cat "$pkg_dir"/{desc,files,depends} | +while read i; do + if [[ -z "$i" ]]; then + continue; + fi + + if [[ "$i" =~ %[A-Z]*% ]] ; then + current=$i + continue + fi + + case "$current" in + # desc + %NAME%) + echo "pkgname = $i" >> .PKGINFO + ;; + %VERSION%) + echo "pkgver = $i" >> .PKGINFO + ;; + %DESC%) + echo "pkgdesc = $i" >> .PKGINFO + ;; + %URL%) + echo "url = $i" >> .PKGINFO + ;; + %LICENSE%) + echo "license = $i" >> .PKGINFO + ;; + %ARCH%) + echo "arch = $i" >> .PKGINFO + ;; + %BUILDDATE%) + echo "builddate = $(date -u "+%s")" >> .PKGINFO + ;; + %PACKAGER%) + echo "packager = $pkg_pkger" >> .PKGINFO + ;; + %SIZE%) + echo "size = $pkg_size" >> .PKGINFO + ;; + %GROUPS%) + echo "group = $i" >> .PKGINFO + ;; + %REPLACES%) + echo "replaces = $i" >> .PKGINFO + ;; + %FORCE%) + echo "force = true" >> .PKGINFO + ;; + + # files + %BACKUP%) + # strip the md5sum after the tab + echo "backup = ${i%%$'\t'*}" >> .PKGINFO + ;; + + # depends + %DEPENDS%) + echo "depend = $i" >> .PKGINFO + ;; + %OPTDEPENDS%) + echo "optdepend = $i" >> .PKGINFO + ;; + %CONFLICTS%) + echo "conflict = $i" >> .PKGINFO + ;; + %PROVIDES%) + echo "provides = $i" >> .PKGINFO + ;; + esac +done + +comp_files=".PKGINFO" + +if [ -f "$pkg_dir/install" ] ; then + cp "$pkg_dir/install" "$work_dir/.INSTALL" + comp_files+=" .INSTALL" +fi +if [ -f $pkg_dir/changelog ] ; then + cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG" + comp_files+=" .CHANGELOG" +fi + +# +# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL +# +chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null +chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null + +# +# Generate the package +# +echo "Generating the package..." + +case "$PKGEXT" in + *tar.gz) EXT=${PKGEXT%.gz} ;; + *tar.bz2) EXT=${PKGEXT%.bz2} ;; + *tar.xz) EXT=${PKGEXT%.xz} ;; + *tar) EXT=${PKGEXT} ;; + *) echo "WARNING: '%s' is not a valid archive extension." \ + "$PKGEXT" ; EXT=$PKGEXT ;; +esac + +pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}" +ret=0 + +# when fileglobbing, we want * in an empty directory to expand to +# the null string rather than itself +shopt -s nullglob +# TODO: Maybe this can be set globally for robustness +shopt -s -o pipefail +bsdtar -cf - $comp_files * | +case "$PKGEXT" in + *tar.gz) gzip -c -f -n ;; + *tar.bz2) bzip2 -c -f ;; + *tar.xz) xz -c -z - ;; + *tar) cat ;; +esac > ${pkg_file} || ret=$? + +if [ $ret -ne 0 ]; then + echo "ERROR: unable to write package to $pkg_dest" + echo " Maybe the disk is full or you do not have write access" + rm -rf "$work_dir" + exit 1 +fi + +rm -rf "$work_dir" + +echo Done + +exit 0 + +# vim: set ts=2 sw=2 noet: + diff --git a/contrib/bash_completion b/contrib/bash_completion deleted file mode 100644 index bdc4754a..00000000 --- a/contrib/bash_completion +++ /dev/null @@ -1,115 +0,0 @@ -# This file is in the public domain. - -_arch_compgen() { - local i r - COMPREPLY=($(compgen -W '$*' -- "$cur")) - for ((i=1; i < ${#COMP_WORDS[@]}-1; i++)); do - for r in ${!COMPREPLY[@]}; do - if [[ ${COMP_WORDS[i]} = ${COMPREPLY[r]} ]]; then - unset 'COMPREPLY[r]'; break - fi - done - done -} - -_arch_ptr2comp() { - local list= x y - for x; do - for y in '0 --' '1 -'; do - eval 'set -- ${'$x'[${y% *}]}' - list+=\ ${@/#/${y#* }} - done - done - _arch_compgen $list -} - -_arch_incomp() { - local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]] -} - -_makepkg() { - local cur opts prev - COMPREPLY=() - cur=$(_get_cword) - prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur = -* && ! $prev =~ ^-(-(cleancache|config|help)$|\w*[Chp]) ]]; then - opts=('allsource asroot clean cleancache config force geninteg help holdver - ignorearch install log nobuild nocolor noconfirm nodeps noextract - noprogressbar pkg repackage rmdeps skipinteg source syncdeps' - 'A C L R c d e f g h i m o p r s') - _arch_ptr2comp opts - fi - true -} - -_pacman_pkg() { - _arch_compgen "$( - if [[ $2 ]]; then - \pacman -$1 | \cut -d' ' -f1 | \sort -u - else - \pacman -$1 - fi - )" -} - -_pacman() { - local common core cur database prev query remove sync upgrade o - COMPREPLY=() - cur=$(_get_cword) - prev=${COMP_WORDS[COMP_CWORD-1]} - database=('asdeps asexplicit') - query=('changelog check deps explicit file foreign groups info list owns - search unrequired upgrades' 'c e g i k l m o p s t u') - remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c k n p s u') - sync=('asdeps asexplicit clean downloadonly force groups ignore ignoregroup - info list needed nodeps print refresh search sysupgrade' - 'c f g i l p s u w y') - upgrade=('asdeps asexplicit force nodeps print' 'f p') - common=('arch cachedir config dbpath debug help logfile noconfirm - noprogressbar noscriptlet quiet root verbose' 'b d h q r v') - core=('database help query remove sync upgrade version' 'D Q R S U V h') - - for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do - _arch_incomp "$o" && break - done - - if [[ $? != 0 ]]; then - _arch_ptr2comp core - elif [[ ! $prev =~ ^-\w*[Vbhr] && - ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]] - then - [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common || - case ${o% *} in - D|R) - _pacman_pkg Qq;; - Q) - { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } || - { _arch_incomp 'p file' && _pacman_file; } || - _arch_incomp 'o owns' || _arch_incomp 'u upgrades' || - _pacman_pkg Qq;; - S) - { _arch_incomp 'g groups' && _pacman_pkg Sg; } || - { _arch_incomp 'l list' && _pacman_pkg Sl sort; } || - _pacman_pkg Slq;; - U) - _pacman_file;; - esac - fi - true -} - -if [[ $(type -t compopt) = "builtin" ]]; then - _pacman_file() { - compopt -o filenames; _filedir 'pkg.tar.*' - } - complete -F _pacman -o default pacman -else - _pacman_file() { - _filedir 'pkg.tar.*' - } - complete -F _pacman -o filenames -o default pacman -fi - -complete -F _makepkg -o default makepkg - -# ex:et ts=2 sw=2 ft=sh diff --git a/contrib/bash_completion.in b/contrib/bash_completion.in new file mode 100644 index 00000000..bdc4754a --- /dev/null +++ b/contrib/bash_completion.in @@ -0,0 +1,115 @@ +# This file is in the public domain. + +_arch_compgen() { + local i r + COMPREPLY=($(compgen -W '$*' -- "$cur")) + for ((i=1; i < ${#COMP_WORDS[@]}-1; i++)); do + for r in ${!COMPREPLY[@]}; do + if [[ ${COMP_WORDS[i]} = ${COMPREPLY[r]} ]]; then + unset 'COMPREPLY[r]'; break + fi + done + done +} + +_arch_ptr2comp() { + local list= x y + for x; do + for y in '0 --' '1 -'; do + eval 'set -- ${'$x'[${y% *}]}' + list+=\ ${@/#/${y#* }} + done + done + _arch_compgen $list +} + +_arch_incomp() { + local r="\s-(-${1#* }\s|\w*${1% *})"; [[ $COMP_LINE =~ $r ]] +} + +_makepkg() { + local cur opts prev + COMPREPLY=() + cur=$(_get_cword) + prev=${COMP_WORDS[COMP_CWORD-1]} + if [[ $cur = -* && ! $prev =~ ^-(-(cleancache|config|help)$|\w*[Chp]) ]]; then + opts=('allsource asroot clean cleancache config force geninteg help holdver + ignorearch install log nobuild nocolor noconfirm nodeps noextract + noprogressbar pkg repackage rmdeps skipinteg source syncdeps' + 'A C L R c d e f g h i m o p r s') + _arch_ptr2comp opts + fi + true +} + +_pacman_pkg() { + _arch_compgen "$( + if [[ $2 ]]; then + \pacman -$1 | \cut -d' ' -f1 | \sort -u + else + \pacman -$1 + fi + )" +} + +_pacman() { + local common core cur database prev query remove sync upgrade o + COMPREPLY=() + cur=$(_get_cword) + prev=${COMP_WORDS[COMP_CWORD-1]} + database=('asdeps asexplicit') + query=('changelog check deps explicit file foreign groups info list owns + search unrequired upgrades' 'c e g i k l m o p s t u') + remove=('cascade dbonly nodeps nosave print recursive unneeded' 'c k n p s u') + sync=('asdeps asexplicit clean downloadonly force groups ignore ignoregroup + info list needed nodeps print refresh search sysupgrade' + 'c f g i l p s u w y') + upgrade=('asdeps asexplicit force nodeps print' 'f p') + common=('arch cachedir config dbpath debug help logfile noconfirm + noprogressbar noscriptlet quiet root verbose' 'b d h q r v') + core=('database help query remove sync upgrade version' 'D Q R S U V h') + + for o in 'D database' 'Q query' 'R remove' 'S sync' 'U upgrade'; do + _arch_incomp "$o" && break + done + + if [[ $? != 0 ]]; then + _arch_ptr2comp core + elif [[ ! $prev =~ ^-\w*[Vbhr] && + ! $prev = --@(cachedir|config|dbpath|help|logfile|root|version) ]] + then + [[ $cur = -* ]] && _arch_ptr2comp ${o#* } common || + case ${o% *} in + D|R) + _pacman_pkg Qq;; + Q) + { _arch_incomp 'g groups' && _pacman_pkg Qg sort; } || + { _arch_incomp 'p file' && _pacman_file; } || + _arch_incomp 'o owns' || _arch_incomp 'u upgrades' || + _pacman_pkg Qq;; + S) + { _arch_incomp 'g groups' && _pacman_pkg Sg; } || + { _arch_incomp 'l list' && _pacman_pkg Sl sort; } || + _pacman_pkg Slq;; + U) + _pacman_file;; + esac + fi + true +} + +if [[ $(type -t compopt) = "builtin" ]]; then + _pacman_file() { + compopt -o filenames; _filedir 'pkg.tar.*' + } + complete -F _pacman -o default pacman +else + _pacman_file() { + _filedir 'pkg.tar.*' + } + complete -F _pacman -o filenames -o default pacman +fi + +complete -F _makepkg -o default makepkg + +# ex:et ts=2 sw=2 ft=sh diff --git a/contrib/pacdiff b/contrib/pacdiff deleted file mode 100755 index 3f26f381..00000000 --- a/contrib/pacdiff +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# pacdiff : a simple pacnew/pacorig/pacsave updater -# -# Copyright (c) 2007 Aaron Griffin -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -diffprog=${DIFFPROG:-vimdiff} -diffsearchpath=${DIFFSEARCHPATH:-/etc} -locate=0 - -usage() { - echo "pacdiff : a simple pacnew/pacorig/pacsave updater" - echo "Usage : pacdiff [-l]" - echo " -l/--locate makes pacdiff use locate rather than find" - echo " DIFFPROG variable allows to override the default vimdiff" - echo " DIFFSEARCHPATH allows to override the default /etc path" - echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff" -} - -cmd() { - if [ $locate -eq 1 ]; then - locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave - else - find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \) -print0 - fi -} - -if [ $# -gt 0 ]; then - case $1 in - -l|--locate) - locate=1;; - *) - usage; exit 0;; - esac -fi - -# see http://mywiki.wooledge.org/BashFAQ/020 -while IFS= read -u 3 -r -d '' pacfile; do - file="${pacfile%.pac*}" - echo "File: $file" - if [ ! -f "$file" ]; then - echo " $file does not exist" - rm -i "$pacfile" - continue - fi - check="$(cmp "$pacfile" "$file")" - if [ -z "${check}" ]; then - echo " Files are identical, removing..." - rm "$pacfile" - else - echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] " - while read c; do - case $c in - r|R) rm "$pacfile"; break ;; - v|V) - $diffprog "$pacfile" "$file" - rm -i "$pacfile"; break ;; - s|S) break ;; - *) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;; - esac - done - fi -done 3< <(cmd) - -exit 0 - -# vim: set ts=2 sw=2 noet: diff --git a/contrib/pacdiff.in b/contrib/pacdiff.in new file mode 100755 index 00000000..3f26f381 --- /dev/null +++ b/contrib/pacdiff.in @@ -0,0 +1,80 @@ +#!/bin/bash +# pacdiff : a simple pacnew/pacorig/pacsave updater +# +# Copyright (c) 2007 Aaron Griffin +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +diffprog=${DIFFPROG:-vimdiff} +diffsearchpath=${DIFFSEARCHPATH:-/etc} +locate=0 + +usage() { + echo "pacdiff : a simple pacnew/pacorig/pacsave updater" + echo "Usage : pacdiff [-l]" + echo " -l/--locate makes pacdiff use locate rather than find" + echo " DIFFPROG variable allows to override the default vimdiff" + echo " DIFFSEARCHPATH allows to override the default /etc path" + echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff" +} + +cmd() { + if [ $locate -eq 1 ]; then + locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave + else + find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \) -print0 + fi +} + +if [ $# -gt 0 ]; then + case $1 in + -l|--locate) + locate=1;; + *) + usage; exit 0;; + esac +fi + +# see http://mywiki.wooledge.org/BashFAQ/020 +while IFS= read -u 3 -r -d '' pacfile; do + file="${pacfile%.pac*}" + echo "File: $file" + if [ ! -f "$file" ]; then + echo " $file does not exist" + rm -i "$pacfile" + continue + fi + check="$(cmp "$pacfile" "$file")" + if [ -z "${check}" ]; then + echo " Files are identical, removing..." + rm "$pacfile" + else + echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] " + while read c; do + case $c in + r|R) rm "$pacfile"; break ;; + v|V) + $diffprog "$pacfile" "$file" + rm -i "$pacfile"; break ;; + s|S) break ;; + *) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;; + esac + done + fi +done 3< <(cmd) + +exit 0 + +# vim: set ts=2 sw=2 noet: diff --git a/contrib/paclist b/contrib/paclist deleted file mode 100755 index 0379a4c5..00000000 --- a/contrib/paclist +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl -# paclist - List all packages installed from a given repo -# -# Copyright (C) 2008 Dan McGee -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -use warnings; - -my $progname = "paclist"; -my $version = "1.0"; - -if ($#ARGV != 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { - print "$progname - List all packages installed from a given repo\n"; - print "Usage: $progname \n"; - print "Example: $progname testing\n"; - if ($#ARGV != 0) { - exit 1; - } - exit 0; -} - -if ( $ARGV[0] eq "--version" || $ARGV[0] eq "-v") { - print "$progname version $version\n"; - print "Copyright (C) 2008 Dan McGee\n"; - exit 0; -} - -# This hash table will be used to store pairs of ('name version', count) from -# the return of both pacman -Sl and pacman -Q output. We then check to -# see if a value was added twice (count = 2)- if so, we will print that package -# as it is both in the repo we queried and installed on our local system. -my %packages = (); -my $output; - -$output = `pacman -Sl $ARGV[0]`; -if ($? != 0) { - exit 1; -} -my @sync = split(/\n/, $output); -# sample output from pacman -Sl: -# testing foobar 1.0-1 -foreach $_ (@sync) { - my @info = split(/ /); - # we only want to store 'foobar 1.0-1' in our hash table - my $pkg = $info[1] . " " . $info[2]; - $packages{$pkg}++; -} - -$output = `pacman -Q`; -if ($? != 0) { - exit 1; -} -# sample output from pacman -Q: -# foobar 1.0-1 -my @local = split(/\n/, $output); -foreach $_ (@local) { - # store 'foobar 1.0-1' in our hash table - $packages{$_}++; -} - -# run comparison check- if value was added twice, it was in the intersection -my @intersection; -foreach $_ (keys %packages) { - if ($packages{$_} == 2) { - push @{ \@intersection }, $_; - } -} - -# print our intersection, and bask in the glory and speed of perl -@intersection = sort @intersection; -foreach $_ (@intersection) { - print $_ . "\n"; -} - -#vim: set noet: diff --git a/contrib/paclist.in b/contrib/paclist.in new file mode 100755 index 00000000..0379a4c5 --- /dev/null +++ b/contrib/paclist.in @@ -0,0 +1,88 @@ +#!/usr/bin/perl +# paclist - List all packages installed from a given repo +# +# Copyright (C) 2008 Dan McGee +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; + +my $progname = "paclist"; +my $version = "1.0"; + +if ($#ARGV != 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { + print "$progname - List all packages installed from a given repo\n"; + print "Usage: $progname \n"; + print "Example: $progname testing\n"; + if ($#ARGV != 0) { + exit 1; + } + exit 0; +} + +if ( $ARGV[0] eq "--version" || $ARGV[0] eq "-v") { + print "$progname version $version\n"; + print "Copyright (C) 2008 Dan McGee\n"; + exit 0; +} + +# This hash table will be used to store pairs of ('name version', count) from +# the return of both pacman -Sl and pacman -Q output. We then check to +# see if a value was added twice (count = 2)- if so, we will print that package +# as it is both in the repo we queried and installed on our local system. +my %packages = (); +my $output; + +$output = `pacman -Sl $ARGV[0]`; +if ($? != 0) { + exit 1; +} +my @sync = split(/\n/, $output); +# sample output from pacman -Sl: +# testing foobar 1.0-1 +foreach $_ (@sync) { + my @info = split(/ /); + # we only want to store 'foobar 1.0-1' in our hash table + my $pkg = $info[1] . " " . $info[2]; + $packages{$pkg}++; +} + +$output = `pacman -Q`; +if ($? != 0) { + exit 1; +} +# sample output from pacman -Q: +# foobar 1.0-1 +my @local = split(/\n/, $output); +foreach $_ (@local) { + # store 'foobar 1.0-1' in our hash table + $packages{$_}++; +} + +# run comparison check- if value was added twice, it was in the intersection +my @intersection; +foreach $_ (keys %packages) { + if ($packages{$_} == 2) { + push @{ \@intersection }, $_; + } +} + +# print our intersection, and bask in the glory and speed of perl +@intersection = sort @intersection; +foreach $_ (@intersection) { + print $_ . "\n"; +} + +#vim: set noet: diff --git a/contrib/pacscripts b/contrib/pacscripts deleted file mode 100755 index 101fb15f..00000000 --- a/contrib/pacscripts +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash -# -# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade} -# scripts of a given package -# -# Copyright (c) 2009 Giulio "giulivo" Fidente -# Copyright (c) 2009 Xavier Chantry -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -# bash options -set -o nounset -set -o errexit - -progname=$(basename $0) -progver="0.4" - -conf="/etc/pacman.conf" - -if [ ! -r "$conf" ]; then - echo "ERROR: unable to read $conf" - exit 1 -fi - -eval $(awk '/DBPath/ {print $1$2$3}' "$conf") -eval $(awk '/CacheDir/ {print $1$2$3}' "$conf") -pac_db="${DBPath:-/var/lib/pacman}/local" -pac_cache="${CacheDir:-/var/cache/pacman/pkg}" - -error() { - local mesg=$1; shift - printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 -} - -usage() { - echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts" - echo "of a given package." - echo "Usage: $progname pkgname|pkgfile" - echo - echo " OPTIONS:" - echo " -h, --help Print this help message" - echo " -v, --version Print program name and version" - echo - echo "Example: $progname gconf-editor" - echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" -} - -spacman() { - if [ $EUID -eq 0 ]; then - pacman "$@" - else - if [ ! "$(type -p sudo)" ]; then - error "Cannot find the sudo binary! Is sudo installed?" - error "Otherwise try to run the program as root" - exit 1 - else - sudo pacman "$@" - fi - fi -} - -print_db() { - pkg=$(pacman -Q "$1") - pkg=${pkg/ /-} - if [ -f $pac_db/$pkg*/install ]; then - cat $pac_db/$pkg*/install - echo - return 0 - else - error "Package $1 does not include any .INSTALL script" - return 1 - fi -} - -print_pkg() { - if ! bsdtar -xOf "$1" .INSTALL 2>/dev/null; then - error "Package $1 does not include any .INSTALL script" - return 1 - fi - echo -} - -print_scriptlet() { - if [ -f "$1" ]; then - if bsdtar tf "$1" .PKGINFO &>/dev/null; then - print_pkg "$1" - return - fi - fi - if pacman -Q "$1" &>/dev/null; then - print_db "$1" - return - fi - if ! pacman -Si $1 &>/dev/null; then - error "Package $1 not found" - return 1 - fi - url=$(spacman -Sdp $1 | tail -n1) - filename=$(basename $url) - if [ ! -f "$pac_cache/$filename" ]; then - if ! spacman -Sdw --noconfirm $1 >&2; then - error "Failed to download $1" - return 1 - fi - echo >&2 - fi - print_pkg "$pac_cache/$filename" - return -} - -if [ $# -ne 1 ] ; then - usage - exit 1 -fi - -case "$1" in - --help|-h) usage; exit 0 ;; - --version|-v) echo "$progname version $progver"; exit 0 ;; - *) print_scriptlet $1 ;; -esac diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in new file mode 100755 index 00000000..101fb15f --- /dev/null +++ b/contrib/pacscripts.in @@ -0,0 +1,132 @@ +#!/bin/bash +# +# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade} +# scripts of a given package +# +# Copyright (c) 2009 Giulio "giulivo" Fidente +# Copyright (c) 2009 Xavier Chantry +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# bash options +set -o nounset +set -o errexit + +progname=$(basename $0) +progver="0.4" + +conf="/etc/pacman.conf" + +if [ ! -r "$conf" ]; then + echo "ERROR: unable to read $conf" + exit 1 +fi + +eval $(awk '/DBPath/ {print $1$2$3}' "$conf") +eval $(awk '/CacheDir/ {print $1$2$3}' "$conf") +pac_db="${DBPath:-/var/lib/pacman}/local" +pac_cache="${CacheDir:-/var/cache/pacman/pkg}" + +error() { + local mesg=$1; shift + printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 +} + +usage() { + echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts" + echo "of a given package." + echo "Usage: $progname pkgname|pkgfile" + echo + echo " OPTIONS:" + echo " -h, --help Print this help message" + echo " -v, --version Print program name and version" + echo + echo "Example: $progname gconf-editor" + echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" +} + +spacman() { + if [ $EUID -eq 0 ]; then + pacman "$@" + else + if [ ! "$(type -p sudo)" ]; then + error "Cannot find the sudo binary! Is sudo installed?" + error "Otherwise try to run the program as root" + exit 1 + else + sudo pacman "$@" + fi + fi +} + +print_db() { + pkg=$(pacman -Q "$1") + pkg=${pkg/ /-} + if [ -f $pac_db/$pkg*/install ]; then + cat $pac_db/$pkg*/install + echo + return 0 + else + error "Package $1 does not include any .INSTALL script" + return 1 + fi +} + +print_pkg() { + if ! bsdtar -xOf "$1" .INSTALL 2>/dev/null; then + error "Package $1 does not include any .INSTALL script" + return 1 + fi + echo +} + +print_scriptlet() { + if [ -f "$1" ]; then + if bsdtar tf "$1" .PKGINFO &>/dev/null; then + print_pkg "$1" + return + fi + fi + if pacman -Q "$1" &>/dev/null; then + print_db "$1" + return + fi + if ! pacman -Si $1 &>/dev/null; then + error "Package $1 not found" + return 1 + fi + url=$(spacman -Sdp $1 | tail -n1) + filename=$(basename $url) + if [ ! -f "$pac_cache/$filename" ]; then + if ! spacman -Sdw --noconfirm $1 >&2; then + error "Failed to download $1" + return 1 + fi + echo >&2 + fi + print_pkg "$pac_cache/$filename" + return +} + +if [ $# -ne 1 ] ; then + usage + exit 1 +fi + +case "$1" in + --help|-h) usage; exit 0 ;; + --version|-v) echo "$progname version $progver"; exit 0 ;; + *) print_scriptlet $1 ;; +esac diff --git a/contrib/pacsearch b/contrib/pacsearch deleted file mode 100755 index a20df265..00000000 --- a/contrib/pacsearch +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/perl -# pacsearch - Adds color and install information to a 'pacman -Ss' search -# -# Copyright (C) 2008, 2010 Dan McGee -# -# Based off original shell script version: -# Copyright (C) 2006-2007 Dan McGee -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -#TODO: colors flag on commandline - -use strict; -use warnings; - -my $progname = "pacsearch"; -my $version = "2.0"; - -if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { - print "$progname - Add color and install information to a pacman -Ss search\n"; - print "Usage: $progname \n"; - print "Example: $progname ^gnome\n"; - if ($#ARGV lt 0) { - exit 1; - } - exit 0; -} - -if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") { - print "$progname version $version\n"; - print "Copyright (C) 2006-2010 Dan McGee\n"; - exit 0; -} - -# define our colors to use when printing -my $CLR1 = "\e[0;34m"; -my $CLR2 = "\e[0;32m"; -my $CLR3 = "\e[0;35m"; -my $CLR4 = "\e[0;36m"; -my $CLR5 = "\e[0;31m"; -my $CLR6 = "\e[0;33m"; -my $CLR7 = "\e[1;36m"; -my $INST = "\e[1;31m"; -my $BASE = "\e[0m"; - -# color a "repo/pkgname pkgver" line based on the repository name -sub to_color { - my $line = shift; - # get the installed text colored first - $line =~ s/(\[.*\]$)/$INST$1$BASE/; - # and now the repo and dealings - $line =~ s/(^core\/.*)/$CLR1$1$BASE/; - $line =~ s/(^extra\/.*)/$CLR2$1$BASE/; - $line =~ s/(^community\/.*)/$CLR3$1$BASE/; - $line =~ s/(^testing\/.*)/$CLR4$1$BASE/; - $line =~ s/(^community-testing\/.*)/$CLR5$1$BASE/; - $line =~ s/(^local\/.*)/$CLR7$1$BASE/; - # any other unknown repository - $line =~ s/(^[\w-]*\/.*)/$CLR6$1$BASE/; - return $line; -} - -my %allpkgs = (); - -my $syncout = `pacman -Ss '@ARGV'`; -# split each sync search entry into its own array entry -my @syncpkgs = split(/\n^(?=\w)/m, $syncout); -# remove the extra \n from the last desc entry -if ($#syncpkgs >= 0) { - chomp($syncpkgs[$#syncpkgs]); -} - -# counter var for packages, used here and in the query loop too -my $cnt = 0; -foreach $_ (@syncpkgs) { - # we grab 4 fields here: repo, name/ver, installed, and desc - my @pkgfields = /^(.*?)\/(.*?) ?(\[.*\])?\n(.*)$/s; - # since installed is optional, we should fill it in if necessary - $pkgfields[2] = "" if not defined $pkgfields[2]; - # add a fifth field that indicates original order - push (@pkgfields, $cnt++); - # add each sync pkg by name/ver to a hash table for quick lookup - $allpkgs{$pkgfields[1]} = [ @pkgfields ]; -} - -my $queryout = `pacman -Qs '@ARGV'`; -# split each querysearch entry into its own array entry -my @querypkgs = split(/\n^(?=\w)/m, $queryout); -# remove the extra \n from the last desc entry -if ($#querypkgs >= 0) { - chomp ($querypkgs[$#querypkgs]); -} - -foreach $_ (@querypkgs) { - # we grab 4 fields here: repo, name/ver, installed, and desc - my @pkgfields = /^(.*?)\/(.*?) ?(\[.*\])?\n(.*)$/s; - # since installed is optional, we should fill it in if necessary - $pkgfields[2] = "" if not defined $pkgfields[2]; - # check if the package was listed in the sync out - if (not exists $allpkgs{$pkgfields[1]}) { - $pkgfields[2] = "[installed]"; - # add a fifth field that indicates original order (after sync) - push (@pkgfields, $cnt++); - # add our local-only package to the hash - $allpkgs{$pkgfields[1]} = [ @pkgfields ]; - } -} - -# sort by original order (the fifth field) and print -foreach $_ ( sort{ @{$allpkgs{$a}}[4] <=> @{$allpkgs{$b}}[4] } keys %allpkgs) { - my @v = @{$allpkgs{$_}}; - my $line = "$v[0]/$v[1] $v[2]"; - $line = to_color($line); - # print colorized "repo/pkgname pkgver" string with possible installed text - print "$line\n"; - print "$v[3]\n"; -} - -#vim: set noet: diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in new file mode 100755 index 00000000..a20df265 --- /dev/null +++ b/contrib/pacsearch.in @@ -0,0 +1,130 @@ +#!/usr/bin/perl +# pacsearch - Adds color and install information to a 'pacman -Ss' search +# +# Copyright (C) 2008, 2010 Dan McGee +# +# Based off original shell script version: +# Copyright (C) 2006-2007 Dan McGee +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#TODO: colors flag on commandline + +use strict; +use warnings; + +my $progname = "pacsearch"; +my $version = "2.0"; + +if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { + print "$progname - Add color and install information to a pacman -Ss search\n"; + print "Usage: $progname \n"; + print "Example: $progname ^gnome\n"; + if ($#ARGV lt 0) { + exit 1; + } + exit 0; +} + +if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") { + print "$progname version $version\n"; + print "Copyright (C) 2006-2010 Dan McGee\n"; + exit 0; +} + +# define our colors to use when printing +my $CLR1 = "\e[0;34m"; +my $CLR2 = "\e[0;32m"; +my $CLR3 = "\e[0;35m"; +my $CLR4 = "\e[0;36m"; +my $CLR5 = "\e[0;31m"; +my $CLR6 = "\e[0;33m"; +my $CLR7 = "\e[1;36m"; +my $INST = "\e[1;31m"; +my $BASE = "\e[0m"; + +# color a "repo/pkgname pkgver" line based on the repository name +sub to_color { + my $line = shift; + # get the installed text colored first + $line =~ s/(\[.*\]$)/$INST$1$BASE/; + # and now the repo and dealings + $line =~ s/(^core\/.*)/$CLR1$1$BASE/; + $line =~ s/(^extra\/.*)/$CLR2$1$BASE/; + $line =~ s/(^community\/.*)/$CLR3$1$BASE/; + $line =~ s/(^testing\/.*)/$CLR4$1$BASE/; + $line =~ s/(^community-testing\/.*)/$CLR5$1$BASE/; + $line =~ s/(^local\/.*)/$CLR7$1$BASE/; + # any other unknown repository + $line =~ s/(^[\w-]*\/.*)/$CLR6$1$BASE/; + return $line; +} + +my %allpkgs = (); + +my $syncout = `pacman -Ss '@ARGV'`; +# split each sync search entry into its own array entry +my @syncpkgs = split(/\n^(?=\w)/m, $syncout); +# remove the extra \n from the last desc entry +if ($#syncpkgs >= 0) { + chomp($syncpkgs[$#syncpkgs]); +} + +# counter var for packages, used here and in the query loop too +my $cnt = 0; +foreach $_ (@syncpkgs) { + # we grab 4 fields here: repo, name/ver, installed, and desc + my @pkgfields = /^(.*?)\/(.*?) ?(\[.*\])?\n(.*)$/s; + # since installed is optional, we should fill it in if necessary + $pkgfields[2] = "" if not defined $pkgfields[2]; + # add a fifth field that indicates original order + push (@pkgfields, $cnt++); + # add each sync pkg by name/ver to a hash table for quick lookup + $allpkgs{$pkgfields[1]} = [ @pkgfields ]; +} + +my $queryout = `pacman -Qs '@ARGV'`; +# split each querysearch entry into its own array entry +my @querypkgs = split(/\n^(?=\w)/m, $queryout); +# remove the extra \n from the last desc entry +if ($#querypkgs >= 0) { + chomp ($querypkgs[$#querypkgs]); +} + +foreach $_ (@querypkgs) { + # we grab 4 fields here: repo, name/ver, installed, and desc + my @pkgfields = /^(.*?)\/(.*?) ?(\[.*\])?\n(.*)$/s; + # since installed is optional, we should fill it in if necessary + $pkgfields[2] = "" if not defined $pkgfields[2]; + # check if the package was listed in the sync out + if (not exists $allpkgs{$pkgfields[1]}) { + $pkgfields[2] = "[installed]"; + # add a fifth field that indicates original order (after sync) + push (@pkgfields, $cnt++); + # add our local-only package to the hash + $allpkgs{$pkgfields[1]} = [ @pkgfields ]; + } +} + +# sort by original order (the fifth field) and print +foreach $_ ( sort{ @{$allpkgs{$a}}[4] <=> @{$allpkgs{$b}}[4] } keys %allpkgs) { + my @v = @{$allpkgs{$_}}; + my $line = "$v[0]/$v[1] $v[2]"; + $line = to_color($line); + # print colorized "repo/pkgname pkgver" string with possible installed text + print "$line\n"; + print "$v[3]\n"; +} + +#vim: set noet: diff --git a/contrib/pactree b/contrib/pactree deleted file mode 100755 index 6051724e..00000000 --- a/contrib/pactree +++ /dev/null @@ -1,322 +0,0 @@ -#!/bin/bash -# pactree : a simple dependency tree viewer -# -# Copyright (C) 2008 Carlo "carlocci" Bersani -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Original http://carlocci.ngi.it/arch/pactree -# Credit to scj for the graphviz idea - -# set the colors -branch1_color="\033[0;33m" #Brown -branch2_color="\033[0;37m" #Gray -leaf_color="\033[1;32m" #Light green -leaf2_color="\033[0;32m" #Green - -# set the separators -separator=" " -branch_tip1="|--" -branch_tip2="+--" -provides="provides " - -# set the graphviz options -# http://www.graphviz.org/doc/info/output.html for available output formats -# http://www.graphviz.org/doc/info/colors.html for available colors -gformat="png" #output format -start_color="red" #START color -nodes_color="green" #color of the nodes -arrow1_color="chocolate4" #color of the normal arrow -arrow2_color="grey" #color of the "provided by" headless arrow - -readonly prog_name="pactree" -readonly prog_ver="0.3" - -_usage(){ - echo "This program generates the dependency tree of an installed package" - echo "Usage: $prog_name [OPTIONS] " - echo - echo " OPTIONS:" - echo " -c, --color Enable color output" - echo " -d, --depth INT Limit the shown dependencies depth" - echo " -g, --graph Use graphviz to make an image of the tree" - echo " -l, --linear Enable linear output" - echo " -r, --reversed Show reversed dependancies" - echo " -s, --silent Shh, let me hear those errors!" - echo " -u, --unique Print the dependency list with no duplicates" - echo - echo " -h, --help Print this help message" - echo " -v, --version Print the program name and version" - echo - echo "Example: $prog_name -c -d2 readline" -} - -_version(){ - echo "$prog_name version $prog_ver" - echo "Copyright (C) 2008 Carlo \"carlocci\" Bersani " -} -# end of the friendliness - - -# grab a field from the database: $1=path/to/file, $2=field to grab -_grabfield(){ - for line in $(cat "$1" 2>/dev/null ); do - if [ -z "$line" ]; then - continue; - fi; - if [[ "$line" =~ %[A-Z]*% ]]; then - current="$line" - continue; - fi; - if [ "$current" = "$2" ]; then - echo "$line" - fi; - done -} - - -# find a dep in the db: $1=dep, $2=field, $3=dbfile, ret=file list -_finddep(){ - for line in $(awk 'BEGIN{RS=""} - { - if ($1=="'"$2"'"){ - for (i=2 ; i<=NF ; ++i){ - if ($i ~ /^'"$1"'([<>=]+.*|)$/ ){ - print FILENAME} - } - } - }' $(find $pac_db -name $3)); do - echo "${line%/*}" - done -} - - -# Recursive function: does all of the work, pays all of the taxes # -_tree(){ - pkg_name="$1" - pkg_dirs="$(echo $pac_db/$pkg_name-[0-9]*)" - - # Is $pkg_name real or provided? - [ ! -d "$pkg_dirs" ] && pkg_dirs="$(_finddep $pkg_name %PROVIDES% depends)" - - for pkg_dir in $pkg_dirs ; do - spaces="$2" - unset provided - branch_tip="$branch_tip1" - branch_color="$branch1_color" - pkg_name="$(_grabfield "$pkg_dir/desc" %NAME%)" - if [ ! "$pkg_name" = "$1" ]; then - provided="$leaf2_color $provides$leaf_color$1" - branch_tip="$branch_tip2" - branch_color="$branch2_color" - if [ $graphviz -eq 1 ] && [[ ! "${dep_list[@]}" =~ _$1_ ]] && [ $spaces -ne $((max_depth+1)) ]; then - echo "\"$1\" -> \"$pkg_name\" [arrowhead=none, color=$arrow2_color];" - dep_list=( "${dep_list[@]}" "_$1_" ) - _tree "$pkg_name" $((spaces+1)) - continue - fi - fi - - # Generate the spacer - spacer="" - for ((count = 0; count < spaces; count++)); do - spacer="$spacer$separator" - done - unset count - spacer="$spacer$branch_tip" - - [ $silent -ne 1 ] && echo -e "$branch_color$spacer$leaf_color$pkg_name$provided" - - [ ! -d "$pkg_dir" ] && echo "No $pkg_name in the database (inconsistent database?)" >&2 - - if [[ ! " ${dep_list[@]} " =~ " $pkg_name " ]] && [ $spaces -ne $max_depth ]; then - dep_list=( "${dep_list[@]}" "$pkg_name" ) - if [ $reversed_dep -eq 0 ]; then - deps_pkg="$(_grabfield "$pkg_dir/depends" %DEPENDS%)" - else - reqs_pkg_dir="$(_finddep "$pkg_name" %DEPENDS% depends)" - unset deps_pkg - for req_pkg_dir in $reqs_pkg_dir; do - deps_pkg=$(echo "$deps_pkg" "$(_grabfield "$req_pkg_dir/desc" %NAME%)") - done - fi - for dep_pkg in $deps_pkg; do - spaces=$2 #Bash scoping ;_; - if [ $graphviz -eq 1 ]; then - echo "\"$1\" -> \"${dep_pkg%%[<>=]*}\" [color=$arrow1_color];" - fi - _tree "${dep_pkg%%[<>=]*}" $((spaces+1)) - done - fi - done -} - - -# Main program: gets all of the money, pays none of the taxes - -# Command line parameters parser -if [ $# -eq 0 ]; then - _usage - exit 1 -fi - -options=( "$@" ) -len_options=${#options[@]} -for (( n=0 ; n < $len_options ; n++ )); do - if [ "${options[$n]}" = "--" ]; then - unset options[$n] - break - fi - if [ "${options[$n]}" = "-h" -o "${options[$n]}" = "--help" ]; then - _usage - exit 0 - fi - - if [ "${options[$n]}" = "-v" -o "${options[$n]}" = "--version" ]; then - _version - exit 0 - fi - - if [ "${options[$n]}" = "-l" -o "${options[$n]}" = "--linear" ]; then - unset options[$n] - linear=1 - continue - fi - - if [ "${options[$n]}" = "-s" -o "${options[$n]}" = "--silent" ]; then - unset options[$n] - silent=1 - continue - fi - - if [ "${options[$n]}" = "-u" -o "${options[$n]}" = "--unique" ]; then - unset options[$n] - silent=1 - nodup=1 - continue - fi - - if [ "${options[$n]}" = "-g" -o "${options[$n]}" = "--graph" ]; then - unset options[$n] - graphviz=1 - continue - fi - - if [ "${options[$n]}" = "-c" -o "${options[$n]}" = "--color" ]; then - unset options[$n] - colored=1 - continue - fi - - if [ "${options[$n]}" = "-r" -o "${options[$n]}" = "--reversed" ]; then - unset options[$n] - reversed_dep=1 - continue - fi - - if [[ "${options[$n]}" =~ -d[[:digit:]]+ || "${options[$n]}" == "--depth" ]]; then - if [[ "${options[$n]#-d}" =~ [[:digit:]]+ ]]; then - max_depth="${options[$n]#-d}" - elif [[ ${options[$((n+1))]} =~ [[:digit:]]+ ]]; then - max_depth="${options[$((n+1))]}" - unset options[$((n+1))] - ((++n)) - fi - unset options[$n] - continue - fi -done -# End of the dumb command line parser - -# Env -colored=${colored:-0} -max_depth=${max_depth:--10} -linear=${linear:-0} -silent=${silent:-0} -nodup=${nodup:-0} -graphviz=${graphviz:-0} -reversed_dep=${reversed_dep:-0} - -if [ $colored -ne 1 ]; then - unset branch1_color - unset leaf_color - unset leaf2_color - unset branch2_color -fi - -if [ $linear -eq 1 ]; then - unset separator - unset branch_tip1 - unset branch_tip2 - unset provides -fi - -if [ $graphviz -eq 1 ]; then - silent=1 - nodup=0 - if [ ! -f /usr/bin/dot ]; then - echo "ERROR: package graphviz is not installed" - echo " Run pacman -S graphviz to install it" - exit 1 - fi -fi - -if [ ! -r /etc/pacman.conf ]; then - echo "ERROR: unable to read /etc/pacman.conf" - exit 1 -else - eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) -fi - -pac_db="${DBPath:-/var/lib/pacman}/local" - -if [ ! -d "$pac_db" ] ; then - echo "ERROR: pacman database directory ${pac_db} not found" - exit 1 -fi -# Env End - - -# Program starts -_main(){ - for pkg_name in ${options[@]} ; do - [ $graphviz -eq 1 ] && echo -e "\"START\" -> \"$pkg_name\" ;" - _tree "$pkg_name" 0 - if [ $nodup -eq 1 ]; then - for pkg_tree in ${dep_list[@]} ; do - echo "$pkg_tree" - done - fi - done - if [ $silent -eq 0 ]; then - echo -ne '\033[0m' # return colors to normal? - echo -ne '\033[?25h' #return cursor to normal? - fi -} - - -if [ $graphviz -eq 1 ]; then - root_pkgs="${options[@]}" - # Uncomment for the "generated by pactree" node in graphviz - #advert="xyz [height=0.07, fontsize=8.0, label=\"GENERATED WITH PACTREE\",shape=box,color="black",style=filled,fontcolor="white"];\n" - if [ $reversed_dep -eq 0 ]; then - file_extension="deps.$gformat" - else - file_extension="reqs.$gformat" - fi - echo -e "digraph G { START [color=$start_color, style=filled];\n node [style=filled, color=$nodes_color];\n$(_main)\n$advert}" | dot -T$gformat -o "${root_pkgs// /_}.$file_extension" -else _main -fi - -# vim: set ts=2 sw=2 noet: diff --git a/contrib/pactree.in b/contrib/pactree.in new file mode 100755 index 00000000..6051724e --- /dev/null +++ b/contrib/pactree.in @@ -0,0 +1,322 @@ +#!/bin/bash +# pactree : a simple dependency tree viewer +# +# Copyright (C) 2008 Carlo "carlocci" Bersani +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Original http://carlocci.ngi.it/arch/pactree +# Credit to scj for the graphviz idea + +# set the colors +branch1_color="\033[0;33m" #Brown +branch2_color="\033[0;37m" #Gray +leaf_color="\033[1;32m" #Light green +leaf2_color="\033[0;32m" #Green + +# set the separators +separator=" " +branch_tip1="|--" +branch_tip2="+--" +provides="provides " + +# set the graphviz options +# http://www.graphviz.org/doc/info/output.html for available output formats +# http://www.graphviz.org/doc/info/colors.html for available colors +gformat="png" #output format +start_color="red" #START color +nodes_color="green" #color of the nodes +arrow1_color="chocolate4" #color of the normal arrow +arrow2_color="grey" #color of the "provided by" headless arrow + +readonly prog_name="pactree" +readonly prog_ver="0.3" + +_usage(){ + echo "This program generates the dependency tree of an installed package" + echo "Usage: $prog_name [OPTIONS] " + echo + echo " OPTIONS:" + echo " -c, --color Enable color output" + echo " -d, --depth INT Limit the shown dependencies depth" + echo " -g, --graph Use graphviz to make an image of the tree" + echo " -l, --linear Enable linear output" + echo " -r, --reversed Show reversed dependancies" + echo " -s, --silent Shh, let me hear those errors!" + echo " -u, --unique Print the dependency list with no duplicates" + echo + echo " -h, --help Print this help message" + echo " -v, --version Print the program name and version" + echo + echo "Example: $prog_name -c -d2 readline" +} + +_version(){ + echo "$prog_name version $prog_ver" + echo "Copyright (C) 2008 Carlo \"carlocci\" Bersani " +} +# end of the friendliness + + +# grab a field from the database: $1=path/to/file, $2=field to grab +_grabfield(){ + for line in $(cat "$1" 2>/dev/null ); do + if [ -z "$line" ]; then + continue; + fi; + if [[ "$line" =~ %[A-Z]*% ]]; then + current="$line" + continue; + fi; + if [ "$current" = "$2" ]; then + echo "$line" + fi; + done +} + + +# find a dep in the db: $1=dep, $2=field, $3=dbfile, ret=file list +_finddep(){ + for line in $(awk 'BEGIN{RS=""} + { + if ($1=="'"$2"'"){ + for (i=2 ; i<=NF ; ++i){ + if ($i ~ /^'"$1"'([<>=]+.*|)$/ ){ + print FILENAME} + } + } + }' $(find $pac_db -name $3)); do + echo "${line%/*}" + done +} + + +# Recursive function: does all of the work, pays all of the taxes # +_tree(){ + pkg_name="$1" + pkg_dirs="$(echo $pac_db/$pkg_name-[0-9]*)" + + # Is $pkg_name real or provided? + [ ! -d "$pkg_dirs" ] && pkg_dirs="$(_finddep $pkg_name %PROVIDES% depends)" + + for pkg_dir in $pkg_dirs ; do + spaces="$2" + unset provided + branch_tip="$branch_tip1" + branch_color="$branch1_color" + pkg_name="$(_grabfield "$pkg_dir/desc" %NAME%)" + if [ ! "$pkg_name" = "$1" ]; then + provided="$leaf2_color $provides$leaf_color$1" + branch_tip="$branch_tip2" + branch_color="$branch2_color" + if [ $graphviz -eq 1 ] && [[ ! "${dep_list[@]}" =~ _$1_ ]] && [ $spaces -ne $((max_depth+1)) ]; then + echo "\"$1\" -> \"$pkg_name\" [arrowhead=none, color=$arrow2_color];" + dep_list=( "${dep_list[@]}" "_$1_" ) + _tree "$pkg_name" $((spaces+1)) + continue + fi + fi + + # Generate the spacer + spacer="" + for ((count = 0; count < spaces; count++)); do + spacer="$spacer$separator" + done + unset count + spacer="$spacer$branch_tip" + + [ $silent -ne 1 ] && echo -e "$branch_color$spacer$leaf_color$pkg_name$provided" + + [ ! -d "$pkg_dir" ] && echo "No $pkg_name in the database (inconsistent database?)" >&2 + + if [[ ! " ${dep_list[@]} " =~ " $pkg_name " ]] && [ $spaces -ne $max_depth ]; then + dep_list=( "${dep_list[@]}" "$pkg_name" ) + if [ $reversed_dep -eq 0 ]; then + deps_pkg="$(_grabfield "$pkg_dir/depends" %DEPENDS%)" + else + reqs_pkg_dir="$(_finddep "$pkg_name" %DEPENDS% depends)" + unset deps_pkg + for req_pkg_dir in $reqs_pkg_dir; do + deps_pkg=$(echo "$deps_pkg" "$(_grabfield "$req_pkg_dir/desc" %NAME%)") + done + fi + for dep_pkg in $deps_pkg; do + spaces=$2 #Bash scoping ;_; + if [ $graphviz -eq 1 ]; then + echo "\"$1\" -> \"${dep_pkg%%[<>=]*}\" [color=$arrow1_color];" + fi + _tree "${dep_pkg%%[<>=]*}" $((spaces+1)) + done + fi + done +} + + +# Main program: gets all of the money, pays none of the taxes + +# Command line parameters parser +if [ $# -eq 0 ]; then + _usage + exit 1 +fi + +options=( "$@" ) +len_options=${#options[@]} +for (( n=0 ; n < $len_options ; n++ )); do + if [ "${options[$n]}" = "--" ]; then + unset options[$n] + break + fi + if [ "${options[$n]}" = "-h" -o "${options[$n]}" = "--help" ]; then + _usage + exit 0 + fi + + if [ "${options[$n]}" = "-v" -o "${options[$n]}" = "--version" ]; then + _version + exit 0 + fi + + if [ "${options[$n]}" = "-l" -o "${options[$n]}" = "--linear" ]; then + unset options[$n] + linear=1 + continue + fi + + if [ "${options[$n]}" = "-s" -o "${options[$n]}" = "--silent" ]; then + unset options[$n] + silent=1 + continue + fi + + if [ "${options[$n]}" = "-u" -o "${options[$n]}" = "--unique" ]; then + unset options[$n] + silent=1 + nodup=1 + continue + fi + + if [ "${options[$n]}" = "-g" -o "${options[$n]}" = "--graph" ]; then + unset options[$n] + graphviz=1 + continue + fi + + if [ "${options[$n]}" = "-c" -o "${options[$n]}" = "--color" ]; then + unset options[$n] + colored=1 + continue + fi + + if [ "${options[$n]}" = "-r" -o "${options[$n]}" = "--reversed" ]; then + unset options[$n] + reversed_dep=1 + continue + fi + + if [[ "${options[$n]}" =~ -d[[:digit:]]+ || "${options[$n]}" == "--depth" ]]; then + if [[ "${options[$n]#-d}" =~ [[:digit:]]+ ]]; then + max_depth="${options[$n]#-d}" + elif [[ ${options[$((n+1))]} =~ [[:digit:]]+ ]]; then + max_depth="${options[$((n+1))]}" + unset options[$((n+1))] + ((++n)) + fi + unset options[$n] + continue + fi +done +# End of the dumb command line parser + +# Env +colored=${colored:-0} +max_depth=${max_depth:--10} +linear=${linear:-0} +silent=${silent:-0} +nodup=${nodup:-0} +graphviz=${graphviz:-0} +reversed_dep=${reversed_dep:-0} + +if [ $colored -ne 1 ]; then + unset branch1_color + unset leaf_color + unset leaf2_color + unset branch2_color +fi + +if [ $linear -eq 1 ]; then + unset separator + unset branch_tip1 + unset branch_tip2 + unset provides +fi + +if [ $graphviz -eq 1 ]; then + silent=1 + nodup=0 + if [ ! -f /usr/bin/dot ]; then + echo "ERROR: package graphviz is not installed" + echo " Run pacman -S graphviz to install it" + exit 1 + fi +fi + +if [ ! -r /etc/pacman.conf ]; then + echo "ERROR: unable to read /etc/pacman.conf" + exit 1 +else + eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) +fi + +pac_db="${DBPath:-/var/lib/pacman}/local" + +if [ ! -d "$pac_db" ] ; then + echo "ERROR: pacman database directory ${pac_db} not found" + exit 1 +fi +# Env End + + +# Program starts +_main(){ + for pkg_name in ${options[@]} ; do + [ $graphviz -eq 1 ] && echo -e "\"START\" -> \"$pkg_name\" ;" + _tree "$pkg_name" 0 + if [ $nodup -eq 1 ]; then + for pkg_tree in ${dep_list[@]} ; do + echo "$pkg_tree" + done + fi + done + if [ $silent -eq 0 ]; then + echo -ne '\033[0m' # return colors to normal? + echo -ne '\033[?25h' #return cursor to normal? + fi +} + + +if [ $graphviz -eq 1 ]; then + root_pkgs="${options[@]}" + # Uncomment for the "generated by pactree" node in graphviz + #advert="xyz [height=0.07, fontsize=8.0, label=\"GENERATED WITH PACTREE\",shape=box,color="black",style=filled,fontcolor="white"];\n" + if [ $reversed_dep -eq 0 ]; then + file_extension="deps.$gformat" + else + file_extension="reqs.$gformat" + fi + echo -e "digraph G { START [color=$start_color, style=filled];\n node [style=filled, color=$nodes_color];\n$(_main)\n$advert}" | dot -T$gformat -o "${root_pkgs// /_}.$file_extension" +else _main +fi + +# vim: set ts=2 sw=2 noet: diff --git a/contrib/vimprojects b/contrib/vimprojects deleted file mode 100644 index e9adfdf1..00000000 --- a/contrib/vimprojects +++ /dev/null @@ -1,25 +0,0 @@ -This is a project file -for the vim-project plugin. -Save it as ~/.vimprojects - -$ pacman -S vim-project -change the pacman path below -$ vim -:Project - -Press \r in the project view -on a project name to generate -the list of files - -pacman=~/devel/pacman/ CD=. filter="*.ac *.am" flags=S { - libalpm=lib/libalpm/ filter="*.c *.h *.am" { - } - pacman=src/pacman/ filter="*.c *.h *.am" { - } - scripts=scripts/ filter="*.sh.in *.py.in *.am" { - } - utils=src/util filter="*.c *.h *.am" { - } - contrib=contrib CD=. { - } -} diff --git a/contrib/vimprojects.in b/contrib/vimprojects.in new file mode 100644 index 00000000..e9adfdf1 --- /dev/null +++ b/contrib/vimprojects.in @@ -0,0 +1,25 @@ +This is a project file +for the vim-project plugin. +Save it as ~/.vimprojects + +$ pacman -S vim-project +change the pacman path below +$ vim +:Project + +Press \r in the project view +on a project name to generate +the list of files + +pacman=~/devel/pacman/ CD=. filter="*.ac *.am" flags=S { + libalpm=lib/libalpm/ filter="*.c *.h *.am" { + } + pacman=src/pacman/ filter="*.c *.h *.am" { + } + scripts=scripts/ filter="*.sh.in *.py.in *.am" { + } + utils=src/util filter="*.c *.h *.am" { + } + contrib=contrib CD=. { + } +} diff --git a/contrib/wget-xdelta.sh b/contrib/wget-xdelta.sh deleted file mode 100755 index 4656f4dd..00000000 --- a/contrib/wget-xdelta.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -if [ -r "/etc/makepkg.conf" ]; then - source /etc/makepkg.conf -else - echo "wget-xdelta: Unable to find makepkg.conf" - exit 1 -fi - -if [ -r ~/.makepkg.conf ]; then - source ~/.makepkg.conf -fi - -out_file=$(basename $1) -file_url=$2 - -if ! [[ "$out_file" =~ "pkg.tar.gz" ]]; then - # If it's not a package file download as normal and exit. - #wget --passive-ftp -c -O "$out_file" "$file_url" - exit $? -fi - - -# Get the package name and version -[[ "$out_file" =~ "$CARCH" ]] && arch="-$CARCH" || arch="" -pkg_data=$(echo $out_file | \ - sed "s|^\(.*\)-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}${PKGEXT}.part|\1 \2|") -pkgname=$(echo $pkg_data | cut -d ' ' -f 1) -new_version=$(echo $pkg_data | cut -d ' ' -f 2) -base_url=${file_url%/*} - -# Look for the last version -for file in $(ls -r /var/cache/pacman/pkg/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do - [[ "$file" =~ "$CARCH" ]] && arch="-$CARCH" || arch="" - check_version=$(echo $file | \ - sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \ - grep -v "^/var/cache/pacman/pkg") - - [ "$check_version" = "" ] && continue - - vercmp=$(vercmp "$check_version" "$old_version") - if [ "$check_version" != "$new_version" -a $vercmp -gt 0 ]; then - old_version=$check_version - old_file=$file - fi -done - -if [ "$old_version" != "" -a "$old_version" != "$new_version" ]; then - # Great, we have a cached file, now calculate a patch name from it - delta_name="$pkgname-${old_version}_to_${new_version}-${CARCH}.delta" - - echo "wget-xdelta: Attempting to download delta $delta_name..." >&2 - if wget --passive-ftp -c "$base_url/$delta_name"; then - echo "wget-xdelta: Applying delta..." - if xdelta patch "$delta_name" "$old_file" "$out_file"; then - echo "wget-xdelta: Delta applied successfully!" - rm "$delta_name" - exit 0 - else - echo "wget-xdelta: Failed to apply delta!" - rm $delta_name - fi - fi - fi - -echo "wget-xdelta: Downloading new package..." -wget --passive-ftp -c -O "$out_file" "$file_url" -exit $? - -# vim:set ts=4 sw=4 noet: diff --git a/contrib/wget-xdelta.sh.in b/contrib/wget-xdelta.sh.in new file mode 100755 index 00000000..4656f4dd --- /dev/null +++ b/contrib/wget-xdelta.sh.in @@ -0,0 +1,70 @@ +#!/bin/bash + +if [ -r "/etc/makepkg.conf" ]; then + source /etc/makepkg.conf +else + echo "wget-xdelta: Unable to find makepkg.conf" + exit 1 +fi + +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + +out_file=$(basename $1) +file_url=$2 + +if ! [[ "$out_file" =~ "pkg.tar.gz" ]]; then + # If it's not a package file download as normal and exit. + #wget --passive-ftp -c -O "$out_file" "$file_url" + exit $? +fi + + +# Get the package name and version +[[ "$out_file" =~ "$CARCH" ]] && arch="-$CARCH" || arch="" +pkg_data=$(echo $out_file | \ + sed "s|^\(.*\)-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}${PKGEXT}.part|\1 \2|") +pkgname=$(echo $pkg_data | cut -d ' ' -f 1) +new_version=$(echo $pkg_data | cut -d ' ' -f 2) +base_url=${file_url%/*} + +# Look for the last version +for file in $(ls -r /var/cache/pacman/pkg/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do + [[ "$file" =~ "$CARCH" ]] && arch="-$CARCH" || arch="" + check_version=$(echo $file | \ + sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \ + grep -v "^/var/cache/pacman/pkg") + + [ "$check_version" = "" ] && continue + + vercmp=$(vercmp "$check_version" "$old_version") + if [ "$check_version" != "$new_version" -a $vercmp -gt 0 ]; then + old_version=$check_version + old_file=$file + fi +done + +if [ "$old_version" != "" -a "$old_version" != "$new_version" ]; then + # Great, we have a cached file, now calculate a patch name from it + delta_name="$pkgname-${old_version}_to_${new_version}-${CARCH}.delta" + + echo "wget-xdelta: Attempting to download delta $delta_name..." >&2 + if wget --passive-ftp -c "$base_url/$delta_name"; then + echo "wget-xdelta: Applying delta..." + if xdelta patch "$delta_name" "$old_file" "$out_file"; then + echo "wget-xdelta: Delta applied successfully!" + rm "$delta_name" + exit 0 + else + echo "wget-xdelta: Failed to apply delta!" + rm $delta_name + fi + fi + fi + +echo "wget-xdelta: Downloading new package..." +wget --passive-ftp -c -O "$out_file" "$file_url" +exit $? + +# vim:set ts=4 sw=4 noet: diff --git a/contrib/zsh_completion b/contrib/zsh_completion deleted file mode 100644 index f69fe631..00000000 --- a/contrib/zsh_completion +++ /dev/null @@ -1,332 +0,0 @@ -#compdef pacman pacman.static=pacman - -# copy this file to /usr/share/zsh/site-functions/_pacman - -typeset -A opt_args - -# options for passing to _arguments: main pacman commands -_pacman_opts_commands=( - '-Q[Query the package database]' - '-R[Remove a package from the system]' - '-S[Synchronize packages]' - '-U[Upgrade a package]' - '-V[Display version and exit]' - '-h[Display usage]' -) - -# options for passing to _arguments: options common to all commands -_pacman_opts_common=( - '-b[Alternate database location]:database_location:_files -/' - '-h[Display syntax for the given operation]' - '-r[Set alternate installation root]:installation root:_files -/' - '-v[Be more verbose]' - '--cachedir[Alternate package cache location]:cache_location:_files -/' - '--config[An alternate configuration file]:config file:_files' - '--logfile[An alternate log file]:config file:_files' - '--noconfirm[Do not ask for confirmation]' - '--noprogressbar[Do not show a progress bar when downloading files]' - '--noscriptlet[Do not execute the install scriptlet if one exists]' - '--print[Only print the targets instead of performing the operation]' -) - -# options for passing to _arguments: options for --upgrade commands -_pacman_opts_pkgfile=( - '-d[Skip dependency checks]' - '-f[Overwrite conflicting files]' - '*:package file:_files -g "*.pkg.tar.*(.)"' -) - -# options for passing to _arguments: subactions for --query command -_pacman_opts_query_actions=( - '-g[View all members of a package group]:*:package groups:->query_group' - '-o[Query the package that owns a file]:file:_files' - '-p[Package file to query]:*:package file:->query_file' - '-s[Search package names and descriptions]:*:search text:->query_search' -) - -# options for passing to _arguments: options for --query and subcommands -_pacman_opts_query_modifiers=( - '-c[List package changelog]' - '-d[List packages installed as dependencies]' - '-e[List packages explicitly installed]' - '-i[View package information]' - '-ii[View package information including backup files]' - '-k[Check package files]' - '-l[List package contents]' - '-m[List installed packages not found in sync db(s)]' - '-t[List packages not required by any package]' - '-u[List packages that can be upgraded]' -) - -# options for passing to _arguments: options for --remove command -_pacman_opts_remove=( - '-c[Remove all dependent packages]' - '-d[Skip dependency checks]' - '-k[Only remove database entry, do not remove files]' - '-n[Remove protected configuration files]' - '-s[Remove dependencies not required by other packages]' - '*:installed package:_pacman_completions_installed_packages' -) - -# options for passing to _arguments: options for --sync command -_pacman_opts_sync_actions=( - '*-c[Remove old packages from cache]:*:clean:->sync_clean' - '*-cc[Remove all packages from cache]:*:clean:->sync_clean' - '-g[View all members of a package group]:*:package groups:->sync_group' - '-s[Search package names and descriptions]:*:search text:->sync_search' -) - -# options for passing to _arguments: options for --sync command -_pacman_opts_sync_modifiers=( - '-d[Skip dependency checks]' - '-f[Overwrite conflicting files]' - '-i[View package information]' - '-l[List all packages in a repository]' - '-p[Print download URIs for each package to be installed]' - '-u[Upgrade all out-of-date packages]' - '-w[Download packages only]' - '-y[Download fresh package databases]' - '*--ignore[Ignore a package upgrade]:package: - _pacman_completions_all_packages' - '*--ignoregroup[Ignore a group upgrade]:package group: - _pacman_completions_all_groups' - '--asdeps[Install packages as non-explicitly installed]' - '--asexplicit[Install packages as explicitly installed]' -) - -# handles --help subcommand -_pacman_action_help() { - _arguments -s : \ - "$_pacman_opts_commands[@]" -} - -# handles cases where no subcommand has yet been given -_pacman_action_none() { - _arguments -s : \ - "$_pacman_opts_commands[@]" -} - -# handles --query subcommand -_pacman_action_query() { - local context state line - typeset -A opt_args - -# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_query_actions[@]" \ -# "$_pacman_opts_query_modifiers[@]" - - case $state in - query_file) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_query_modifiers[@]" \ - '*:package file:_files -g "*.pkg.tar.*"' - ;; - query_group) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_query_modifiers[@]" \ - '*:groups:_pacman_completions_installed_groups' - ;; - query_owner) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_query_modifiers[@]" \ - '*:file:_files' - ;; - query_search) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_query_modifiers[@]" \ - '*:search text: ' - ;; - *) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_query_actions[@]" \ - "$_pacman_opts_query_modifiers[@]" \ - '*:package:_pacman_completions_installed_packages' - ;; - esac -} - -# handles --remove subcommand -_pacman_action_remove() { - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_remove[@]" -} - -# handles --sync subcommand -_pacman_action_sync() { - local context state line - typeset -A opt_args - -# _arguments -s : \ -# "$_pacman_opts_common[@]" \ -# "$_pacman_opts_sync_actions[@]" #\ -# #"$_pacman_opts_sync_modifiers[@]" - - case $state in - sync_clean) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_sync_modifiers[@]" \ - '*-c[Remove old packages from cache]' \ - ;; - sync_group) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_sync_modifiers[@]" \ - '*:package group:_pacman_completions_all_groups' - ;; - sync_search) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_sync_modifiers[@]" \ - '*:search text: ' - ;; - *) - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_sync_modifiers[@]" \ - '*:package:_pacman_completions_all_packages' - ;; - esac -} - -# handles --upgrade subcommand -_pacman_action_upgrade() { - _arguments -s : \ - "$_pacman_opts_common[@]" \ - "$_pacman_opts_pkgfile[@]" -} - -# handles --version subcommand -_pacman_action_version() { - # no further arguments - return 0 -} - -# provides completions for package groups -_pacman_completions_all_groups() { - local -a cmd groups - _pacman_get_command - groups=( $(_call_program groups $cmd[@] -Sg) ) - compadd "$@" -a groups -} - -# provides completions for packages available from repositories -# these can be specified as either 'package' or 'repository/package' -_pacman_completions_all_packages() { - local -a cmd packages repositories packages_long - - repositories=(${(o)${${${(M)${(f)"$(query_group' + '-o[Query the package that owns a file]:file:_files' + '-p[Package file to query]:*:package file:->query_file' + '-s[Search package names and descriptions]:*:search text:->query_search' +) + +# options for passing to _arguments: options for --query and subcommands +_pacman_opts_query_modifiers=( + '-c[List package changelog]' + '-d[List packages installed as dependencies]' + '-e[List packages explicitly installed]' + '-i[View package information]' + '-ii[View package information including backup files]' + '-k[Check package files]' + '-l[List package contents]' + '-m[List installed packages not found in sync db(s)]' + '-t[List packages not required by any package]' + '-u[List packages that can be upgraded]' +) + +# options for passing to _arguments: options for --remove command +_pacman_opts_remove=( + '-c[Remove all dependent packages]' + '-d[Skip dependency checks]' + '-k[Only remove database entry, do not remove files]' + '-n[Remove protected configuration files]' + '-s[Remove dependencies not required by other packages]' + '*:installed package:_pacman_completions_installed_packages' +) + +# options for passing to _arguments: options for --sync command +_pacman_opts_sync_actions=( + '*-c[Remove old packages from cache]:*:clean:->sync_clean' + '*-cc[Remove all packages from cache]:*:clean:->sync_clean' + '-g[View all members of a package group]:*:package groups:->sync_group' + '-s[Search package names and descriptions]:*:search text:->sync_search' +) + +# options for passing to _arguments: options for --sync command +_pacman_opts_sync_modifiers=( + '-d[Skip dependency checks]' + '-f[Overwrite conflicting files]' + '-i[View package information]' + '-l[List all packages in a repository]' + '-p[Print download URIs for each package to be installed]' + '-u[Upgrade all out-of-date packages]' + '-w[Download packages only]' + '-y[Download fresh package databases]' + '*--ignore[Ignore a package upgrade]:package: + _pacman_completions_all_packages' + '*--ignoregroup[Ignore a group upgrade]:package group: + _pacman_completions_all_groups' + '--asdeps[Install packages as non-explicitly installed]' + '--asexplicit[Install packages as explicitly installed]' +) + +# handles --help subcommand +_pacman_action_help() { + _arguments -s : \ + "$_pacman_opts_commands[@]" +} + +# handles cases where no subcommand has yet been given +_pacman_action_none() { + _arguments -s : \ + "$_pacman_opts_commands[@]" +} + +# handles --query subcommand +_pacman_action_query() { + local context state line + typeset -A opt_args + +# _arguments -s : \ +# "$_pacman_opts_common[@]" \ +# "$_pacman_opts_query_actions[@]" \ +# "$_pacman_opts_query_modifiers[@]" + + case $state in + query_file) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_query_modifiers[@]" \ + '*:package file:_files -g "*.pkg.tar.*"' + ;; + query_group) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_query_modifiers[@]" \ + '*:groups:_pacman_completions_installed_groups' + ;; + query_owner) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_query_modifiers[@]" \ + '*:file:_files' + ;; + query_search) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_query_modifiers[@]" \ + '*:search text: ' + ;; + *) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_query_actions[@]" \ + "$_pacman_opts_query_modifiers[@]" \ + '*:package:_pacman_completions_installed_packages' + ;; + esac +} + +# handles --remove subcommand +_pacman_action_remove() { + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_remove[@]" +} + +# handles --sync subcommand +_pacman_action_sync() { + local context state line + typeset -A opt_args + +# _arguments -s : \ +# "$_pacman_opts_common[@]" \ +# "$_pacman_opts_sync_actions[@]" #\ +# #"$_pacman_opts_sync_modifiers[@]" + + case $state in + sync_clean) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_modifiers[@]" \ + '*-c[Remove old packages from cache]' \ + ;; + sync_group) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_modifiers[@]" \ + '*:package group:_pacman_completions_all_groups' + ;; + sync_search) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_modifiers[@]" \ + '*:search text: ' + ;; + *) + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_sync_modifiers[@]" \ + '*:package:_pacman_completions_all_packages' + ;; + esac +} + +# handles --upgrade subcommand +_pacman_action_upgrade() { + _arguments -s : \ + "$_pacman_opts_common[@]" \ + "$_pacman_opts_pkgfile[@]" +} + +# handles --version subcommand +_pacman_action_version() { + # no further arguments + return 0 +} + +# provides completions for package groups +_pacman_completions_all_groups() { + local -a cmd groups + _pacman_get_command + groups=( $(_call_program groups $cmd[@] -Sg) ) + compadd "$@" -a groups +} + +# provides completions for packages available from repositories +# these can be specified as either 'package' or 'repository/package' +_pacman_completions_all_packages() { + local -a cmd packages repositories packages_long + + repositories=(${(o)${${${(M)${(f)"$(