bz2 fix absolute symlinks (#4365)

* for some reason these symlinks are created absolute, fix that
* restore the makefile to make the dylib on darwin
  * it was failing due to bzip2 being a dep for brewkit
This commit is contained in:
Max Howell 2023-12-11 13:36:10 -05:00 committed by GitHub
parent 51a7a5f2a6
commit 447e3f0245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 100 additions and 28 deletions

View file

@ -0,0 +1,44 @@
# This Makefile builds a shared version of the library,
# libbz2.dylib for MacOSX x86 (10.13.4 or higher),
# It is a custom Makefile. Use at own risk.
# Run in your MacOS terminal with the following command:
# make -f Makefile-libbz2_dylib
PKG_VERSION?=1.0.8
PREFIX?=/usr/local
# SHELL=/bin/sh
# CC=gcc
BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
OBJS= blocksort.o \
huffman.o \
crctable.o \
randtable.o \
compress.o \
decompress.o \
bzlib.o
all: $(OBJS)
$(CC) -shared -Wl,-install_name -Wl,libbz2.dylib -o libbz2.${PKG_VERSION}.dylib $(OBJS)
cp libbz2.${PKG_VERSION}.dylib ${PREFIX}/lib/
ln -s libbz2.${PKG_VERSION}.dylib ${PREFIX}/lib/libbz2.dylib
clean:
rm -f libbz2.dylib libbz2.${PKG_VERSION}.dylib
blocksort.o: blocksort.c
$(CC) $(CFLAGS) -c blocksort.c
huffman.o: huffman.c
$(CC) $(CFLAGS) -c huffman.c
crctable.o: crctable.c
$(CC) $(CFLAGS) -c crctable.c
randtable.o: randtable.c
$(CC) $(CFLAGS) -c randtable.c
compress.o: compress.c
$(CC) $(CFLAGS) -c compress.c
decompress.o: decompress.c
$(CC) $(CFLAGS) -c decompress.c
bzlib.o: bzlib.c
$(CC) $(CFLAGS) -c bzlib.c

View file

@ -9,48 +9,76 @@ versions:
provides: provides:
- bin/bunzip2 - bin/bunzip2
- bin/bzcat - bin/bzcat
- bin/bzcmp
- bin/bzdiff - bin/bzdiff
- bin/bzgrep - bin/bzgrep
- bin/bzegrep
- bin/bzfgrep
- bin/bzip2 - bin/bzip2
- bin/bzip2recover - bin/bzip2recover
- bin/bzmore - bin/bzmore
- bin/bzless
build: build:
script: | script:
make \ - make --environment-overrides
--environment-overrides \ - make --environment-overrides install
--jobs {{ hw.concurrency }} \
install
case {{ hw.platform }} in # fix absolute symlinks
linux) - run: |
make \ for x in *; do
--file Makefile-libbz2_so \ if [ -L $x ]; then
--environment-overrides \ y="$(readlink $x)"
--jobs {{ hw.concurrency }} rm $x
ln -s $(basename "$y") $x
fi
done
working-directory: '{{prefix}}/bin'
mv libbz2.*.1.* {{ prefix }}/lib - if: linux
cd {{ prefix }}/lib run: |
test -e libbz2.so || ln -s libbz2.so.{{ version }} libbz2.so make \
test -e libbz2.so.{{ version.major }} || ln -s libbz2.so.{{ version }} libbz2.so.{{ version.major }} --file Makefile-libbz2_so \
;; --environment-overrides \
darwin) --jobs {{ hw.concurrency }}
cd {{ prefix }}/lib
test -e libbz2.dylib mv libbz2.*.1.* {{ prefix }}/lib
test -e libbz2.{{version}}.dylib cd {{ prefix }}/lib
test -e libbz2.{{version.major}}.dylib test -e libbz2.so || ln -s libbz2.so.{{ version }} libbz2.so
;; test -e libbz2.so.{{ version.major }} || ln -s libbz2.so.{{ version }} libbz2.so.{{ version.major }}
esac
- if: darwin
run: |
# necessary until brewkit v1
if [ -n "$(ls {{ prefix }}/lib/*.dylib)" ]; then
rm {{ prefix }}/lib/*.dylib
fi
make \
--file props/Makefile-libbz2_dylib \
--environment-overrides \
--jobs {{ hw.concurrency }}
cd {{ prefix }}/lib
test -e libbz2.dylib
test -e libbz2.{{version}}.dylib
ln -s libbz2.{{version}}.dylib libbz2.{{version.major}}.dylib
env: env:
CFLAGS: -fPIC # so deps link without relocation issues on linux/aarch64
PREFIX: ${{ prefix }} PREFIX: ${{ prefix }}
darwin: darwin:
PKG_VERSION: ${{ version }} PKG_VERSION: ${{ version }}
test: test:
script: | script:
OUT=$(echo "$INPUT" | bzip2 | bunzip2) - |
test "$OUT" = "$INPUT" OUT=$(echo "$INPUT" | bzip2 | bunzip2)
test "$OUT" = "$INPUT"
# test symlinks are functional
# sadly bzegrep has no `--help`
- |
echo "$INPUT" > file
bzip2 file
bzegrep test-string file.bz2
env: env:
INPUT: tea.xyz INPUT: tea.xyz.test-string