Skip to content

Commit 1c88bc8

Browse files
authored
Merge pull request #1530 from @rivy (create publishable coreutils)
Change ~ create a publishable version of `coreutils`
2 parents d9de816 + bf8353c commit 1c88bc8

File tree

445 files changed

+4422
-3457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+4422
-3457
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# spell-checker:words POSIX SDK SDKs repo toolchain toolchains
2-
# spell-checker:ignore ABI ARCH BACKTRACE BINDIR COMNTOOLS MINGW MINGWDIR MSVC MSYS USERPROFILE cl dllcrt findstr maint mkdir rustc rustlib rustup targetting uutils vcvarsall
2+
# spell-checker:ignore ABI ARCH BACKTRACE BINDIR COMNTOOLS MINGW MINGWDIR MSVC MSYS USERPROFILE cl dllcrt findstr maint mkdir rustc rustlib rustup uutils vcvarsall
33

44
version: "{build} ~ {branch}"
55

.github/workflows/CICD.yml

+71-27
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ name: CICD
44
# spell-checker:ignore (env/flags) Ccodegen Coverflow RUSTFLAGS
55
# spell-checker:ignore (jargon) SHAs deps softprops toolchain
66
# spell-checker:ignore (names) CodeCOV MacOS MinGW Peltoche rivy
7-
# spell-checker:ignore (shell/tools) choco clippy dmake esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
8-
# spell-checker:ignore (misc) alnum gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
9-
7+
# spell-checker:ignore (shell/tools) choco clippy dmake dpkg esac fakeroot gmake grcov halium lcov libssl mkdir popd printf pushd rustc rustfmt rustup shopt xargs
8+
# spell-checker:ignore (misc) aarch alnum armhf coreutils gnueabihf issuecomment maint nullglob onexitbegin onexitend uutils
109

