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

compose: Support arch-specific packages in YAML (and in JSON again) #1468

Closed

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Jul 23, 2018

Follow up to: #1459

We now honor arch-specific packages in YAML, and reject unknown
architectures. I looked a little bit at how to avoid having hardcoded
arch lists, but it doesn't seem worth it right now.

Follow up to: coreos#1459

We now honor arch-specific packages in YAML, and reject unknown
architectures.  I looked a little bit at how to avoid having hardcoded
arch lists, but it doesn't seem worth it right now.
@cgwalters cgwalters force-pushed the yaml-treefile-arch-packages branch from 63f0f3f to f5f95fe Compare July 23, 2018 14:34
@cgwalters
Copy link
Member Author

I context switched while working on this and realized after it's not done; I have a bigger patch I'm working on to actually plumb it through to the C side now.

@cgwalters cgwalters added the WIP label Jul 24, 2018
@cgwalters cgwalters changed the title compose: Support arch-specific packages in YAML (and in JSON again) WIP: compose: Support arch-specific packages in YAML (and in JSON again) Jul 24, 2018
rust/src/lib.rs Outdated
let arch = unsafe { CStr::from_ptr(arch) };
Some(arch.to_string_lossy().into_owned())
};
let arch = arch.as_ref().map(String::as_str);
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 found writing what I expected to be an easy "convert a raw nullable string pointer to Option<&str>" to be more awkward than expected. I was going to reach for CStr::to_str().unwrap() but that'd rely on our panic=abort setting, otherwise we'd try to unwind across FFI, which...OK it looks like relatively recently turned into an abort. So we probably can do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I reworked things here and I'm happier ⬇️ - it's worth finding good patterns here as the FFI glue is going to be a risky area of the code.

@cgwalters cgwalters removed the WIP label Jul 24, 2018
@cgwalters cgwalters changed the title WIP: compose: Support arch-specific packages in YAML (and in JSON again) compose: Support arch-specific packages in YAML (and in JSON again) Jul 24, 2018
@cgwalters
Copy link
Member Author

Lifted WIP.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Looks sane! Just some nits.

rust/src/lib.rs Outdated
fd: libc::c_int,
error: *mut *mut glib_sys::GError,
) -> libc::c_int {
// Convert arguments
let filename = Path::new(unsafe { CStr::from_ptr(filename).to_str().unwrap() });
Copy link
Member

Choose a reason for hiding this comment

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

Not that we really want to cater to the anti-UTF-8 rebels, though what was wrong with the previous way of building a Path which supported any path?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah my feeling is that the OsStr stuff is mostly for tools like rm or du that don't actually need to interpret filenames in general. I'm totally fine erroring out if the user provides us a treefile whose filename isn't valid UTF-8. That said we shouldn't panic. I reworked this some ⬇️

Also holy cow is the *const libc::c_char/CStr/[u8]/OsStr/Path situation confusing...I was able to drop the Path::new as we don't need/want a mutable buffer.

assert!(treefile.treeref == "exampleos/x86_64/blah");
assert!(treefile.packages.unwrap().len() == 3);
eprintln!("{:?}", treefile);
Copy link
Member

Choose a reason for hiding this comment

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

Letfover debugging?

rust/src/lib.rs Outdated
@@ -51,6 +51,12 @@ fn str_from_nullable<'a>(s: *const libc::c_char) -> Option<&'a str> {
}
}

/// Convert a C "bytestring" to a OsStr; panics if `s` is `NULL`.
Copy link
Member

Choose a reason for hiding this comment

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

Minor: s/OsStr/&[u8]/

rust/src/lib.rs Outdated
let file = unsafe { fs::File::from_raw_fd(fd) };
let r = {
let output = io::BufWriter::new(&file);
treefile_read_impl(filename, arch, output).to_glib_convention(error)
treefile_read_impl(filename.as_ref(), arch, output).to_glib_convention(error)
Copy link
Member

Choose a reason for hiding this comment

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

Neat!

@jlebon
Copy link
Member

jlebon commented Jul 24, 2018

@rh-atomic-bot r+ 773bd77

@rh-atomic-bot
Copy link

⌛ Testing commit 773bd77 with merge 23a3f96...

rh-atomic-bot pushed a commit that referenced this pull request Jul 24, 2018
Follow up to: #1459

We now honor arch-specific packages in YAML, and reject unknown
architectures.  I looked a little bit at how to avoid having hardcoded
arch lists, but it doesn't seem worth it right now.

Closes: #1468
Approved by: jlebon
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@jlebon
Copy link
Member

jlebon commented Jul 24, 2018

Hmm, looks like a registry.fedoraproject.org/fedora flake.
@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit 773bd77 with merge dd2f86e...

rh-atomic-bot pushed a commit that referenced this pull request Jul 24, 2018
Follow up to: #1459

We now honor arch-specific packages in YAML, and reject unknown
architectures.  I looked a little bit at how to avoid having hardcoded
arch lists, but it doesn't seem worth it right now.

Closes: #1468
Approved by: jlebon
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@cgwalters
Copy link
Member Author

@rh-atomic-bot retry

Go go gadget merge!

@rh-atomic-bot
Copy link

⌛ Testing commit 773bd77 with merge fa29f7a...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing fa29f7a to master...

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

Successfully merging this pull request may close these issues.

3 participants