Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,026 changes: 1,018 additions & 8 deletions examples/MODULE.bazel.lock

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions packages/qnx/SDP/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

# QNX SDP Distribution Build

load(":qnx_sdp.bzl", "qnx_sdp_distribution")

# Create the QNX SDP distribution from the patchset file
qnx_sdp_distribution(
name = "qnx_sdp",
patchset = "patchset-qnx803-virtio.plist",
qnxsoftwarecenter_clt = ":qnxsoftwarecenter_clt",
visibility = ["//visibility:public"],
)

# Package the SDP as a tarball for distribution (optional)
genrule(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need genrule to package the output of CLI QNX (SDP). Bazel support already all sorts of packaging rules like pkg_tar or pkg_zip.

name = "qnx_sdp_tar",
srcs = [":qnx_sdp"],
outs = ["qnx803-sdp.tar.gz"],
cmd = "tar -czf $@ -C $$(dirname $(location :qnx_sdp)) $$(basename $(location :qnx_sdp))",
visibility = ["//visibility:public"],
)

# Create a filegroup that references the output directory
filegroup(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

name = "qnx_sdp_files",
srcs = [":qnx_sdp"],
visibility = ["//visibility:public"],
)

# Local stub for qnxsoftwarecenter_clt so the package can be built inside this
# repository for testing. Replace with the real installer binary when integrating
# into a consuming workspace that provides @qnx_software_center.
sh_binary(
name = "qnxsoftwarecenter_clt",
srcs = ["qnxsoftwarecenter_clt.sh"],
visibility = ["//visibility:private"],
)
26 changes: 26 additions & 0 deletions packages/qnx/SDP/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# *******************************************************************************
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you create module here? As far as I can see, we don't need this.

# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""QNX SDP Installer Module"""

module(
name = "qnx_sdp_installer",
version = "1.0.0",
)

# Dependencies
bazel_dep(name = "bazel_skylib", version = "1.8.2")

# Register the QNX repositories
qnx_repos = use_extension("//:extensions.bzl", "qnx_repositories")
use_repo(qnx_repos, "qnx_installer", "qnx_software_center")
191 changes: 191 additions & 0 deletions packages/qnx/SDP/MODULE.bazel.lock

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions packages/qnx/SDP/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Bazel module extension for QNX repositories."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("//:qnx_install.bzl", "qnx_software_center_repository")

def _qnx_repositories_impl(module_ctx):
"""Implementation of the QNX repositories extension."""

# Download the QNX installer
http_file(
name = "qnx_installer",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really believe it would be good to get this installer as binary from somewhere rather than installing it like this. I will check with QNX if this is possible.

url = "https://www.qnx.com/download/download/79441/qnx-setup-2.0.4-202501021438-linux.run",
executable = True,
downloaded_file_path = "qnx-setup-2.0.4-202501021438-linux.run",
)

# Create the QNX Software Center repository
qnx_software_center_repository(
name = "qnx_software_center",
installer = "@qnx_installer//file:qnx-setup-2.0.4-202501021438-linux.run",
)

qnx_repositories = module_extension(
implementation = _qnx_repositories_impl,
)
210 changes: 210 additions & 0 deletions packages/qnx/SDP/patchset-qnx803-virtio.plist

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions packages/qnx/SDP/qnx_install.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Repository rule to install QNX Software Center."""

def _qnx_software_center_repository_impl(repository_ctx):
"""Implementation of the QNX Software Center repository rule."""

installer_label = repository_ctx.attr.installer
install_dir = repository_ctx.path("qnx_software_center")

# Check if QNX Software Center is already installed
qnxsoftwarecenter_clt = repository_ctx.path("qnxsoftwarecenter/qnxsoftwarecenter_clt")

if not qnxsoftwarecenter_clt.exists:
# Download/symlink the installer file
installer_path = repository_ctx.path(installer_label)

# Make installer executable
repository_ctx.execute(["chmod", "+x", str(installer_path)])

# Run the installer
result = repository_ctx.execute(
[
str(installer_path),
"--nox11",
"force-override disable-auto-start agree-to-license-terms",
"disable-auto-start",
"agree-to-license-terms",
".",
],
timeout = 300, # 5 minutes timeout
quiet = False,
)

if result.return_code != 0:
fail("Failed to extract QNX Software Center: %s\nStderr: %s" % (result.stdout, result.stderr))

# Create a BUILD file that exports the qnxsoftwarecenter_clt binary
# Note: The installer extracts to ./qnxsoftwarecenter (not qnx_software_center/qnxsoftwarecenter)
repository_ctx.file("BUILD", """
exports_files([
"qnxsoftwarecenter/qnxsoftwarecenter_clt",
])