1110
env:
12-
PROJECT_NAME: uutils
13-
PROJECT_DESC: "'Universal' (cross-platform) CLI utilities"
11+
PROJECT_NAME: coreutils
12+
PROJECT_DESC: "Core universal (cross-platform) utilities"
1413
PROJECT_AUTH: "uutils"
1514
RUST_MIN_SRV: "1.31.0" ## v1.31.0 == "Rust 2018" (2018-12-06)
1615
RUST_COV_SRV: "2020-04-29" ## (~v1.45.0) supported rust version for code coverage; (date required/used by 'coverage') ## !maint: refactor when code coverage support is included in the stable channel
@@ -35,11 +34,6 @@ jobs:
3534
shell: bash
3635
run: |
3736
## VARs setup
38-
# #maint: [rivy; 2020-02-08] 'windows-latest' `cargo fmt` is bugged for this project (see reasons @ GH:rust-lang/rustfmt #3324, #3590, #3688 ; waiting for repair)
39-
JOB_DO_FORMAT_TESTING="true"
40-
case '${{ matrix.job.os }}' in windows-latest) unset JOB_DO_FORMAT_TESTING ;; esac;
41-
echo set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING:-<empty>/false}
42-
echo ::set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING}
4337
# target-specific options
4438
# * CARGO_FEATURES_OPTION
4539
CARGO_FEATURES_OPTION='' ;
@@ -54,14 +48,12 @@ jobs:
5448
profile: minimal # minimal component installation (ie, no documentation)
5549
components: rustfmt, clippy
5650
- name: "`fmt` testing"
57-
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
5851
shell: bash
5952
run: |
6053
# `fmt` testing
6154
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
6255
S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; }
6356
- name: "`fmt` testing of tests"
64-
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
6557
shell: bash
6658
run: |
6759
# `fmt` testing of tests
@@ -130,7 +122,10 @@ jobs:
130122
job:
131123
# { os, target, cargo-options, features, use-cross, toolchain }
132124
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross }
125+
- { os: ubuntu-latest , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf , use-cross: use-cross }
133126
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
127+
# - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
128+
# - { os: ubuntu-18.04 , target: i586-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross } ## note: older windows platform; not required, dev-FYI only
134129
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
135130
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
136131
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , features: feat_os_unix , use-cross: use-cross }
@@ -148,6 +143,7 @@ jobs:
148143
## install/setup prerequisites
149144
case '${{ matrix.job.target }}' in
150145
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
146+
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
151147
esac
152148
- name: Initialize workflow variables
153149
id: vars
@@ -186,7 +182,14 @@ jobs:
186182
echo ::set-output name=REF_TAG::${REF_TAG}
187183
echo ::set-output name=REF_SHAS::${REF_SHAS}
188184
# parse target
189-
unset TARGET_ARCH ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
185+
unset TARGET_ARCH
186+
case '${{ matrix.job.target }}' in
187+
aarch64-*) TARGET_ARCH=arm64 ;;
188+
arm-*-*hf) TARGET_ARCH=armhf ;;
189+
i586-*) TARGET_ARCH=i586 ;;
190+
i686-*) TARGET_ARCH=i686 ;;
191+
x86_64-*) TARGET_ARCH=x86_64 ;;
192+
esac;
190193
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
191194
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
192195
unset TARGET_OS ; case '${{ matrix.job.target }}' in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
@@ -203,9 +206,34 @@ jobs:
203206
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
204207
echo ::set-output name=PKG_NAME::${PKG_NAME}
205208
# deployable tag? (ie, leading "vM" or "M"; M == version number)
206-
unset DEPLOYABLE ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOYABLE='true' ; fi
207-
echo set-output name=DEPLOYABLE::${DEPLOYABLE:-<empty>/false}
208-
echo ::set-output name=DEPLOYABLE::${DEPLOYABLE}
209+
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
210+
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
211+
echo ::set-output name=DEPLOY::${DEPLOY}
212+
# DPKG architecture?
213+
unset DPKG_ARCH
214+
case ${{ matrix.job.target }} in
215+
x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
216+
*-linux-*) DPKG_ARCH=${TARGET_ARCH} ;;
217+
esac
218+
echo set-output name=DPKG_ARCH::${DPKG_ARCH}
219+
echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
220+
# DPKG version?
221+
unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
222+
echo set-output name=DPKG_VERSION::${DPKG_VERSION}
223+
echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
224+
# DPKG base name/conflicts?
225+
DPKG_BASENAME=${PROJECT_NAME}
226+
DPKG_CONFLICTS=${PROJECT_NAME}-musl
227+
case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;
228+
echo set-output name=DPKG_BASENAME::${DPKG_BASENAME}
229+
echo set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
230+
echo ::set-output name=DPKG_BASENAME::${DPKG_BASENAME}
231+
echo ::set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
232+
# DPKG name
233+
unset DPKG_NAME;
234+
if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
235+
echo set-output name=DPKG_NAME::${DPKG_NAME}
236+
echo ::set-output name=DPKG_NAME::${DPKG_NAME}
209237
# target-specific options
210238
# * CARGO_FEATURES_OPTION
211239
CARGO_FEATURES_OPTION='' ;
@@ -216,18 +244,17 @@ jobs:
216244
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
217245
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
218246
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
219-
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
220-
JOB_DO_TESTING="true"
221-
case '${{ matrix.job.target }}' in arm-*) unset JOB_DO_TESTING ;; esac;
222-
echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
223-
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
224-
# # * test only binary for arm-type targets
225-
unset CARGO_TEST_OPTIONS
226-
unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in arm-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
247+
# * test only library and/or binaries for arm-type targets
248+
unset CARGO_TEST_OPTIONS ; case '${{ matrix.job.target }}' in aarch64-* | arm-*) CARGO_TEST_OPTIONS="--bins" ;; esac;
227249
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
228250
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
229-
# * strip executable?
230-
STRIP="strip" ; case '${{ matrix.job.target }}' in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
251+
# * executable for `strip`?
252+
STRIP="strip"
253+
case ${{ matrix.job.target }} in
254+
aarch64-*-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
255+
arm-*-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;;
256+
*-pc-windows-msvc) STRIP="" ;;
257+
esac;
231258
echo set-output name=STRIP::${STRIP:-<empty>/false}
232259
echo ::set-output name=STRIP::${STRIP}
233260
- name: Create all needed build/work directories
@@ -236,6 +263,7 @@ jobs:
236263
## create build/work space
237264
mkdir -p '${{ steps.vars.outputs.STAGING }}'
238265
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
266+
mkdir -p '${{ steps.vars.outputs.STAGING }}/dpkg'
239267
- name: rust toolchain ~ install
240268
uses: actions-rs/toolchain@v1
241269
with:
@@ -307,12 +335,28 @@ jobs:
307335
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
308336
esac
309337
popd >/dev/null
338+
# dpkg
339+
if [ -n "${{ steps.vars.outputs.DPKG_NAME }}" ]; then
340+
DPKG_DIR="${{ steps.vars.outputs.STAGING }}/dpkg"
341+
# binary
342+
install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}"
343+
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
344+
# README and LICENSE
345+
(shopt -s nullglob; for f in [R]"EADME"{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
346+
(shopt -s nullglob; for f in [L]"ICENSE"{-*,}{,.*}; do install -Dm644 "$f" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/$f" ; done)
347+
# control file
348+
mkdir -p "${DPKG_DIR}/DEBIAN"
349+
printf "Package: ${{ steps.vars.outputs.DPKG_BASENAME }}\nVersion: ${{ steps.vars.outputs.DPKG_VERSION }}\nSection: utils\nPriority: optional\nMaintainer: ${{ env.PROJECT_AUTH }}\nArchitecture: ${{ steps.vars.outputs.DPKG_ARCH }}\nProvides: ${{ env.PROJECT_NAME }}\nConflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}\nDescription: ${{ env.PROJECT_DESC }}\n" > "${DPKG_DIR}/DEBIAN/control"
350+
# build dpkg
351+
fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
352+
fi
310353
- name: Publish
311354
uses: softprops/action-gh-release@v1
312-
if: steps.vars.outputs.DEPLOYABLE
355+
if: steps.vars.outputs.DEPLOY
313356
with:
314357
files: |
315358
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
359+
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
316360
env:
317361
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
318362

0 commit comments

Comments
 (0)