commit: c1395e6a4dc008774351a4415a78080c996ce85f
parent a9d894317de0787c53ab45d9dbd88d3cb2c840ec
Author: fosslinux <fosslinux@aussies.space>
Date: Fri, 15 Jan 2021 12:22:06 +1100
Merge pull request #11 from stikonas/bzip2
Bzip2
Diffstat:
4 files changed, 95 insertions(+), 5 deletions(-)
diff --git a/rootfs.sh b/rootfs.sh
@@ -87,7 +87,9 @@ cp tcc-patched.kaem tmp/after/
# tar 1.12
url=https://ftp.gnu.org/gnu/tar/tar-1.12.tar.gz
pushd ../sources
-wget --continue "$url"
+if [ ! -f "$(basename $url)" ]; then
+ wget "$url"
+fi
popd
cp "$(basename $url .tar.gz).kaem" tmp/after
tar -C tmp/after -xf "../sources/$(basename $url)"
@@ -95,7 +97,9 @@ tar -C tmp/after -xf "../sources/$(basename $url)"
get_file() {
url=$1
pushd ../sources
- wget --continue "$url"
+ if [ ! -f "$(basename "$url")" ]; then
+ wget "$url"
+ fi
popd
ext="${url##*.}"
if [ "$ext" = "tar" ]; then
@@ -103,9 +107,11 @@ get_file() {
else
bname=$(basename "$url" ".tar.${ext}")
fi
- if [ -f "${bname}."* ]; then
- cp "${bname}."* tmp/after
- fi
+ for file in "${bname}."*; do
+ if [ -f "${file}" ]; then
+ cp "${file}" tmp/after
+ fi
+ done
cp "../sources/$(basename "$url")" tmp/after
}
@@ -124,6 +130,9 @@ cp tcc-patched.kaem tmp/after/
# make 3.80
get_file https://ftp.gnu.org/gnu/make/make-3.80.tar.gz
+# bzip2 1.0.8
+get_file ftp://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
+
# General cleanup
find tmp -name .git -exec rm -rf \;
diff --git a/sysa/after.kaem.run b/sysa/after.kaem.run
@@ -89,3 +89,10 @@ cd ..
cd make-3.80
kaem --file ../make-3.80.kaem
cd ..
+
+# Part 14: bzip2
+/after/bin/gunzip bzip2-1.0.8.tar.gz
+/after/bin/tar xf bzip2-1.0.8.tar
+cd bzip2-1.0.8
+kaem --file ../bzip2-1.0.8.kaem
+cd ..
diff --git a/sysa/bzip2-1.0.8.kaem b/sysa/bzip2-1.0.8.kaem
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -ex
+
+/after/bin/patch -Np0 -i ../patches/bzip2-1.0.8/bzip2-1.0.8.patch
+/after/bin/make CC=tcc AR="tcc -ar" bzip2
+
+# Install
+/after/bin/cp bzip2 /after/bin/bzip2
+/after/bin/chmod 755 /after/bin/bzip2
+
+# Test
+/after/bin/bzip2 --help
diff --git a/sysa/patches/bzip2-1.0.8/bzip2-1.0.8.patch b/sysa/patches/bzip2-1.0.8/bzip2-1.0.8.patch
@@ -0,0 +1,61 @@
+diff -r -N -U3 bzip2-1.0.8/bzip2.c bzip2-1.0.8/bzip2.c
+--- bzip2.c 2019-07-13 18:50:05.000000000 +0100
++++ bzip2.c 2021-01-14 14:11:40.160213521 +0000
+@@ -1051,12 +1051,13 @@
+ {
+ # if BZ_UNIX
+ IntNative retVal;
+- struct utimbuf uTimBuf;
++ //struct utimbuf uTimBuf;
+
+- uTimBuf.actime = fileMetaInfo.st_atime;
+- uTimBuf.modtime = fileMetaInfo.st_mtime;
++ //uTimBuf.actime = fileMetaInfo.st_atime;
++ //uTimBuf.modtime = fileMetaInfo.st_mtime;
+
+- retVal = utime ( dstName, &uTimBuf );
++ //retVal = utime ( dstName, &uTimBuf );
++ retVal = 0;
+ ERROR_IF_NOT_ZERO ( retVal );
+ # endif
+ }
+diff -r -N -U3 bzip2-1.0.8/Makefile bzip2-1.0.8/Makefile
+--- Makefile 2019-07-13 18:50:05.000000000 +0100
++++ Makefile 2021-01-14 15:45:17.558516299 +0000
+@@ -21,7 +21,7 @@
+ LDFLAGS=
+
+ BIGFILES=-D_FILE_OFFSET_BITS=64
+-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
++CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) -I .
+
+ # Where you want it installed when you do 'make install'
+ PREFIX=/usr/local
+@@ -44,13 +44,7 @@
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
+
+ libbz2.a: $(OBJS)
+- rm -f libbz2.a
+ $(AR) cq libbz2.a $(OBJS)
+- @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
+- -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \
+- echo $(RANLIB) libbz2.a ; \
+- $(RANLIB) libbz2.a ; \
+- fi
+
+ check: test
+ test: bzip2
+@@ -114,7 +108,6 @@
+ sample1.tst sample2.tst sample3.tst
+
+ blocksort.o: blocksort.c
+- @cat words0
+ $(CC) $(CFLAGS) -c blocksort.c
+ huffman.o: huffman.c
+ $(CC) $(CFLAGS) -c huffman.c
+diff -r -N -U3 bzip2-1.0.8/utime.h bzip2-1.0.8/utime.h
+--- utime.h 1970-01-01 01:00:00.000000000 +0100
++++ utime.h 2021-01-14 18:11:11.253825037 +0000
+@@ -0,0 +1,2 @@
++#define fchown(filedes, owner, group) 0
++#define fchmod(filedes, mode) 0