Skip to content

Commit

Permalink
Add bzip2
Browse files Browse the repository at this point in the history
  • Loading branch information
blue42u authored and jpakkane committed Jul 12, 2024
1 parent 6a38c28 commit 1ccf7ba
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@
"3.3.0-1"
]
},
"bzip2": {
"dependency_names": [
"bzip2"
],
"versions": [
"1.0.8-1"
]
},
"c-ares": {
"dependency_names": [
"libcares"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/bzip2.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = bzip2-1.0.8
source_url = https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
source_filename = bzip2-1.0.8.tar.gz
source_hash = ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269
patch_directory = bzip2

[provide]
dependency_names = bzip2
101 changes: 101 additions & 0 deletions subprojects/packagefiles/bzip2/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
project('bzip2', 'c', version: '1.0.8', meson_version: '>=1.0.0')

libbz2_lib = static_library(
'bz2',
'blocksort.c',
'huffman.c',
'crctable.c',
'randtable.c',
'compress.c',
'decompress.c',
'bzlib.c',
pic: true,
install: true,
)

bzip2_exe = executable('bzip2', 'bzip2.c', link_with: libbz2_lib)

if meson.can_run_host_binaries()
python = find_program('python3', native: true, version: ['>=3.5', '<4'])
_testargs = [files('test.py')]
test(
'compress sample1',
python,
args: [
_testargs,
files('sample1.ref'),
files('sample1.bz2'),
'--',
bzip2_exe,
'-1',
],
)
test(
'compress sample2',
python,
args: [
_testargs,
files('sample2.ref'),
files('sample2.bz2'),
'--',
bzip2_exe,
'-2',
],
)
test(
'compress sample3',
python,
args: [
_testargs,
files('sample3.ref'),
files('sample3.bz2'),
'--',
bzip2_exe,
'-3',
],
)
test(
'decompress sample1',
python,
args: [
_testargs,
files('sample1.bz2'),
files('sample1.ref'),
'--',
bzip2_exe,
'-d',
],
)
test(
'decompress sample2',
python,
args: [
_testargs,
files('sample2.bz2'),
files('sample2.ref'),
'--',
bzip2_exe,
'-d',
],
)
test(
'decompress sample3',
python,
args: [
_testargs,
files('sample3.bz2'),
files('sample3.ref'),
'--',
bzip2_exe,
'-ds',
],
)
endif

install_headers('bzlib.h')

bzip2_dep = declare_dependency(
link_with: libbz2_lib,
include_directories: include_directories('.'),
)
meson.override_dependency('bzip2', bzip2_dep)
36 changes: 36 additions & 0 deletions subprojects/packagefiles/bzip2/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3

import subprocess
import argparse
from pathlib import Path
import tempfile
import os
import shlex
import sys


def run_command(command, stdinfile):
if "MESON_EXE_WRAPPER" in os.environ:
command = shlex.split(os.environ["MESON_EXE_WRAPPER"]) + command
with tempfile.TemporaryFile("w+b") as outf:
with open(stdinfile, "rb") as inf:
subprocess.run(command, stdin=inf, stdout=outf)
outf.seek(0)
return outf.read()


def compare(result, reffile):
with open(reffile, "rb") as reff:
return result == reff.read()


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("input", type=Path)
parser.add_argument("reference", type=Path)
parser.add_argument("command", nargs="+")
args = parser.parse_args()

if not compare(run_command(args.command, args.input), args.reference):
print("Output did not match reference file!")
sys.exit(1)
3 changes: 3 additions & 0 deletions tools/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
'box2d': [
'doctest.h'
],
'bzip2': [
'test.py',
],
'curl': [
'extract.mk',
'rewrite.mk',
Expand Down

0 comments on commit 1ccf7ba

Please sign in to comment.