Make thin_migrate tool optional#1
Conversation
mingnus
left a comment
There was a problem hiding this comment.
Thanks for the patch. I had considered this cleanup when modifying Makefile previously, but it ended up slipping through. Appreciate you addressing it.
Makefile
Outdated
| ln -s -f pdata_tools $(BINDIR)/era_dump | ||
| ln -s -f pdata_tools $(BINDIR)/era_invalidate | ||
| ln -s -f pdata_tools $(BINDIR)/era_restore | ||
| for tool in $(TOOLS); do ln -s -f pdata_tools $(BINDIR)/$${tool}; done |
There was a problem hiding this comment.
Would you mind using the foreach function instead for better logging and portability?
$(foreach tool, $(TOOLS), ln -s -f pdata_tools $(BINDIR)/$(tool); $(NEWLINE))
Also define the NEWLINE variable in Makefile to separate the lines:
define NEWLINE
endef
Makefile
Outdated
| $(INSTALL_DATA) man8/era_restore.8 $(MANPATH)/man8 | ||
| $(INSTALL_DATA) man8/era_invalidate.8 $(MANPATH)/man8 | ||
| $(INSTALL_DATA) man8/thin_trim.8 $(MANPATH)/man8 | ||
| for tool in $(TOOLS); do $(INSTALL_DATA) man8/$${tool}.8 $(MANPATH)/man8; done |
There was a problem hiding this comment.
Similarly,
$(foreach tool,$(TOOLS), $(INSTALL_DATA) man8/$(tool).8 $(MANPATH)/man8; $(NEWLINE))
Signed-off-by: Krzesimir Nowak <knowak@microsoft.com>
fd3d574 to
d560748
Compare
|
Thanks for the review. Replaced the bash loop with make loop. I also added a slightly-unrelated commit fixing a warning in txt2man that was showing up for every generated man-page - I must have updated something in the meantime, because I haven't seen it before. |
mingnus
left a comment
There was a problem hiding this comment.
Review provided. I'm wondering why clang is avoided. Is that due to build errors or some other constraint?
Cargo.toml
Outdated
| thinp = { path = ".", features = ["devtools"] } | ||
|
|
||
| [features] | ||
| default = ["migrate"] |
There was a problem hiding this comment.
How about renaming the feature to thin_migrate for clarity?
Makefile
Outdated
| era_invalidate \ | ||
| era_restore | ||
|
|
||
| ifeq ($(THIN_MIGRATE_EXCLUDE),) |
There was a problem hiding this comment.
Would you consider naming this DISABLE_THIN_MIGRATE to align with how the configure script handles naming?
Also, the flag should be propagate to the build command as well:
CARGO_FLAGS:=$(if $(DISABLE_THIN_MIGRATE),--no-default-features)
$(PDATA_TOOLS):
$(V) cargo build --release $(CARGO_FLAGS)
Given that users may run cargo build and make install separately, the feature availability check should be performed when the binary exists:
HAS_THIN_MIGRATE:=$(shell if [ -f $(PDATA_TOOLS) ]; then \
$(PDATA_TOOLS) 2>&1 | grep -q thin_migrate && echo 1; \
else \
$(if $(DISABLE_THIN_MIGRATE), true, echo 1); \
fi)
Finally, enable thin_migrate installation accordingly:
TOOLS:=\
...
era_restore \
$(if $(HAS_THIN_MIGRATE),thin_migrate)
(Both $(if and ifeq could be acceptable. I'm using $(if to make it consistent with the previous section)
That means, the DISABLE_THIN_MIGRATE flag doesn't affect the installation if the binary was built with thin_migrate enabled, or vise versa.
There was a problem hiding this comment.
Would you consider naming this
DISABLE_THIN_MIGRATEto align with how the configure script handles naming?
Sure, sounds good.
Also, the flag should be propagate to the build command as well:
CARGO_FLAGS:=$(if $(DISABLE_THIN_MIGRATE),--no-default-features) $(PDATA_TOOLS): $(V) cargo build --release $(CARGO_FLAGS)
Alright.
Given that users may run
cargo buildandmake installseparately, the feature availability check should be performed when the binary exists:HAS_THIN_MIGRATE:=$(shell if [ -f $(PDATA_TOOLS) ]; then \ $(PDATA_TOOLS) 2>&1 | grep -q thin_migrate && echo 1; \ else \ $(if $(DISABLE_THIN_MIGRATE), true, echo 1); \ fi)
We are cross-compiling thin-provisioning-tools, so running $(PDATA_TOOLS) to check if migrate appears in the output won't work for us. Also, I'd print a warning about DISABLE_THIN_MIGRATE being ignored if the binary already exists. How about the following?
HAS_THIN_MIGRATE:=$(shell if [ -f $(PDATA_TOOLS).d ]; then \
grep -qF thin-migrate.rs $(PDATA_TOOLS).d && echo 1; \
else \
$(if $(DISABLE_THIN_MIGRATE), true, echo 2); \
fi)
ifeq ($(HAS_THIN_MIGRATE),2)
ifneq ($(DISABLE_THIN_MIGRATE),)
$(warning DISABLE_THIN_MIGRATE variable is ignored, the pdata_tools binary exists and it has thin_migrate tool built in)
endif
endif
The $(PDATA_TOOLS).d seems to be some dependency file that lists all the source files that were used to build the binary. So if there is thin_migrate.rs listed, then it means that thin_migrate tool was built.
Finally, enable
thin_migrateinstallation accordingly:TOOLS:=\ ... era_restore \ $(if $(HAS_THIN_MIGRATE),thin_migrate)(Both
$(ifandifeqcould be acceptable. I'm using$(ifto make it consistent with the previous section)That means, the
DISABLE_THIN_MIGRATEflag doesn't affect the installation if the binary was built withthin_migrateenabled, or vise versa.
bin/txt2man
Outdated
| sub(/^ +$/,"") | ||
| } | ||
| /^[:space:]*[[:upper:][:digit:]]+[[:upper:][:space:][:digit:][:punct:]]+$/ { | ||
| /^[[:space:]]*[[:upper:][:digit:]]+[[:upper:][:space:][:digit:][:punct:]]+$/ { |
There was a problem hiding this comment.
The fix looks reasonable to me. However, I cannot reproduce the warning using gawk 5.3.0. Could you please let me know which version of gawk is reporting this warning? Also, would you mind reporting this issue to the txt2man upstream as well?
There was a problem hiding this comment.
I'm using gawk 5.3.2. Also, this seems to be already reported: mvertes/txt2man#41 and my fix is probably not correct, see upstream commit with the fix.
There was a problem hiding this comment.
I think I'll revert this commit for now.
There was a problem hiding this comment.
Seems like the upstream commit was reverted too, so no fix yet. Probably a regression in gawk.
Just trying to avoid pulling in clang into Flatcar's SDK solely for the |
The tool pulls in, indirectly through the devicemapper crate, a dependency on libclang. Make it possible to skip the tool to avoid the dependency, but keep it enabled by default. Signed-off-by: Krzesimir Nowak <knowak@microsoft.com>
d560748 to
32daf1b
Compare
|
Updated. |
|
My concern is that disabling a high-level feature like If the goal is to provide a way to build without bindgen & clang, I believe a better approach would be to provide a minimal devicemapper wrapper with pre-generated bindings, thus eliminating the need for bindgen and clang at compile time. A feature flag will be used to toggle between the default devicemapper-rs and the minimal wrapper implementations. What are your thoughts on this approach? |
|
I did consider something like that myself, but I ruled it out because it wouldn't have been feasible for Flatcar to do it by itself, and then we saw that it only affected |
|
Understood. I will start investigating the necessary changes, but expect this to take some time. I'll provide updates here. |
|
@krnowak I'm drafting the fix. Since the Cargo features are strict additive, we'll have to specify the Does this necessity align with how you plan to integrate the crate? |
|
@krnowak is away at the moment, but I've checked Gentoo's cargo.eclass, and it allows for conditionally enabling features as well as passing |
Please consider making the aforementioned tool optional, but still enabled by default. The tool pulls in a dependency on libclang through devicemapper crate and it would be nice to skip it if possible.
In Flatcar we kept using version 1.0.10 to avoid building clang just for this one package. If possible, we would still like to keep it out. I came up with this patch, because our upstream (Gentoo) dropped this rather old version of the package.
Currently, the thin_migrate tool is behind the "migrate" feature, and installation of the symlink is can be disabled with the non-empty THIN_MIGRATE_EXCLUDE variable in Makefile.