Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22914ba

Browse files
Main: Support xz compression as an to gzip for the extension pack.
svn:sync-xref-src-repo-rev: r171255
1 parent 8780f7a commit 22914ba

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

‎src/VBox/Main/Makefile.kmk‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: Makefile.kmk 111604 2025-11-10 16:25:29Z alexander.eichner@oracle.com $
1+
# $Id: Makefile.kmk 111663 2025-11-12 12:07:32Z knut.osmundsen@oracle.com $
22
## @file
33
# Makefile for the VBox Main module.
44
#
@@ -220,6 +220,9 @@ endif
220220
ifdef VBOX_WITH_MAIN_OBJECT_TRACKER
221221
VBOX_MAIN_DEFS += VBOX_WITH_MAIN_OBJECT_TRACKER
222222
endif
223+
ifdef VBOX_WITH_LIBLZMA
224+
VBOX_MAIN_DEFS += VBOX_WITH_LIBLZMA
225+
endif
223226
# Unconditionally enable the new semaphore key generation code
224227
VBOX_MAIN_DEFS += VBOX_WITH_NEW_SYS_V_KEYGEN
225228
VBOX_MAIN_DEFS += \
@@ -1405,6 +1408,9 @@ if !defined(VBOX_ONLY_SDK) && !defined(VBOX_ONLY_EXTPACKS) # Note this goes on f
14051408
ifdef VBOX_WITH_EXTPACK
14061409
PROGRAMS += VBoxExtPackHelperApp
14071410
VBoxExtPackHelperApp_TEMPLATE = VBoxR3SetUidToRoot
1411+
ifdef VBOX_WITH_LIBLZMA
1412+
VBoxExtPackHelperApp_DEFS := VBOX_WITH_LIBLZMA
1413+
endif
14081414
VBoxExtPackHelperApp_LDFLAGS.darwin = -framework Security
14091415
VBoxExtPackHelperApp_LDFLAGS.win = /SUBSYSTEM:windows
14101416
VBoxExtPackHelperApp_SOURCES = \

‎src/VBox/Main/src-all/ExtPackUtil.cpp‎

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: ExtPackUtil.cpp 110684 2025-08-11 17:18:47Z klaus.espenlaub@oracle.com $ */
1+
/* $Id: ExtPackUtil.cpp 111663 2025-11-12 12:07:32Z knut.osmundsen@oracle.com $ */
22
/** @file
33
* VirtualBox Main - Extension Pack Utilities and definitions, VBoxC, VBoxSVC, ++.
44
*/
@@ -1206,14 +1206,26 @@ int VBoxExtPackValidateMember(const char *pszName, RTVFSOBJTYPE enmType, RTVFSOB
12061206
int VBoxExtPackOpenTarFss(RTFILE hTarballFile, char *pszError, size_t cbError, PRTVFSFSSTREAM phTarFss,
12071207
PRTMANIFEST phFileManifest)
12081208
{
1209+
int vrc;
1210+
12091211
Assert(cbError > 0);
12101212
*pszError = '0円';
12111213
*phTarFss = NIL_RTVFSFSSTREAM;
12121214

1215+
/*
1216+
* Read the first couple of bytes to detect the compression type.
1217+
*/
1218+
uint8_t abFirstBytes[16] = {0};
1219+
size_t cbFirstBytes = 0;
1220+
vrc = RTFileReadAt(hTarballFile, 0, abFirstBytes, sizeof(abFirstBytes), &cbFirstBytes);
1221+
if (RT_FAILURE(vrc))
1222+
return vboxExtPackReturnError(vrc, pszError, cbError,
1223+
ExtPackUtil::tr("Failed to read the first 16 bytes of the tarball: %Rrc"), vrc);
1224+
12131225
/*
12141226
* Rewind the file and set up a VFS chain for it.
12151227
*/
1216-
intvrc = RTFileSeek(hTarballFile, 0, RTFILE_SEEK_BEGIN, NULL);
1228+
vrc = RTFileSeek(hTarballFile, 0, RTFILE_SEEK_BEGIN, NULL);
12171229
if (RT_FAILURE(vrc))
12181230
return vboxExtPackReturnError(vrc, pszError, cbError,
12191231
ExtPackUtil::tr("Failed seeking to the start of the tarball: %Rrc"), vrc);
@@ -1233,16 +1245,36 @@ int VBoxExtPackOpenTarFss(RTFILE hTarballFile, char *pszError, size_t cbError, P
12331245
true /*read*/, &hPtIos);
12341246
if (RT_SUCCESS(vrc))
12351247
{
1236-
RTVFSIOSTREAM hGunzipIos;
1237-
vrc = RTZipGzipDecompressIoStream(hPtIos, 0 /*fFlags*/, &hGunzipIos);
1248+
RTVFSIOSTREAM hDecompIos = NIL_RTVFSIOSTREAM;
1249+
const char *pszDecompNm;
1250+
vrc = VERR_NOT_SUPPORTED;
1251+
if (RTZipXzIsStartOfCompressedStream(abFirstBytes, cbFirstBytes))
1252+
{
1253+
pszDecompNm = "RTZipXzDecompressIoStream";
1254+
#ifdef VBOX_WITH_LIBLZMA
1255+
vrc = RTZipXzDecompressIoStream(hPtIos, 0 /*fFlags*/, &hDecompIos);
1256+
#endif
1257+
}
1258+
else if (RTZipBzip2IsStartOfCompressedStream(abFirstBytes, cbFirstBytes))
1259+
{
1260+
pszDecompNm = "RTZipBzip2DecompressIoStream";
1261+
#ifdef VBOX_WITH_LIBBZIP2
1262+
vrc = RTZipBzip2DecompressIoStream(hPtIos, 0 /*fFlags*/, &hDecompIos);
1263+
#endif
1264+
}
1265+
else
1266+
{
1267+
pszDecompNm = "RTZipGzipDecompressIoStream";
1268+
vrc = RTZipGzipDecompressIoStream(hPtIos, 0 /*fFlags*/, &hDecompIos);
1269+
}
12381270
if (RT_SUCCESS(vrc))
12391271
{
12401272
RTVFSFSSTREAM hTarFss;
1241-
vrc = RTZipTarFsStreamFromIoStream(hGunzipIos, 0 /*fFlags*/, &hTarFss);
1273+
vrc = RTZipTarFsStreamFromIoStream(hDecompIos, 0 /*fFlags*/, &hTarFss);
12421274
if (RT_SUCCESS(vrc))
12431275
{
12441276
RTVfsIoStrmRelease(hPtIos);
1245-
RTVfsIoStrmRelease(hGunzipIos);
1277+
RTVfsIoStrmRelease(hDecompIos);
12461278
RTVfsIoStrmRelease(hTarballIos);
12471279
*phTarFss = hTarFss;
12481280
if (phFileManifest)
@@ -1253,10 +1285,10 @@ int VBoxExtPackOpenTarFss(RTFILE hTarballFile, char *pszError, size_t cbError, P
12531285
}
12541286

12551287
vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipTarFsStreamFromIoStream failed: %Rrc"), vrc);
1256-
RTVfsIoStrmRelease(hGunzipIos);
1288+
RTVfsIoStrmRelease(hDecompIos);
12571289
}
12581290
else
1259-
vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("RTZipGzipDecompressIoStream failed: %Rrc"), vrc);
1291+
vboxExtPackSetError(pszError, cbError, ExtPackUtil::tr("%s failed: %Rrc"), pszDecompNm, vrc);
12601292
RTVfsIoStrmRelease(hPtIos);
12611293
}
12621294
else

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /