Skip to content

Commit

Permalink
bsdtar_win (#9)
Browse files Browse the repository at this point in the history
add lzma support to linux version
move current_tool to environment settings
  • Loading branch information
hemnstill authored Mar 5, 2022
1 parent da5d270 commit 727cf70
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 16 deletions.
89 changes: 80 additions & 9 deletions .github/workflows/ci-test-run.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: ci build

on: [pull_request]

env:
CURRENT_TOOL: 'far2l'
on: [pull_request, workflow_dispatch]

jobs:
prejob:
runs-on: ubuntu-latest
environment: release
outputs:
tool: ${{ steps.setvar.outputs.envvar }}
steps:
- id: setvar
run: echo "::set-output name=envvar::$CURRENT_TOOL"
run: |
echo ${{ secrets._CURRENT_TOOL }} > CI_ENV
echo "::set-output name=envvar::$(sed -e 's/^_//' CI_ENV)"
- run: echo CURRENT_TOOL '${{ steps.setvar.outputs.envvar }}'

alpine-bsdtar-linux:
bsdtar-alpine-musl:
needs: prejob
if: ${{ needs.prejob.outputs.tool=='bsdtar' }}
runs-on: ubuntu-latest
Expand All @@ -27,11 +28,81 @@ jobs:
apk add --no-cache bash
./bsdtar/build.sh
- uses: actions/upload-artifact@v3
with:
name: bsdtar-alpine-musl
path: |
./bsdtar/release/_musl.tar.gz
bsdtar-windows-mingw:
needs: prejob
if: ${{ needs.prejob.outputs.tool=='bsdtar' }}
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: build
id: build
shell: cmd
run: .tools\busybox64.exe sh bsdtar\build_mingw.sh

- uses: actions/upload-artifact@v3
with:
name: bsdtar-windows-mingw
path: |
./bsdtar/release/_mingw.tar.gz
bsdtar-alpine-test:
needs: bsdtar-alpine-musl
runs-on: ubuntu-latest
container: alpine:3.15.0
steps:
- uses: actions/download-artifact@v2
with:
name: bsdtar-alpine-musl
path: .

- name: Test musl build on Alpine
run: |
tar -xf ./_musl.tar.gz
./bsdtar --version
bsdtar-windows-test:
needs: bsdtar-windows-mingw
runs-on: windows-2022
steps:
- uses: actions/download-artifact@v2
with:
name: bsdtar-windows-mingw
path: .

- name: Test mingw build on Windows
shell: cmd
run: |
tar -xf .\_mingw.tar.gz
.\bsdtar.exe --version
bsdtar-release:
runs-on: ubuntu-latest
needs: [bsdtar-alpine-test, bsdtar-windows-test]
steps:
- uses: actions/download-artifact@v2
with:
name: bsdtar-alpine-musl
path: .
- uses: actions/download-artifact@v2
with:
name: bsdtar-windows-mingw
path: .
- run: |
tar -xf ./_musl.tar.gz
tar -xf ./_mingw.tar.gz
cat _musl.md >> body.md
cat _mingw.md >> body.md
- uses: ncipollo/release-action@v1
with:
tag: '${{ steps.build.outputs.tool_name }}-${{ steps.build.outputs.tool_version }}'
bodyFile: './bsdtar/release/body.md'
artifacts: './bsdtar/release/${{ steps.build.outputs.tool_name }}'
tag: 'bsdtar-3.5.1'
artifacts: './bsdtar*'
bodyFile: './body.md'
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
Binary file added .tools/busybox64.exe
Binary file not shown.
19 changes: 12 additions & 7 deletions bsdtar/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
echo "::group::install deps"

apk update
apk add --no-cache alpine-sdk zlib-dev bzip2-dev zlib-static bzip2-static
apk add --no-cache alpine-sdk zlib-dev bzip2-dev zlib-static bzip2-static xz-dev

echo "::endgroup::"

Expand All @@ -27,7 +27,9 @@ echo "::group::build"

./configure LDFLAGS='--static' --enable-bsdtar=static --disable-shared --disable-bsdcpio --disable-bsdcat
make -j$(nproc)
gcc -static -o "../$tool_name" \

mkdir "$dp0/release/build"
gcc -static -o "$dp0/release/build/$tool_name" \
tar/bsdtar-bsdtar.o \
tar/bsdtar-cmdline.o \
tar/bsdtar-creation_set.o \
Expand All @@ -38,17 +40,20 @@ gcc -static -o "../$tool_name" \
.libs/libarchive.a \
.libs/libarchive_fe.a \
/lib/libz.a \
/usr/lib/libbz2.a
/usr/lib/libbz2.a \
/usr/lib/liblzma.a

echo "::endgroup::"

cd "$dp0/release"
cd "$dp0/release/build"
strip "$tool_name"
chmod +x "$tool_name"

{ printf 'SHA-256: %s
%s
%s' "$(sha256sum < $tool_name)" "$("./$tool_name" --version)" "$download_url"
} > body.md
' "$(sha256sum $tool_name)" "$("./$tool_name" --version)"
} > _musl.md

cat _musl.md

cat body.md
tar -czvf ../_musl.tar.gz .
42 changes: 42 additions & 0 deletions bsdtar/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
set -e

tool_name="bsdtar.exe"
tool_version="3.5.1"
echo "::set-output name=tool_name::$tool_name"
echo "::set-output name=tool_version::$tool_version"

download_url="https://github.com/libarchive/libarchive/releases/download/v$tool_version/libarchive-$tool_version.tar.gz"
echo "::group::prepare sources $download_url"

mkdir -p "$dp0/release" && cd "$dp0/release"
wget "$download_url" -O "libarchive-$tool_version.tar.gz"
tar -xf "libarchive-$tool_version.tar.gz" && cd "libarchive-$tool_version"

wget "https://github.com/libarchive/libarchive/raw/v$tool_version/build/ci/github_actions/ci.cmd" -O "$dp0/ci.cmd"

echo "::endgroup::"

echo "::group::build"

export BE=mingw-gcc

"$dp0/ci.cmd" deplibs
"$dp0/ci.cmd" configure
"$dp0/ci.cmd" build

echo "::endgroup::"

mkdir "$dp0/release/build" && cd "$dp0/release/build"
cp -f "$dp0/release/libarchive-$tool_version/build_ci/cmake/bin/$tool_name" "."

{ printf 'SHA-256: %s
%s
%s
' "$(sha256sum $tool_name)" "$("./$tool_name" --version)" "$download_url"
} > _mingw.md

cat _mingw.md

tar -czvf ../_mingw.tar.gz .

0 comments on commit 727cf70

Please sign in to comment.