diff mbox series

[v3,1/4] package/bats-support: new package

Message ID 20240503020000.3168109-1-brandon.maier@collins.com
State Accepted
Headers show
Series [v3,1/4] package/bats-support: new package | expand

Commit Message

Brandon Maier May 3, 2024, 1:59 a.m. UTC
This library provides support functions needed by the bats-assert and
bats-file libraries.

This library does not provide an installer. Manually install the files
under /usr/lib/bats/bats-support which is what the Arch Linux package
does[1]. This makes the library loadable using `bats_load_library`[2].

[1] https://gitlab.archlinux.org/archlinux/packaging/packages/bats-support/-/blob/main/PKGBUILD?ref_type=heads
[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html#bats-load-library-load-system-wide-libraries

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
---
v2:
- fix older versions of install that don't support -D with -t

v3:
- fix commit subject to be 'new package'
- switch 'install' to '$(INSTALL)'
- install with 0755 permissions
- remove unneeded quotes
---
 DEVELOPERS                             |  1 +
 package/Config.in                      |  1 +
 package/bats-support/Config.in         |  8 ++++++++
 package/bats-support/bats-support.hash |  5 +++++
 package/bats-support/bats-support.mk   | 18 ++++++++++++++++++
 5 files changed, 33 insertions(+)
 create mode 100644 package/bats-support/Config.in
 create mode 100644 package/bats-support/bats-support.hash
 create mode 100644 package/bats-support/bats-support.mk

Comments

Yann E. MORIN May 5, 2024, 9:21 a.m. UTC | #1
Brandon, All,

On 2024-05-03 01:59 +0000, Brandon Maier via buildroot spake thusly:
> This library provides support functions needed by the bats-assert and
> bats-file libraries.
> 
> This library does not provide an installer. Manually install the files
> under /usr/lib/bats/bats-support which is what the Arch Linux package
> does[1]. This makes the library loadable using `bats_load_library`[2].
> 
> [1] https://gitlab.archlinux.org/archlinux/packaging/packages/bats-support/-/blob/main/PKGBUILD?ref_type=heads
> [2] https://bats-core.readthedocs.io/en/stable/writing-tests.html#bats-load-library-load-system-wide-libraries
> 
> Signed-off-by: Brandon Maier <brandon.maier@collins.com>
> ---
[--SNIP--]
> diff --git a/package/Config.in b/package/Config.in
> index 38e9c94198..f1da714418 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -170,6 +170,7 @@ endmenu
>  menu "Development tools"
>  	source "package/avocado/Config.in"
>  	source "package/bats-core/Config.in"
> +	source "package/bats-support/Config.in"

While this looks like the thing to do, including the bats sub-packages
from here is sub-optimal. Indeed, when all the series is applied, the
menuconfig will look something like:

    [ ] bats-assert (NEW)
    [*] bats
    [ ]   bats-file (NEW)
    [ ]   bats-support (NEW)

This is not very nice-looking.

Instead, I've moved the 'source' statements to the bats-core package
itself (elided for brevity; check the actual package for exact code):

    config BR2_PACKAGE_BATS_CORE
        bool "bats-core"

    if BR2_PACKAGE_BATS_CORE

    source "package/bats-assert/Config.in"
    source "package/bats-file/Config.in"
    source "package/bats-support/Config.in"

    endif

Now the menuconfig looks nicer:

    [*] bats
    [ ]   bats-assert (NEW)
    [ ]   bats-file (NEW)
    [ ]   bats-support (NEW)

As a consequence of the includes now being guarded by the if-endif
conditional block, the dependency on bats-core is no longer needed on
each package, so I also dropped it.

Series applied to master with this little cleanup, thanks!

Regards,
Yann E. MORIN.

>  	source "package/binutils/Config.in"
>  	source "package/bitwise/Config.in"
>  	source "package/bsdiff/Config.in"
> diff --git a/package/bats-support/Config.in b/package/bats-support/Config.in
> new file mode 100644
> index 0000000000..24b49cee1d
> --- /dev/null
> +++ b/package/bats-support/Config.in
> @@ -0,0 +1,8 @@
> +config BR2_PACKAGE_BATS_SUPPORT
> +	bool "bats-support"
> +	depends on BR2_PACKAGE_BATS_CORE # runtime
> +	help
> +	  bats-support is a supporting library providing common
> +	  functions to test helper libraries written for Bats.
> +
> +	  https://github.com/bats-core/bats-support
> diff --git a/package/bats-support/bats-support.hash b/package/bats-support/bats-support.hash
> new file mode 100644
> index 0000000000..847f39e7c7
> --- /dev/null
> +++ b/package/bats-support/bats-support.hash
> @@ -0,0 +1,5 @@
> +# Locally calculated
> +sha256  7815237aafeb42ddcc1b8c698fc5808026d33317d8701d5ec2396e9634e2918f  bats-support-0.3.0.tar.gz
> +
> +# License files
> +sha256  36ffd9dc085d529a7e60e1276d73ae5a030b020313e6c5408593a6ae2af39673  LICENSE
> diff --git a/package/bats-support/bats-support.mk b/package/bats-support/bats-support.mk
> new file mode 100644
> index 0000000000..765e08ffce
> --- /dev/null
> +++ b/package/bats-support/bats-support.mk
> @@ -0,0 +1,18 @@
> +################################################################################
> +#
> +# bats-support
> +#
> +################################################################################
> +
> +BATS_SUPPORT_VERSION = 0.3.0
> +BATS_SUPPORT_SITE = $(call github,bats-core,bats-support,v$(BATS_SUPPORT_VERSION))
> +BATS_SUPPORT_LICENSE = CC0-1.0
> +BATS_SUPPORT_LICENSE_FILES = LICENSE
> +
> +define BATS_SUPPORT_INSTALL_TARGET_CMDS
> +	$(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/lib/bats/bats-support/src
> +	$(INSTALL) -m 0755 $(@D)/*.bash -t $(TARGET_DIR)/usr/lib/bats/bats-support
> +	$(INSTALL) -m 0755 $(@D)/src/*.bash -t $(TARGET_DIR)/usr/lib/bats/bats-support/src
> +endef
> +
> +$(eval $(generic-package))
> -- 
> 2.44.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 5d198567d8..7fc46d6b43 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -540,6 +540,7 @@  F:	package/ncdu/
 N:	Brandon Maier <brandon.maier@collins.com>
 F:	board/freescale/ls1046a-frwy/
 F:	configs/ls1046a-frwy_defconfig
+F:	package/bats-support/
 F:	package/python-pysensors/
 F:	package/qoriq-fm-ucode/
 F:	package/unifdef/
diff --git a/package/Config.in b/package/Config.in
index 38e9c94198..f1da714418 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -170,6 +170,7 @@  endmenu
 menu "Development tools"
 	source "package/avocado/Config.in"
 	source "package/bats-core/Config.in"
+	source "package/bats-support/Config.in"
 	source "package/binutils/Config.in"
 	source "package/bitwise/Config.in"
 	source "package/bsdiff/Config.in"
diff --git a/package/bats-support/Config.in b/package/bats-support/Config.in
new file mode 100644
index 0000000000..24b49cee1d
--- /dev/null
+++ b/package/bats-support/Config.in
@@ -0,0 +1,8 @@ 
+config BR2_PACKAGE_BATS_SUPPORT
+	bool "bats-support"
+	depends on BR2_PACKAGE_BATS_CORE # runtime
+	help
+	  bats-support is a supporting library providing common
+	  functions to test helper libraries written for Bats.
+
+	  https://github.com/bats-core/bats-support
diff --git a/package/bats-support/bats-support.hash b/package/bats-support/bats-support.hash
new file mode 100644
index 0000000000..847f39e7c7
--- /dev/null
+++ b/package/bats-support/bats-support.hash
@@ -0,0 +1,5 @@ 
+# Locally calculated
+sha256  7815237aafeb42ddcc1b8c698fc5808026d33317d8701d5ec2396e9634e2918f  bats-support-0.3.0.tar.gz
+
+# License files
+sha256  36ffd9dc085d529a7e60e1276d73ae5a030b020313e6c5408593a6ae2af39673  LICENSE
diff --git a/package/bats-support/bats-support.mk b/package/bats-support/bats-support.mk
new file mode 100644
index 0000000000..765e08ffce
--- /dev/null
+++ b/package/bats-support/bats-support.mk
@@ -0,0 +1,18 @@ 
+################################################################################
+#
+# bats-support
+#
+################################################################################
+
+BATS_SUPPORT_VERSION = 0.3.0
+BATS_SUPPORT_SITE = $(call github,bats-core,bats-support,v$(BATS_SUPPORT_VERSION))
+BATS_SUPPORT_LICENSE = CC0-1.0
+BATS_SUPPORT_LICENSE_FILES = LICENSE
+
+define BATS_SUPPORT_INSTALL_TARGET_CMDS
+	$(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/lib/bats/bats-support/src
+	$(INSTALL) -m 0755 $(@D)/*.bash -t $(TARGET_DIR)/usr/lib/bats/bats-support
+	$(INSTALL) -m 0755 $(@D)/src/*.bash -t $(TARGET_DIR)/usr/lib/bats/bats-support/src
+endef
+
+$(eval $(generic-package))