From a0e23f216495b87227f99b1567064f72ddacc1da Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 15:28:53 -0400 Subject: [PATCH 1/8] common/scripts/template_shellcheck_shim: create shim for xshellcheck --- common/scripts/template_shellcheck_shim | 398 ++++++++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 common/scripts/template_shellcheck_shim diff --git a/common/scripts/template_shellcheck_shim b/common/scripts/template_shellcheck_shim new file mode 100644 index 000000000000..48932d19dbca --- /dev/null +++ b/common/scripts/template_shellcheck_shim @@ -0,0 +1,398 @@ +#!/bin/bash +# this file is for use by xshellcheck from xtools +# +# by assigning and using every variable templates should contain, +# it suppresses SC2034 (unused variable) and SC2154 (possibly unassigned +# variable). set -e suppresses errors like SC2164 (use cd ... || exit). + +set -e + +# TODO: do other variables need handling? +# _* +# *_descr +# *_groups +# *_homedir +# *_pgroup +# *_shell +# desc_option_* +# build_option_* + +# global variables +CHROOT_READY= +CROSS_BUILD= +DESTDIR= +FILESDIR= +PKGDESTDIR= +XBPS_BUILDDIR= +XBPS_BUILD_ENVIRONMENT= +XBPS_CHECK_PKGS= +XBPS_CROSS_BASE= +XBPS_ENDIAN= +XBPS_FETCH_CMD= +XBPS_LIBC= +XBPS_MACHINE= +XBPS_MAKEJOBS= +XBPS_NO_ATOMIC8= +XBPS_RUST_TARGET= +XBPS_SRCDISTDIR= +XBPS_SRCPKGDIR= +XBPS_TARGET_ENDIAN= +XBPS_TARGET_LIBC= +XBPS_TARGET_MACHINE= +XBPS_TARGET_NO_ATOMIC8= +XBPS_TARGET_WORDSIZE= +XBPS_WORDSIZE= +XBPS_WRAPPERDIR= +makejobs= +sourcepkg= + +# toolchain variables +AR= +AS= +CC= +CFLAGS= +CPP= +CPPFLAGS= +CXX= +CXXFLAGS= +GCC= +LD= +LDFLAGS= +LD_LIBRARY_PATH= +NM= +OBJCOPY= +OBJDUMP= +RANLIB= +READELF= +STRIP= + +# available variables +allow_unknown_shlibs= +alternatives= +archs= +binfmts= +bootstrap= +broken= +build_helper= +build_options= +build_options_default= +build_style= +build_wrksrc= +changelog= +checkdepends= +checksum= +conf_files= +configure_args= +configure_script= +conflicts= +create_wrksrc= +depends= +disable_parallel_build= +disable_parallel_check= +distfiles= +dkms_modules= +fetch_cmd= +font_dirs= +force_debug_pkgs= +gconf_entries= +gconf_schemas= +homepage= +hostmakedepends= +ignore_elf_dirs= +ignore_elf_files= +keep_libtool_archives= +kernel_hooks_version= +lib32depends= +lib32disabled= +lib32files= +lib32mode= +lib32symlinks= +license= +maintainer= +make_build_args= +make_build_target= +make_check= +make_check_args= +make_check_pre= +make_check_target= +make_cmd= +make_dirs= +make_install_args= +make_install_target= +make_use_env= +makedepends= +mutable_files= +no_generic_pkgconfig_link= +nocheckperms= +nocross= +nodebug= +nofixperms= +nopie= +nopie_files= +noshlibprovides= +nostrip= +nostrip_files= +noverifyrdeps= +patch_args= +perl_configure_dirs= +pkgname= +preserve= +provides= +register_shell= +replaces= +repository= +restricted= +reverts= +revision= +sgml_entries= +shlib_provides= +shlib_requires= +short_desc= +skip_extraction= +skiprdeps= +subpackages= +system_accounts= +system_groups= +tags= +triggers= +version= +wrksrc= +xml_catalogs= +xml_entries= + +# go +go_build_tags= +go_import_path= +go_ldflags= +go_mod_mode= +go_package= + +# cmake +cmake_builddir= + +# gemspec +gem_cmd= + +# haskell-stack +stackage= + +# meson +meson_builddir= +meson_cmd= +meson_crossfile= + +# python* +py2_inc= +py2_lib= +py2_sitelib= +py2_ver= +py3_inc= +py3_lib= +py3_sitelib= +py3_ver= +pycompile_dirs= +pycompile_module= +python_version= + +# void-cross +cross_binutils_configure_args= +cross_gcc_bootstrap_configure_args= +cross_gcc_configure_args= +cross_gcc_skip_go= +cross_glibc_cflags= +cross_glibc_configure_args= +cross_glibc_ldflags= +cross_musl_cflags= +cross_musl_configure_args= +cross_musl_ldflags= + +. template + +# global variables +: "$CHROOT_READY" +: "$CROSS_BUILD" +: "$DESTDIR" +: "$FILESDIR" +: "$PKGDESTDIR" +: "$XBPS_BUILDDIR" +: "$XBPS_BUILD_ENVIRONMENT" +: "$XBPS_CHECK_PKGS" +: "$XBPS_CROSS_BASE" +: "$XBPS_ENDIAN" +: "$XBPS_FETCH_CMD" +: "$XBPS_LIBC" +: "$XBPS_MACHINE" +: "$XBPS_MAKEJOBS" +: "$XBPS_NO_ATOMIC8" +: "$XBPS_RUST_TARGET" +: "$XBPS_SRCDISTDIR" +: "$XBPS_SRCPKGDIR" +: "$XBPS_TARGET_ENDIAN" +: "$XBPS_TARGET_LIBC" +: "$XBPS_TARGET_MACHINE" +: "$XBPS_TARGET_NO_ATOMIC8" +: "$XBPS_TARGET_WORDSIZE" +: "$XBPS_WORDSIZE" +: "$XBPS_WRAPPERDIR" +: "$makejobs" +: "$sourcepkg" + +# toolchain variables +: "$AR" +: "$AS" +: "$CC" +: "$CFLAGS" +: "$CPP" +: "$CPPFLAGS" +: "$CXX" +: "$CXXFLAGS" +: "$GCC" +: "$LD" +: "$LDFLAGS" +: "$LD_LIBRARY_PATH" +: "$NM" +: "$OBJCOPY" +: "$OBJDUMP" +: "$RANLIB" +: "$READELF" +: "$STRIP" + +# available variables +: "$allow_unknown_shlibs" +: "$alternatives" +: "$archs" +: "$binfmts" +: "$bootstrap" +: "$broken" +: "$build_helper" +: "$build_options" +: "$build_options_default" +: "$build_style" +: "$build_wrksrc" +: "$changelog" +: "$checkdepends" +: "$checksum" +: "$conf_files" +: "$configure_args" +: "$configure_script" +: "$conflicts" +: "$create_wrksrc" +: "$depends" +: "$disable_parallel_build" +: "$disable_parallel_check" +: "$distfiles" +: "$dkms_modules" +: "$fetch_cmd" +: "$font_dirs" +: "$force_debug_pkgs" +: "$gconf_entries" +: "$gconf_schemas" +: "$homepage" +: "$hostmakedepends" +: "$ignore_elf_dirs" +: "$ignore_elf_files" +: "$keep_libtool_archives" +: "$kernel_hooks_version" +: "$lib32depends" +: "$lib32disabled" +: "$lib32files" +: "$lib32mode" +: "$lib32symlinks" +: "$license" +: "$maintainer" +: "$make_build_args" +: "$make_build_target" +: "$make_check" +: "$make_check_args" +: "$make_check_pre" +: "$make_check_target" +: "$make_cmd" +: "$make_dirs" +: "$make_install_args" +: "$make_install_target" +: "$make_use_env" +: "$makedepends" +: "$mutable_files" +: "$no_generic_pkgconfig_link" +: "$nocheckperms" +: "$nocross" +: "$nodebug" +: "$nofixperms" +: "$nopie" +: "$nopie_files" +: "$noshlibprovides" +: "$nostrip" +: "$nostrip_files" +: "$noverifyrdeps" +: "$patch_args" +: "$perl_configure_dirs" +: "$pkgname" +: "$preserve" +: "$provides" +: "$register_shell" +: "$replaces" +: "$repository" +: "$restricted" +: "$reverts" +: "$revision" +: "$sgml_entries" +: "$shlib_provides" +: "$shlib_requires" +: "$short_desc" +: "$skip_extraction" +: "$skiprdeps" +: "$subpackages" +: "$system_accounts" +: "$system_groups" +: "$tags" +: "$triggers" +: "$version" +: "$wrksrc" +: "$xml_catalogs" +: "$xml_entries" + +# go +: "$go_build_tags" +: "$go_import_path" +: "$go_ldflags" +: "$go_mod_mode" +: "$go_package" + +# cmake +: "$cmake_builddir" + +# gemspec +: "$gem_cmd" + +# haskell-stack +: "$stackage" + +# meson +: "$meson_builddir" +: "$meson_cmd" +: "$meson_crossfile" + +# python* +: "$py2_inc" +: "$py2_lib" +: "$py2_sitelib" +: "$py2_ver" +: "$py3_inc" +: "$py3_lib" +: "$py3_sitelib" +: "$py3_ver" +: "$pycompile_dirs" +: "$pycompile_module" +: "$python_version" + +# void-cross +: "$cross_binutils_configure_args" +: "$cross_gcc_bootstrap_configure_args" +: "$cross_gcc_configure_args" +: "$cross_gcc_skip_go" +: "$cross_glibc_cflags" +: "$cross_glibc_configure_args" +: "$cross_glibc_ldflags" +: "$cross_musl_cflags" +: "$cross_musl_configure_args" +: "$cross_musl_ldflags" From 862c0664bdc3f0bdf55976fc09a52516e28de8ac Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 16:14:14 -0400 Subject: [PATCH 2/8] .github/workflows/build.yaml: install shellcheck for xlint --- .github/workflows/build.yaml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index eb4fb7c85be9..aaaec25053d6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,17 +20,35 @@ jobs: name: Lint templates runs-on: ubuntu-latest - env: - PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' - XLINT: '1' - LICENSE_LIST: common/travis/license.lst + container: + image: 'ghcr.io/void-linux/xbps-src-masterdir:20230425RC01-x86_64' + env: + PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' + LICENSE_LIST: common/travis/license.lst + XSHELLCHECK_ARGS: --color=always steps: + - name: Prepare container + run: | + # switch to repo-ci mirror + mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ + sed -i 's|repo-default|repo-ci|g' /etc/xbps.d/*-repository-*.conf + # Sync and upgrade once, assume error comes from xbps update + xbps-install -Syu || xbps-install -yu xbps + # Upgrade again (in case there was a xbps update) + xbps-install -yu + # install tools needed for lints + xbps-install -y shellcheck grep gawk + xbps-query -l - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 + - name: Create hostrepo and prepare masterdir + run: | + ln -s "$(pwd)" /hostrepo && + common/travis/set_mirror.sh && + common/travis/prepare.sh && + common/travis/fetch-xtools.sh - run: common/travis/changed_templates.sh - - run: common/travis/fetch-xbps.sh - - run: common/travis/fetch-xtools.sh - run: common/travis/xlint.sh # Build changed packages. From be2da53a400a568965116eafa711f5ffbdb7b099 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 16:14:57 -0400 Subject: [PATCH 3/8] common/travis/xlint.sh: run xshellcheck --- common/travis/xlint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/common/travis/xlint.sh b/common/travis/xlint.sh index 790791ef1733..bc12aedd4f8e 100755 --- a/common/travis/xlint.sh +++ b/common/travis/xlint.sh @@ -12,6 +12,7 @@ common/scripts/lint-commits $base $tip || EXITCODE=$? for t in $(awk '{ print "srcpkgs/" $0 "/template" }' /tmp/templates); do /bin/echo -e "\x1b[32mLinting $t...\x1b[0m" xlint "$t" > /tmp/xlint_out || EXITCODE=$? + xshellcheck "$t" || EXITCODE=$? common/scripts/lint-version-change "$t" $base $tip > /tmp/vlint_out || EXITCODE=$? awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out done From 204ff661dd824089049c5b60936bd3d33788773e Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 16:15:17 -0400 Subject: [PATCH 4/8] TEMP: switch xtools fork/branch for xshellcheck --- common/travis/fetch-xtools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/travis/fetch-xtools.sh b/common/travis/fetch-xtools.sh index 0dd9e6c532c0..6795b1afc313 100755 --- a/common/travis/fetch-xtools.sh +++ b/common/travis/fetch-xtools.sh @@ -4,7 +4,7 @@ TAR=tar command -v bsdtar >/dev/null && TAR=bsdtar -URL="https://github.com/leahneukirchen/xtools/archive/master.tar.gz" +URL="https://github.com/classabbyamp/xtools/archive/xshellcheck.tar.gz" FILE="xtools.tar.gz" mkdir -p /tmp/bin From 1eebbd39d2bac582f18a830c02a22bab3e34f5a1 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 16:16:23 -0400 Subject: [PATCH 5/8] TEMP: something to shellcheck --- srcpkgs/chezmoi/template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srcpkgs/chezmoi/template b/srcpkgs/chezmoi/template index b7dca806e5f2..e1c63ec6a247 100644 --- a/srcpkgs/chezmoi/template +++ b/srcpkgs/chezmoi/template @@ -14,6 +14,7 @@ homepage="https://chezmoi.io/" changelog="https://github.com/twpayne/chezmoi/releases" distfiles="https://github.com/twpayne/chezmoi/archive/v${version}.tar.gz" checksum=49f624ff55e1fb7165e9bca98aead8d6c49c6ff73926973c6ba6347f0ee17eba +bhasdfhsdf= pre_build() { local _date @@ -32,4 +33,5 @@ post_install() { vcompletion completions/chezmoi-completion.bash bash vcompletion completions/chezmoi.fish fish vcompletion completions/chezmoi.zsh zsh + : $adfsdhfajhsdfjasdf } From 3ef19af87c02408563627403f576e2364f7809f2 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 16:34:56 -0400 Subject: [PATCH 6/8] XLINT no longer needed --- common/travis/prepare.sh | 2 -- common/travis/xlint.sh | 2 -- 2 files changed, 4 deletions(-) diff --git a/common/travis/prepare.sh b/common/travis/prepare.sh index 550fbd7598d0..46072e9f81ea 100755 --- a/common/travis/prepare.sh +++ b/common/travis/prepare.sh @@ -2,8 +2,6 @@ # # prepare.sh -[ "$XLINT" ] && exit 0 - /bin/echo -e '\x1b[32mUpdating etc/conf...\x1b[0m' echo XBPS_BUILD_ENVIRONMENT=void-packages-ci >> etc/conf echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf diff --git a/common/travis/xlint.sh b/common/travis/xlint.sh index bc12aedd4f8e..b9f3333ccef3 100755 --- a/common/travis/xlint.sh +++ b/common/travis/xlint.sh @@ -2,8 +2,6 @@ # # xlint.sh -[ "$XLINT" ] || exit 0 - EXITCODE=0 read base tip < /tmp/revisions From 3c4ef6bfc95ae1f9afeb3df075fbb008ba9eb472 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 18:58:24 -0400 Subject: [PATCH 7/8] temp --- common/travis/xlint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/travis/xlint.sh b/common/travis/xlint.sh index b9f3333ccef3..86da7069aa5f 100755 --- a/common/travis/xlint.sh +++ b/common/travis/xlint.sh @@ -9,9 +9,9 @@ common/scripts/lint-commits $base $tip || EXITCODE=$? for t in $(awk '{ print "srcpkgs/" $0 "/template" }' /tmp/templates); do /bin/echo -e "\x1b[32mLinting $t...\x1b[0m" - xlint "$t" > /tmp/xlint_out || EXITCODE=$? + xlint "$t" || EXITCODE=$? #> /tmp/xlint_out || EXITCODE=$? xshellcheck "$t" || EXITCODE=$? common/scripts/lint-version-change "$t" $base $tip > /tmp/vlint_out || EXITCODE=$? - awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out + # awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out done exit $EXITCODE From 1960e0d260acc4469ea35834d5d264c795eb5827 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 19 May 2023 19:41:13 -0400 Subject: [PATCH 8/8] fixup! .github/workflows/build.yaml: install shellcheck for xlint --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index aaaec25053d6..062ff03fd9d1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,7 +38,7 @@ jobs: # Upgrade again (in case there was a xbps update) xbps-install -yu # install tools needed for lints - xbps-install -y shellcheck grep gawk + xbps-install -y shellcheck grep xbps-query -l - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1