Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deb files with .tar.xz control and data files #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions autoload/deb.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim autoload file for browsing debian package.
" copyright (C) 2007-2008, arno renevier <[email protected]>
" Distributed under the GNU General Public License (version 2 or above)
" Last Change: 2008 april 1
" Last Change: 2018 June 17
"
" Inspired by autoload/tar.vim by Charles E Campbell
"
Expand Down Expand Up @@ -37,14 +37,23 @@ fun! deb#read(debfile, member)
return
endif
let l:unpcmp = "lzma -d | tar xfO "
elseif l:archmember == "data.tar.xz"
let l:unpcmp = "tar JxfO "
elseif l:archmember == "data.tar"
let l:unpcmp = "tar xfO "
endif

if a:member =~ '^\* ' " information control file
let l:archmember = "control.tar.gz"
let l:archmember = s:controlFileName(a:debfile)
if l:archmember == ""
echohl WarningMsg | echo "***error*** (deb#read) no valid control file found in debian archive"
return
elseif l:archmember == "control.tar.gz"
let l:unpcmp = "tar zxfO "
elseif l:archmember == "control.tar.xz"
let l:unpcmp = "tar JxfO "
endif
let l:target = substitute(l:target, "^\* ", "", "")
let l:unpcmp = "tar zxfO "
elseif a:member =~ ' -> ' " symbolic link
let l:target = split(a:member,' -> ')[0]
let l:linkname = split(a:member,' -> ')[1]
Expand Down Expand Up @@ -151,7 +160,16 @@ fun! deb#browse(file)

" display information control files
let l:infopos = line(".")
exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.gz | tar zt"

let l:archmember = s:controlFileName(a:file)
if l:archmember == ""
echohl WarningMsg | echo "***error*** (deb#browse) no valid control file found in debian archive"
return
elseif l:archmember == "control.tar.gz"
exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.gz | tar zt"
elseif l:archmember == "control.tar.xz"
exe "silent read! ar p " . s:QuoteFile(a:file) . " control.tar.xz | tar Jt"
endif

$put=''

Expand Down Expand Up @@ -228,9 +246,9 @@ fun! s:DebBrowseSelect()
endfun

" return data file name for debian package. This can be either data.tar.gz,
" data.tar.bz2 or data.tar.lzma
" data.tar.bz2, data.tar.lzma or data.tar.xz (plus unpacked data.tar)
fun s:dataFileName(deb)
for fn in ["data.tar.gz", "data.tar.bz2", "data.tar.lzma", "data.tar"]
for fn in ["data.tar.gz", "data.tar.bz2", "data.tar.lzma", "data.tar.xz", "data.tar"]
" [0:-2] is to remove trailing null character from command output
if (system("ar t " . "'" . a:deb . "'" . " " . fn))[0:-2] == fn
return fn
Expand All @@ -239,6 +257,18 @@ fun s:dataFileName(deb)
return "" " no debian data format in this archive
endfun

" return control file name for debian package. This can be either
" control.tar.gz or control.tar.xz
fun s:controlFileName(deb)
for fn in ["control.tar.gz", "control.tar.xz"]
" [0:-2] is to remove trailing null character from command output
if (system("ar t " . "'" . a:deb . "'" . " " . fn))[0:-2] == fn
return fn
endif
endfor
return "" " no debian control file in this archive
endfun

fun s:QuoteFile(file)
" we need to escape %, #, <, and >
" see :help cmdline-specialk
Expand Down
1 change: 1 addition & 0 deletions plugin/debPlugin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ endif
let g:loaded_debPlugin = 1

autocmd BufReadCmd *.deb call deb#browse(expand("<amatch>"))
autocmd BufReadCmd *.ipk call deb#browse(expand("<amatch>"))