Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QWT support #181

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Add QWT support #181

wants to merge 40 commits into from

Conversation

omeg
Copy link
Member

@omeg omeg commented Feb 10, 2025

No description provided.

Copy link
Member

@marmarek marmarek left a comment

Choose a reason for hiding this comment

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

This isn't a full review yet, but I think I captured main point here already.

set -efo pipefail

# shellcheck source=SCRIPTDIR/qubes.WinSign.common
. /etc/qubes-rpc/qubes.WinSign.common
Copy link
Member

Choose a reason for hiding this comment

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

Better not hardcode the path here. Especially, it's convenient to install the RPC files in /usr/local/etc/qubes-rpc in a specific AppVM.
You can use $(dirname "$0") to find the directory.

Similar comment to all the other services too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


echo "[*] Copying the final iso from '${DISPVM}' to '${OUTPUT}'..."

shell_call "${DISPVM}" "cat ~/win-build.iso" | cat > "${OUTPUT}"
Copy link
Member

Choose a reason for hiding this comment

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

Why extra cat?

Suggested change
shell_call "${DISPVM}" "cat ~/win-build.iso" | cat > "${OUTPUT}"
shell_call "${DISPVM}" "cat ~/win-build.iso" > "${OUTPUT}"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

key_name=sign_key_name,
)

dvm.kill()
Copy link
Member

Choose a reason for hiding this comment

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

If starting dvm fails, this will fail too (UnboundLocalError: cannot access local variable 'dvm' where it is not associated with a value). Either move starting dvm before the try part, or initialize the variable early (with None?) and check for it here.
But also, it looks like the dvm start can be moved much later? Currently it's at the start of the build, but it's used only after the build - so, if you move it later, you can save starting it in case of build failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

qubes.WinSign.CreateKey +Qubes__Windows__Tools work-qubesos vault-sign allow
qubes.WinSign.DeleteKey +Qubes__Windows__Tools work-qubesos vault-sign allow
qubes.WinSign.GetCert +Qubes__Windows__Tools work-qubesos vault-sign allow
qubes.WinSign.Sign +Qubes__Windows__Tools work-qubesos vault-sign allow
Copy link
Member

Choose a reason for hiding this comment

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

Missing policy for the timestamp service

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

admin.vm.property.Get * work-qubesos win-build allow target=dom0
admin.vm.device.block.Attach * work-qubesos win-build allow target=dom0

qubes.WinSign.QueryKey +Qubes__Windows__Tools work-qubesos vault-sign allow
Copy link
Member

Choose a reason for hiding this comment

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

Generally for builder-specific services we use qubesbuilder. prefix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +296 to +163
def run(
self,
cmd: List[str],
copy_in: List[Tuple[Path, PurePath]] = None,
copy_out: List[Tuple[PurePath, Path]] = None,
):
Copy link
Member

Choose a reason for hiding this comment

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

To support building in DispVM, this should be able to create and start new DispVM first and kill it at the end.
It does mean fresh DispVM for each component - is that a problem? In other words - are there some hidden assumption about reusing the same VM (like, depending on some files being present from previous build)?

For development builds it probably make sense to retain option to reuse the same VM over and over, so the DispVM case can be under some config option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it can be a DispVM all the time, for development I usually just do local builds without the builder.

Comment on lines 27 to 28
from qubesadmin import Qubes
from qubesadmin.devices import DeviceAssignment, UnknownDevice
from qubesadmin.exc import DeviceAlreadyAttached, QubesException
from qubesadmin.utils import encode_for_vmexec
from qubesadmin.vm import DispVM, QubesVM
Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to use qubes-builderv2 outside of Qubes VM too. It doesn't need to support building Windows code there, but it shouldn't crash on ImportError. I think there need to be try / except ImportError somewhere, that will catch it nicely. I have an idea where - see separate comment.

@@ -31,6 +31,7 @@
from qubesbuilder.executors.container import ContainerExecutor
from qubesbuilder.executors.local import LocalExecutor
from qubesbuilder.executors.qubes import LinuxQubesExecutor
from qubesbuilder.executors.windows import WindowsExecutor
Copy link
Member

Choose a reason for hiding this comment

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

You can catch ImportError here, and set some variable like windows_executor_available = False

@@ -575,6 +576,8 @@ def get_executor(options):
executor = LocalExecutor(**executor_options) # type: ignore
elif executor_type == "qubes":
executor = LinuxQubesExecutor(**executor_options) # type: ignore
elif executor_type == "windows":
executor = WindowsExecutor(**executor_options) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

And here throw an exception if windows_executor_available is false.

from qubesbuilder.config import Config
from qubesbuilder.distribution import QubesDistribution
from qubesbuilder.executors import ExecutorError
from qubesbuilder.executors.windows import WindowsExecutor
Copy link
Member

Choose a reason for hiding this comment

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

And similarly this (and the qubesadmin imports above) can be problematic. It wants either some wrapping here (and raise an exception early in run if qubesadmin is not available), or changing PluginManager so that plugin import error is not fatal. IMO the first option is better if wouldn't clutter the code too much.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW several CI tests that are unrelated to QWT fail due to importing qubesadmin. That could be a good check if it works as expected - tests not related to QWT should pass even if qubesadmin cannot be imported.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the qubesadmin dependency.

@marmarek
Copy link
Member

It has conflicts now... @fepitre in the meantime added most of the cross-distribution dependencies that will be needed for building iso+rpm (remaining part is in #185, but that shouldn't conflict anymore, I hope).

omeg added 15 commits February 26, 2025 18:57
Add option to not ask user to enable network discovery

Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 36.34497% with 310 lines in your changes missing coverage. Please review.

Project coverage is 75.12%. Comparing base (1987baa) to head (5f3210a).

Files with missing lines Patch % Lines
qubesbuilder/plugins/build_windows/__init__.py 21.93% 153 Missing ⚠️
qubesbuilder/executors/qubes.py 31.62% 80 Missing ⚠️
qubesbuilder/executors/windows.py 37.50% 35 Missing ⚠️
qubesbuilder/plugins/source_windows/__init__.py 42.10% 22 Missing ⚠️
qubesbuilder/plugins/__init__.py 46.15% 7 Missing ⚠️
qubesbuilder/executors/qrexec.py 89.58% 5 Missing ⚠️
qubesbuilder/config.py 33.33% 4 Missing ⚠️
qubesbuilder/distribution.py 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
- Coverage   78.74%   75.12%   -3.63%     
==========================================
  Files          47       51       +4     
  Lines        5388     5825     +437     
==========================================
+ Hits         4243     4376     +133     
- Misses       1145     1449     +304     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marmarek
Copy link
Member

Can you squash the fixup commits (just do git rebase -i --autosquash)

omeg added 15 commits February 27, 2025 15:57
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
Signed-off-by: Rafał Wojdyła <[email protected]>
@omeg omeg marked this pull request as ready for review February 27, 2025 15:36
@tlaurion
Copy link

tlaurion commented Feb 28, 2025

Amazing work @omeg ! Can't wait to test testing packages. Also really interesting piece of work in terms of complex qubes-builderv2 for a learner. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants