kevinlu1248 / armbian-build

The Armbian Linux Build Framework under Kreyren's Management
GNU General Public License v2.0
0 stars 0 forks source link

Sweep (map): Get rid of 'x-hack' such as [ “x$var” = “xval” ] from the code #91

Open kevinlu1248 opened 10 months ago

kevinlu1248 commented 10 months ago

x-hack is a shell/bash conditional using any letter (often 'x' thus the 'x-hack' name) followed by variable declaration ${var} and checking against the same letter followed by value such as:

# bash
[[ “x$var” == “xval” ]]

# POSIX shell
[ “x$var” = “xval” ]

This was done to ensure compatibility across different shells and systems many years ago, but today it's obsolete as the shells evolved enough to be more reliable.

That said the armbian codebase is still using them for some reason and it was agreed that these should be replaced so i want you to look through the codebase and fix all x-hacks.

Note that the declaration can also be written without quotes:

[ x$var = xval ]

Or even checking for a directory:

[ x$var = xval/ ]

The following files alll have issues with x-hacks, try to address it.

Partition the following list of files into 11 issues editing 8 files each

./packages/blobs/grub/09_linux_with_dtb.sh ./packages/bsp/nanopim4/nanopim4-pwm-fan.sh ./lib/tools/shellcheck.sh ./lib/functions/artifacts/artifact-armbian-bsp-cli.sh ./lib/functions/artifacts/artifact-firmware.sh ./lib/functions/rootfs/distro-specific.sh ./lib/functions/artifacts/artifacts-obtain.sh ./lib/functions/artifacts/artifacts-reversion.sh ./lib/functions/artifacts/artifact-uboot.sh ./lib/functions/artifacts/artifact-armbian-base-files.sh ./lib/functions/cli/entrypoint.sh ./lib/functions/artifacts/artifact-rootfs.sh ./lib/functions/artifacts/artifact-kernel.sh ./lib/functions/cli/commands.sh ./lib/functions/artifacts/artifact-full_firmware.sh ./lib/functions/cli/utils-cli.sh ./lib/functions/main/config-prepare.sh ./lib/functions/main/start-end.sh ./lib/functions/artifacts/artifact-fake-ubuntu-advantage-tools.sh ./lib/functions/cli/cli-patch.sh ./lib/functions/artifacts/artifact-armbian-zsh.sh ./lib/functions/rootfs/distro-agnostic.sh ./lib/functions/main/build-packages.sh ./lib/functions/artifacts/artifact-armbian-plymouth-theme.sh ./lib/functions/cli/cli-distccd.sh ./lib/functions/artifacts/artifact-armbian-desktop.sh ./lib/functions/cli/cli-configdump.sh ./lib/functions/artifacts/artifact-armbian-config.sh ./lib/functions/artifacts/artifact-armbian-bsp-desktop.sh ./lib/functions/logging/trap-logging.sh ./lib/functions/logging/traps.sh ./lib/functions/rootfs/create-cache.sh ./lib/functions/rootfs/rootfs-create.sh ./lib/functions/image/partitioning.sh ./lib/functions/image/initrd.sh ./lib/functions/image/rootfs-to-image.sh ./lib/functions/logging/runners.sh ./lib/functions/image/loop.sh ./lib/functions/logging/logging.sh ./lib/functions/logging/export-logs.sh ./lib/functions/logging/debug-dump.sh ./lib/functions/image/compress-checksum.sh ./lib/functions/logging/capture.sh ./lib/functions/host/host-utils.sh ./lib/functions/compilation/kernel-debs.sh ./extensions/grub-sbc-media.sh ./lib/functions/compilation/uboot.sh ./extensions/lsmod.sh ./extensions/nomod.sh ./extensions/nvidia.sh ./extensions/v4l2loopback-dkms.sh ./extensions/zfs.sh ./lib/functions/compilation/utils-compilation.sh ./lib/functions/compilation/kernel-make.sh ./lib/functions/compilation/kernel.sh ./extensions/grub.sh ./lib/functions/general/git-ref2info.sh ./lib/functions/general/apt-utils.sh ./extensions/gen-sample-extension-docs.sh ./lib/functions/general/shellcheck.sh ./lib/functions/general/python-tools.sh ./lib/functions/general/memoize-cached.sh ./lib/functions/general/oci-oras.sh ./lib/functions/compilation/patch/drivers-harness.sh ./lib/functions/general/hash-files.sh ./lib/functions/compilation/packages/utils-dpkgdeb.sh ./lib/functions/compilation/patch/patching.sh ./lib/functions/host/wsl2.sh ./lib/functions/compilation/distcc.sh ./lib/functions/host/prepare-host.sh ./lib/functions/compilation/crust.sh ./lib/functions/general/downloads.sh ./lib/functions/bsp/armbian-bsp-cli-deb.sh ./lib/functions/general/git.sh ./lib/functions/configuration/menu.sh ./lib/functions/host/docker.sh ./lib/functions/configuration/main-config.sh ./lib/functions/host/tmpfs-utils.sh ./lib/functions/host/mktemp-utils.sh ./lib/functions/compilation/atf.sh ./lib/functions/configuration/interactive.sh ./lib/functions/configuration/config-desktop.sh ./lib/functions/compilation/armbian-kernel.sh ./lib/functions/general/chroot-helpers.sh ./lib/functions/general/extensions.sh ./lib/functions/configuration/package-lists.sh


