Improve ptxdist project visibility by adding it to repology.
https://repology.org/

This also allows components like rauc to showcase supported
distributions and current packaged version.

It also gives ptxdist users and maintainers an overview of packages
with known CVEs that should be priotized for version bumpes.

Generate JSON output about almost all packages in ptxdist for repology.
Below is an output example for alsa-lib:

{
    "name": "alsa-lib",
    "version": "1.2.13",
    "upstream_urls": 
"https://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.13.tar.bz2";,
    "license": "LGPL-2.1-or-later"
},

Add PTXdist support #1487:
https://github.com/repology/repology-updater/issues/1487

I have run this patch against ptxdist-2025.04.0 and got this output:
https://github.com/baxeno/ptxdist-repology/blob/main/repology.json

Using the following command:
$ ptxdist repology | grep -v "make: Nothing to be done for" > repology.json

Signed-off-by: Bruno Thomsen <[email protected]>
Co-developed-by: Ladislav Michl <[email protected]>
---
Since RFC PATCH:
- Replace bash script with pure makefile thanks to Ladislav
- Add upstream_urls for packages as it was an repology requirement

Ladislav:
I can see you use different last names and emails, let me know if I used the 
wrong.

 bin/ptxdist                        |  6 +++
 rules/post/ptxd_make_repology.make | 78 ++++++++++++++++++++++++++++++
 scripts/bash_completion            |  2 +-
 3 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 rules/post/ptxd_make_repology.make

diff --git a/bin/ptxdist b/bin/ptxdist
index 1f561fdf6..24a8e2ed9 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -799,6 +799,7 @@ Misc:
                                variable and print the contents of this variable
   licensecheck                 check md5sums of license files for all packages
   lint                         run some basic checks for the bsp and PTXdist
+  repology                     generate repology JSON for PTXdist
   list-packages                        print a list of all selected packages
   local-src <pkg> [<directory>]        overwrite a package source with a 
locally provided
                                directory containing the sourcecode.
@@ -1916,6 +1917,11 @@ EOF
                                ptxd_bailout "lint checks failed"
                        fi
                        ;;
+               repology)
+                       check_premake_compiler &&
+                       ptxd_make_log ptxdist-repology
+                       exit
+                       ;;
                list-packages)
                        check_config &&
                        check_deps &&
diff --git a/rules/post/ptxd_make_repology.make 
b/rules/post/ptxd_make_repology.make
new file mode 100644
index 000000000..3360101cf
--- /dev/null
+++ b/rules/post/ptxd_make_repology.make
@@ -0,0 +1,78 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2025 by Bruno Thomsen <[email protected]>
+#               2025 by Ladislav Michl <[email protected]>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+PTX_PACKAGES_IGNORE    := \
+       at91bootstrap2 \
+       barebox \
+       barebox_mlo \
+       base \
+       binutils \
+       blspec-entry \
+       cross-dummy-strip \
+       cross-llvm \
+       cross-nasm \
+       cross-pkg-config-wrapper \
+       cryptodev-api \
+       gcclibs \
+       gdb \
+       gdbserver \
+       glibc \
+       initmethod-bbinit \
+       initmethod-systemd \
+       kernel \
+       kernel-fit \
+       kernel-header \
+       locales \
+       machine-id \
+       nodejs_packages \
+       os-release \
+       ptxdist-configs \
+       rc-once \
+       rootfs \
+       systemd-hwdb \
+       u-boot \
+       uclibc \
+       usr-rootfs \
+       x-load \
+       xorg-fonts
+
+PHONY += ptxdist-repology
+
+ptx_packages_reported:=$(sort $(filter-out host-system-%,$(filter-out 
host-%,$(filter-out image-%,$(PTX_PACKAGES_ALL)))))
+ptx_packages_reported:=$(filter-out 
$(PTX_PACKAGES_IGNORE),$(ptx_packages_reported))
+ptx_package_last:=$(lastword $(ptx_packages_reported))
+ptx_packages_reported:=$(filter-out 
$(ptx_package_last),$(ptx_packages_reported))
+
+ptx/repology-print = \
+       $(info $(space)   "name": "$(1)"$(comma)) \
+       $(info $(space)   "version": 
"$($(PTX_MAP_TO_PACKAGE_$(1))_VERSION)"$(comma)) \
+       $(info $(space)   "upstream_urls": 
"$($(PTX_MAP_TO_PACKAGE_$(1))_URL)"$(comma)) \
+       $(info $(space)   "license": "$($(PTX_MAP_TO_PACKAGE_$(1))_LICENSE)")
+
+ptx/repology-item = \
+       $(info $(space) {) \
+       $(call ptx/repology-print,$(1)) \
+       $(info $(space) }$(comma))
+
+ptx/repology-lastitem = \
+       $(info $(space) {) \
+       $(call ptx/repology-print,$(1)) \
+       $(info $(space) })
+
+ptx/repology = \
+       $(info [) \
+       $(foreach pkg,$(ptx_packages_reported), \
+               $(call ptx/repology-item,$(pkg))$(ptx/nl)) \
+       $(call ptx/repology-lastitem,$(ptx_package_last)) \
+       $(info ])
+
+ptxdist-repology:
+       @$(call ptx/repology)
+
+# vim: syntax=make
diff --git a/scripts/bash_completion b/scripts/bash_completion
index 4bff2d4b6..2bb21a848 100644
--- a/scripts/bash_completion
+++ b/scripts/bash_completion
@@ -123,7 +123,7 @@ _ptxdist_completion()
        clean)
                COMPREPLY=( $( compgen -W root -- $cur ) )
                ;&
-       
get|extract|prepare|compile|install|targetinstall|tags|urlcheck|licensecheck|package-info|cargosync)
+       
get|extract|prepare|compile|install|targetinstall|tags|urlcheck|licensecheck|repology|package-info|cargosync)
                COMPREPLY+=( $( compgen -W "$(__ptxdist_completion_packages)" 
-- $cur ) )
                ;;
        drop)

base-commit: f61905c23240642dec3e5390ee15e83cf1e016e9
-- 
2.49.0


Reply via email to