runtime(misc): add support for bzip3 to tar, vimball and gzip plugins
fixes: #16751
closes: #16755
Signed-off-by: Jim Zhou <jimzhouzzy@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/getscript.vim b/runtime/autoload/getscript.vim
index 3906050..e599d1e 100644
--- a/runtime/autoload/getscript.vim
+++ b/runtime/autoload/getscript.vim
@@ -12,6 +12,7 @@
" autoloading search path fix
" substitution of hardcoded commands with global variables
" 2024 Nov 12 by Vim Project: fix problems on Windows (#16036)
+" 2025 Feb 28 by Vim Project: add support for bzip3 (#16755)
" }}}
"
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
@@ -100,6 +101,10 @@
let g:GetLatestVimScripts_bunzip2= "bunzip2"
endif
+if !exists("g:GetLatestVimScripts_bunzip3")
+ let g:GetLatestVimScripts_bunzip3= "bunzip3"
+endif
+
if !exists("g:GetLatestVimScripts_gunzip")
let g:GetLatestVimScripts_gunzip= "gunzip"
endif
@@ -565,73 +570,55 @@
" --------------------------------------------------------------------------
" call Decho("checking if plugin requested autoinstall: doautoinstall=".doautoinstall)
if doautoinstall
-" call Decho(" ")
-" call Decho("Autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
if filereadable(sname)
-" call Decho("<".sname."> is readable")
-" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall))
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall)
let curdir = fnameescape(substitute(getcwd(),'\','/','ge'))
let installdir= curdir."/Installed"
if !isdirectory(installdir)
call mkdir(installdir)
endif
-" call Decho("curdir<".curdir."> installdir<".installdir.">")
-" call Decho("exe cd ".fnameescape(s:autoinstall))
exe "cd ".fnameescape(s:autoinstall)
" determine target directory for moves
let firstdir= substitute(&rtp,',.*$','','')
let pname = substitute(sname,'\..*','.vim','')
-" call Decho("determine tgtdir: is <".firstdir.'/AsNeeded/'.pname." readable?")
if filereadable(firstdir.'/AsNeeded/'.pname)
let tgtdir= "AsNeeded"
else
let tgtdir= "plugin"
endif
-" call Decho("tgtdir<".tgtdir."> pname<".pname.">")
-
+
" decompress
if sname =~ '\.bz2$'
-" call Decho("decompress: attempt to bunzip2 ".sname)
exe "sil !".g:GetLatestVimScripts_bunzip2." ".shellescape(sname)
let sname= substitute(sname,'\.bz2$','','')
-" call Decho("decompress: new sname<".sname."> after bunzip2")
+ elseif sname =~ '\.bz3$'
+ exe "sil !".g:GetLatestVimScripts_bunzip3." ".shellescape(sname)
+ let sname= substitute(sname,'\.bz3$','','')
elseif sname =~ '\.gz$'
-" call Decho("decompress: attempt to gunzip ".sname)
exe "sil !".g:GetLatestVimScripts_gunzip." ".shellescape(sname)
let sname= substitute(sname,'\.gz$','','')
-" call Decho("decompress: new sname<".sname."> after gunzip")
elseif sname =~ '\.xz$'
-" call Decho("decompress: attempt to unxz ".sname)
exe "sil !".g:GetLatestVimScripts_unxz." ".shellescape(sname)
let sname= substitute(sname,'\.xz$','','')
-" call Decho("decompress: new sname<".sname."> after unxz")
else
" call Decho("no decompression needed")
endif
-
+
" distribute archive(.zip, .tar, .vba, .vmb, ...) contents
if sname =~ '\.zip$'
-" call Decho("dearchive: attempt to unzip ".sname)
exe "silent !".g:GetLatestVimScripts_unzip." -o ".shellescape(sname)
elseif sname =~ '\.tar$'
-" call Decho("dearchive: attempt to untar ".sname)
exe "silent !tar -xvf ".shellescape(sname)
elseif sname =~ '\.tgz$'
-" call Decho("dearchive: attempt to untar+gunzip ".sname)
exe "silent !tar -zxvf ".shellescape(sname)
elseif sname =~ '\.taz$'
-" call Decho("dearchive: attempt to untar+uncompress ".sname)
exe "silent !tar -Zxvf ".shellescape(sname)
elseif sname =~ '\.tbz$'
-" call Decho("dearchive: attempt to untar+bunzip2 ".sname)
exe "silent !tar -jxvf ".shellescape(sname)
elseif sname =~ '\.txz$'
-" call Decho("dearchive: attempt to untar+xz ".sname)
exe "silent !tar -Jxvf ".shellescape(sname)
elseif sname =~ '\.vba$\|\.vmb$'
-" call Decho("dearchive: attempt to handle a vimball: ".sname)
silent 1split
if exists("g:vimball_home")
let oldvimballhome= g:vimball_home
@@ -648,25 +635,21 @@
else
" call Decho("no dearchiving needed")
endif
-
+
" ---------------------------------------------
" move plugin to plugin/ or AsNeeded/ directory
" ---------------------------------------------
if sname =~ '.vim$'
-" call Decho("dearchive: attempt to simply move ".sname." to ".tgtdir)
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".tgtdir
else
-" call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".installdir
endif
if tgtdir != "plugin"
-" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape("plugin/".pname)." ".tgtdir)
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape("plugin/".pname)." ".tgtdir
endif
-
+
" helptags step
let docdir= substitute(&rtp,',.*','','e')."/doc"
-" call Decho("helptags: docdir<".docdir.">")
exe "helptags ".fnameescape(docdir)
exe "cd ".fnameescape(curdir)
endif
@@ -681,13 +664,8 @@
" update the data in the <GetLatestVimScripts.dat> file
call setline(line("."),modline)
-" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
-" else " Decho
-" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
endif
-" call Dredir("BUFFER TEST (GetOneScript)","ls!")
-" call Dret("GetOneScript")
endfun
" ---------------------------------------------------------------------
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index 5c4499f..ea1525c 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -1,9 +1,15 @@
" tar.vim: Handles browsing tarfiles - AUTOLOAD PORTION
-" Date: Feb 06, 2025
+" Date: Feb 28, 2025
" Version: 32b (with modifications from the Vim Project)
" Maintainer: This runtime file is looking for a new maintainer.
" Former Maintainer: Charles E Campbell
" License: Vim License (see vim's :help license)
+" Last Change:
+" 2024 Jan 08 by Vim Project: fix a few problems (#138331, #12637, #8109)
+" 2024 Feb 19 by Vim Project: announce adoption
+" 2024 Nov 11 by Vim Project: support permissions (#7379)
+" 2025 Feb 06 by Vim Project: add support for lz4 (#16591)
+" 2025 Feb 28 by Vim Project: add support for bzip3 (#16755)
"
" Contains many ideas from Michael Toren's <tar.vim>
"
@@ -161,6 +167,8 @@
if filekind =~ "bzip2"
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
+ elseif filekind =~ "bzip3"
+ exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif filekind =~ "XZ"
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif filekind =~ "Zstandard"
@@ -175,6 +183,8 @@
exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$'
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
+ elseif tarfile =~# '\.\(bz3\|tb3\)$'
+ exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(lzma\|tlz\)$'
exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.\(xz\|txz\)$'
@@ -316,6 +326,9 @@
if fname =~ '\.bz2$' && executable("bzcat")
let decmp= "|bzcat"
let doro = 1
+ elseif fname =~ '\.bz3$' && executable("bz3cat")
+ let decmp= "|bz3cat"
+ let doro = 1
elseif fname =~ '\.t\=gz$' && executable("zcat")
let decmp= "|zcat"
let doro = 1
@@ -334,7 +347,7 @@
else
let decmp=""
let doro = 0
- if fname =~ '\.bz2$\|\.gz$\|\.lzma$\|\.xz$\|\.zip$\|\.Z$'
+ if fname =~ '\.bz2$\|\.bz3$\|\.gz$\|\.lzma$\|\.xz$\|\.zip$\|\.Z$'
setlocal bin
endif
endif
@@ -348,6 +361,9 @@
if tarfile =~# '\.bz2$'
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
exe "read ".fname
+ if tarfile =~# '\.bz3$'
+ exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
+ exe "read ".fname
elseif tarfile =~# '\.\(gz\)$'
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
exe "read ".fname
@@ -360,6 +376,9 @@
if filekind =~ "bzip2"
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
exe "read ".fname
+ elseif filekind =~ "bzip3"
+ exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
+ exe "read ".fname
elseif filekind =~ "XZ"
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
exe "read ".fname
@@ -446,6 +465,10 @@
call system("bzip2 -d -- ".shellescape(tarfile,0))
let tarfile = substitute(tarfile,'\.bz2','','e')
let compress= "bzip2 -- ".shellescape(tarfile,0)
+ elseif tarfile =~# '\.bz3'
+ call system("bzip3 -d -- ".shellescape(tarfile,0))
+ let tarfile = substitute(tarfile,'\.bz3','','e')
+ let compress= "bzip3 -- ".shellescape(tarfile,0)
elseif tarfile =~# '\.gz'
call system("gzip -d -- ".shellescape(tarfile,0))
let tarfile = substitute(tarfile,'\.gz','','e')
@@ -638,6 +661,15 @@
echo "***note*** successfully extracted ".fname
endif
+ elseif filereadable(tarbase.".tar.bz3")
+ let extractcmd= substitute(extractcmd,"-","-j","")
+ call system(extractcmd." ".shellescape(tarbase).".tar.bz3 ".shellescape(fname))
+ if v:shell_error != 0
+ echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tar.bz3 ".fname.": failed!" | echohl NONE
+ else
+ echo "***note*** successfully extracted ".fname
+ endif
+
elseif filereadable(tarbase.".txz")
let extractcmd= substitute(extractcmd,"-","-J","")
call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname))
diff --git a/runtime/autoload/vimball.vim b/runtime/autoload/vimball.vim
index 774b798..6456984 100644
--- a/runtime/autoload/vimball.vim
+++ b/runtime/autoload/vimball.vim
@@ -2,8 +2,10 @@
" Maintainer: This runtime file is looking for a new maintainer.
" Original Author: Charles E. Campbell
" Date: Apr 11, 2016
-" Version: 37
+" Version: 37 (with modifications from the Vim Project)
" GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim
+" Last Change:
+" 2025 Feb 28 by Vim Project: add support for bzip3 (#16755)
" Copyright: (c) 2004-2011 by Charles E. Campbell
" The VIM LICENSE applies to Vimball.vim, and Vimball.txt
" (see |copyright|) except use "Vimball" instead of "Vim".
@@ -530,6 +532,26 @@
exe "e ".escape(fname,' \')
if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif
+ elseif expand("%") =~ '.*\.bz3' && executable("bunzip3")
+ " handle *.bz3 with bunzip3
+ silent exe "!bunzip3 ".shellescape(a:fname)
+ if v:shell_error != 0
+ call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) bunzip3 may have failed with <".a:fname.">")
+ endif
+ let fname= substitute(a:fname,'\.bz3$','','')
+ exe "e ".escape(fname,' \')
+ if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif
+
+ elseif expand("%") =~ '.*\.bz3' && executable("bzip3")
+ " handle *.bz3 with bzip3 -d
+ silent exe "!bzip3 -d ".shellescape(a:fname)
+ if v:shell_error != 0
+ call vimball#ShowMesg(s:WARNING,'(vimball#Decompress) "bzip3 -d" may have failed with <'.a:fname.">")
+ endif
+ let fname= substitute(a:fname,'\.bz3$','','')
+ exe "e ".escape(fname,' \')
+ if a:0 == 0| call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)") | endif
+
elseif expand("%") =~ '.*\.zip' && executable("unzip")
" handle *.zip with unzip
silent exe "!unzip ".shellescape(a:fname)