filegroup(
name = "qnxsoftwarecenter_clt",
srcs = ["qnxsoftwarecenter/qnxsoftwarecenter_clt"],
visibility = ["//visibility:public"],
)

filegroup(
name = "all",
srcs = glob(["qnxsoftwarecenter/**"]),
visibility = ["//visibility:public"],
)
""")

qnx_software_center_repository = repository_rule(
implementation = _qnx_software_center_repository_impl,
attrs = {
"installer": attr.label(
allow_single_file = True,
mandatory = True,
doc = "The QNX installer file",
),
},
local = False,
doc = "Downloads and installs QNX Software Center",
)
109 changes: 109 additions & 0 deletions packages/qnx/SDP/qnx_sdp.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

"""Rule to create a QNX SDP distribution from a patchset file."""

def _qnx_sdp_distribution_impl(ctx):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to run the command over the script? Why not directly via ctx.actuins.run?

"""Implementation of the QNX SDP distribution rule."""

patchset = ctx.file.patchset
qnxsoftwarecenter_clt = ctx.executable.qnxsoftwarecenter_clt

# Output directory for the SDP distribution
output_dir = ctx.actions.declare_directory(ctx.attr.name)

# Create a script to run the qnxsoftwarecenter_clt command
script = ctx.actions.declare_file(ctx.attr.name + "_install.sh")

script_content = """#!/bin/bash
set -e

# Set up variables
QNXSOFTWARECENTER_CLT="{qnxsoftwarecenter_clt}"
PKG_PATCHLIST="{patchset}"
INSTALL_DIR="{install_dir}"

echo "srini - Installing QNX SDP from patchset $PKG_PATCHLIST using $QNXSOFTWARECENTER_CLT"
echo "srini - Output directory: $INSTALL_DIR"

# Create output directory
mkdir -p "$INSTALL_DIR"

# get proxy
# Strip protocol
temp="${{http_proxy#*://}}"
# Strip authentication if present
temp="${{temp#*@}}"
# Strip port and path
PROXYHOST="${{temp%%:*}}"
# Extract port if present
PROXYPORT="${{http_proxy##*:}}"

# Run qnxsoftwarecenter_clt to install packages from patchset
"$QNXSOFTWARECENTER_CLT" \
-proxy.host "$PROXYHOST" \
-proxy.port "$PROXYPORT" \
-myqnx.user "$SCORE_QNX_USER" \
-myqnx.password "$SCORE_QNX_PASSWORD" \
-importAndInstall "$PKG_PATCHLIST" \
-destination "$INSTALL_DIR"

echo "QNX SDP distribution created successfully in $INSTALL_DIR"
""".format(
qnxsoftwarecenter_clt = qnxsoftwarecenter_clt.path,
patchset = patchset.path,
install_dir = output_dir.path,
)

ctx.actions.write(
output = script,
content = script_content,
is_executable = True,
)

# Run the installation script
ctx.actions.run(
inputs = [patchset, qnxsoftwarecenter_clt],
outputs = [output_dir],
executable = script,
mnemonic = "QnxSdpInstall",
progress_message = "Installing QNX SDP from patchset %s" % patchset.short_path,
use_default_shell_env = True,
execution_requirements = {
"no-sandbox": "1", # May need to run without sandbox for installer
},
)

return [
DefaultInfo(
files = depset([output_dir]),
),
]

qnx_sdp_distribution = rule(
implementation = _qnx_sdp_distribution_impl,
attrs = {
"patchset": attr.label(
allow_single_file = [".plist"],
mandatory = True,
doc = "The patchset .plist file containing the package list",
),
"qnxsoftwarecenter_clt": attr.label(
default = "@qnx_software_center//:qnxsoftwarecenter_clt",
executable = True,
cfg = "exec",
doc = "The qnxsoftwarecenter_clt binary",
),
},
doc = "Creates a QNX SDP distribution from a patchset file",
)
38 changes: 38 additions & 0 deletions packages/qnx/SDP/qnxsoftwarecenter_clt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
# Simple stub for qnxsoftwarecenter_clt used for local testing inside the repo.
# It looks for the -destination <dir> argument and creates that directory.
set -e
DEST=""
ARG_NEXT=0
for a in "$@"; do
if [ "$ARG_NEXT" -eq 1 ]; then
DEST="$a"
ARG_NEXT=0
continue
fi
case "$a" in
-destination)
ARG_NEXT=1
;;
esac
done
if [ -z "$DEST" ]; then
echo "qnxsoftwarecenter_clt stub: no -destination provided, nothing to do" >&2
exit 0
fi
mkdir -p "$DEST"
# Create a small marker to indicate stub run
echo "QNX SDP stub installed at $(date -u) by qnxsoftwarecenter_clt stub" > "$DEST/INSTALLED_BY_QNX_SOFTWARE_CENTER_STUB"
exit 0
Loading