Add pkg_install(wipe_destdir: bool)
I want to request a feature to add the following:
pkg_install(
wipe_destdir = True,
)
Default value is false. If true, pkg_install() script will wipe the given destdir before installing the files.
This is particularly useful if we want the resulting destdir to be always strictly containing the given list of files, but not any old files. For example, I have a pkg_install() rule that generates stardoc and put it in our source tree. If the list of generated file names changes, I need to manually delete the old documentation files now. But with this attribute, I can set it to True so I don't have to manually delete old documentation. The example is illustrated here: https://r.android.com/c/kernel/build/+/3273727/2/kleaf/docs/BUILD.bazel
@aiuto if you think this is a useful feature, I can start preparing a pull request; or please let me know if this does not fit in pkg_install(). Thanks!
Sigh... Yes it is useful. but adding an rm -rf is such a footgun.
What if is were a command line option for when you run it?
blaze run //my/install:target -- --rules_pkg//pkg:install-wipe-dest.
That would be sub-optimal for our use case (and for some downstream partners), so I would love to add an attribute to "always wipe". But yeah it is better than nothing.
I'll submit a PR to add the command line option (the option goes to the script, not to bazel, so it goes after the -- and doesn't need a @rules_pkg//pkg:install prefix.
bazel run //my/install:target -- --wipe-destdir
Bikeshed:
How do you like the command line option name to be? wipe_destdir, wipe-destdir, wipe-dest, wipe_dest etc.? Personally I like wipe_destdir but there are no convention in this code base, so I'd like to ask first.