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 #11

Open kevinlu1248 opened 1 year ago

kevinlu1248 commented 1 year 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

Break the following 15 files into 3 issues editing 5 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


Checklist:

**Replace x-hack in packages and lib/tools** * In packages/blobs/grub/09_linux_with_dtb.sh, replace all instances of the 'x-hack' with a more modern approach. * In packages/bsp/nanopim4/nanopim4-pwm-fan.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/tools/shellcheck.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-armbian-bsp-cli.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-firmware.sh, replace all instances of the 'x-hack' with a more modern approach.
**Replace x-hack in lib/functions/rootfs and lib/functions/artifacts** * In lib/functions/rootfs/distro-specific.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifacts-obtain.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifacts-reversion.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-uboot.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-armbian-base-files.sh, replace all instances of the 'x-hack' with a more modern approach.
**Replace x-hack in lib/functions/cli and lib/functions/artifacts** * In lib/functions/cli/entrypoint.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/cli/commands.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-rootfs.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-kernel.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-full_firmware.sh, replace all instances of the 'x-hack' with a more modern approach.
sweep-nightly[bot] commented 1 year 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/packages/bsp/nanopim4/nanopim4-pwm-fan.sh#L1-L487 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/packages/blobs/grub/09_linux_with_dtb.sh#L1-L455 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/lib/tools/shellcheck.sh#L1-L146 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/lib/functions/artifacts/artifact-full_firmware.sh#L1-L106 https://github.com/kevinlu1248/armbian-build/blob/99739036af474f625072a7cd57cfbbc24843c561/lib/functions/artifacts/artifact-kernel.sh#L1-L265

Step 2: ⌨️ Coding

I'm creating the following subissues:

Replace x-hack in packages and lib/tools:

* In packages/blobs/grub/09_linux_with_dtb.sh, replace all instances of the 'x-hack' with a more modern approach. * In packages/bsp/nanopim4/nanopim4-pwm-fan.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/tools/shellcheck.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-armbian-bsp-cli.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-firmware.sh, replace all instances of the 'x-hack' with a more modern approach.

Replace x-hack in lib/functions/rootfs and lib/functions/artifacts:

* In lib/functions/rootfs/distro-specific.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifacts-obtain.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifacts-reversion.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-uboot.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-armbian-base-files.sh, replace all instances of the 'x-hack' with a more modern approach.

Replace x-hack in lib/functions/cli and lib/functions/artifacts:

* In lib/functions/cli/entrypoint.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/cli/commands.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-rootfs.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-kernel.sh, replace all instances of the 'x-hack' with a more modern approach. * In lib/functions/artifacts/artifact-full_firmware.sh, replace all instances of the 'x-hack' with a more 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