11 Star 0 Fork 4

openEuler/unizip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

README

unizip

介绍

本项目基于 openEuler 社区提供统一的压缩库,基于该压缩库能够实现对于不同压缩软件的适配,无需修改开源软件代码即可灵活切换开源软件使用不同的压缩算法。

软件架构

详细设计见 wiki

安装教程

  1. 执行如下命令安装 gmock-devel、cmake、make、zlib-devel、LibLZMA、BZip2、Zstd、Snappy、Brotli、lz4
yum install -y gmock-devel cmake make gcc-c++ bzip2-devel zlib-devel xz-devel libzstd-devel snappy-devel brotli-devel lz4-devel
  1. 使用如下命令 clone 代码
git clone https://gitee.com/openeuler/unizip.git
  1. 进入 unizip 目录,执行如下命令进行编译
sudo mkdir build
cd build
cmake ..
make
  1. 执行如下命令运行测试用例:
ctest
  1. 执行如下命令生成覆盖率报告:
make coverage
  1. 执行如下命令安装:
make install

使用教程

开源软件可以使用unizip替代zlib库使用,修改需要修改的内容如下(以curl为例)

1、修改开源代码的编译参数配置文件,根据不同的开源软件编译方式修改不同的文件,例如configure.ac或者CMakeLists.txt等。 以curl为例,修改configure.ac,增加如下内容,通过参数--with-unizip控制是否使用unizip:

AC_ARG_WITH([unizip],
    [AS_HELP_STRING([--with-unizip], [Enable UNIZIP (default is no)])],
    [use_unizip="$withval"],
    [use_unizip="no"])

if test "x$use_unizip" = "xyes"; then
    AC_MSG_WARN([UNIZIP is enabled.])
    PKG_CHECK_MODULES([UNIZIP], [unizip],
        [LIBS="-lunizip $LIBS"
        AC_DEFINE([USE_UNIZIP], [1], [Define if UNIZIP is enabled])],
        [
        AC_MSG_ERROR([Could not find UNIZIP library])
        ])
fi

2、查找源码文件中所有使用到zlib.h的位置,将源代码中的 zlib.h 更换成 unizip_adapt.h,并对结构体进行重命名,以curl为例:

例如将 content_encoding.c 文件中的

#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif

更换成

#ifndef USE_UNIZIP						// 根据configure.ac中是否传入--with-unizip来确定是否使用unizip
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#else
#include "unizip.h"
#endif

3、修改开源软件的编译脚本,在configure中添加--with-unizip,开启使用unizip替代zlib。以curl.spec为例:

common_configure_opts="--cache-file=../config.cache \
         --enable-ldap \
         --enable-ldaps \
         --enable-manual \
-        --with-brotli \
         --with-libidn2 \
         --with-libpsl \
+        --with-libssh \
+        --with-unizip		# 开启使用unizip

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

空文件

简介

the framework of integrating existing archiving libraries into unified program interfaces 展开 收起
C 等 4 种语言
MulanPSL-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/unizip.git
git@gitee.com:openeuler/unizip.git
openeuler
unizip
unizip
master

搜索帮助