Checklist:

**Replace 'x-hack' in extensions and lib/functions/artifacts files** * In extensions/nvidia.sh, replace all instances of 'x-hack' with a modern approach * In extensions/v4l2loopback-dkms.sh, replace all instances of 'x-hack' with a modern approach * In extensions/grub.sh, replace all instances of 'x-hack' with a modern approach * In extensions/nomod.sh, replace all instances of 'x-hack' with a modern approach * In extensions/zfs.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifact-armbian-bsp-cli.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifact-firmware.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifacts-obtain.sh, replace all instances of 'x-hack' with a modern approach
**Replace 'x-hack' in lib/functions/cli and lib/functions/logging files** * In lib/functions/cli/entrypoint.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/commands.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-patch.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-distccd.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-configdump.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/trap-logging.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/traps.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/runners.sh, replace all instances of 'x-hack' with a modern approach
sweep-nightly[bot] commented 10 months ago
Sweeping

100%
💎 Sweep Pro: I'm creating this ticket using GPT-4. You have unlimited GPT-4 tickets.

Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/extensions/nvidia.sh#L1-L19 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/extensions/v4l2loopback-dkms.sh#L1-L15 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/extensions/grub.sh#L1-L285 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/extensions/nomod.sh#L1-L9 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/extensions/zfs.sh#L1-L15

Step 2: ⌨️ Coding

I'm creating the following subissues:

Replace 'x-hack' in extensions and lib/functions/artifacts files:

* In extensions/nvidia.sh, replace all instances of 'x-hack' with a modern approach * In extensions/v4l2loopback-dkms.sh, replace all instances of 'x-hack' with a modern approach * In extensions/grub.sh, replace all instances of 'x-hack' with a modern approach * In extensions/nomod.sh, replace all instances of 'x-hack' with a modern approach * In extensions/zfs.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifact-armbian-bsp-cli.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifact-firmware.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/artifacts/artifacts-obtain.sh, replace all instances of 'x-hack' with a modern approach

Replace 'x-hack' in lib/functions/cli and lib/functions/logging files:

* In lib/functions/cli/entrypoint.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/commands.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-patch.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-distccd.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/cli/cli-configdump.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/trap-logging.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/traps.sh, replace all instances of 'x-hack' with a modern approach * In lib/functions/logging/runners.sh, replace all instances of 'x-hack' with a modern approach

Step 3: 🔁 Code Review

I finished creating the subissues! Track them at:


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord