Masayoshi Mizuma
2019-Mar-04 11:18 UTC
[Libguestfs] [supermin PATCH] rebuild the output it when SUPERMIN_KERNEL or SUPERMIN_MODULES are defined
SUPERMIN_KERNEL and SUPERMIN_MODULES don't work to guestfish.
Since guestfish sets --if-newer parameter to supermin, so the environment
variables are not used under the following conditions.
- the output directory exists and,
- the dates of both input files and package database are
older than the output
To solve that, rebuild the output it when SUPERMIN_KERNEL or
SUPERMIN_MODULES are defined even if --if-newer is set.
Signed-off-by: Masayoshi Mizuma <msys.mizuma at gmail.com>
---
src/supermin.ml | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/supermin.ml b/src/supermin.ml
index 7c7135b3..b997643 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -236,13 +236,17 @@ appliance automatically.
*)
if if_newer then (
try
- let odate = (lstat outputdir).st_mtime in
- let idates = List.map (fun d -> (lstat d).st_mtime) inputs in
- let pdate = (get_package_handler ()).ph_get_package_database_mtime () in
- if List.for_all (fun idate -> idate < odate) (pdate :: idates) then
(
- if debug >= 1 then
- printf "supermin: if-newer: output does not need
rebuilding\n%!";
- exit 0
+ let kernel = try getenv "SUPERMIN_KERNEL" with Not_found ->
"" in
+ let modules = try getenv "SUPERMIN_MODULES" with Not_found
-> "" in
+ if kernel = "" && modules = "" then (
+ let odate = (lstat outputdir).st_mtime in
+ let idates = List.map (fun d -> (lstat d).st_mtime) inputs in
+ let pdate = (get_package_handler ()).ph_get_package_database_mtime ()
in
+ if List.for_all (fun idate -> idate < odate) (pdate :: idates)
then (
+ if debug >= 1 then
+ printf "supermin: if-newer: output does not need
rebuilding\n%!";
+ exit 0
+ )
)
with
Unix_error _ -> () (* just continue *)
--
2.20.1
Pino Toscano
2019-Mar-04 12:17 UTC
[Libguestfs] [supermin PATCH] rebuild the output it when SUPERMIN_KERNEL or SUPERMIN_MODULES are defined
On Monday, 4 March 2019 12:18:58 CET Masayoshi Mizuma wrote:> SUPERMIN_KERNEL and SUPERMIN_MODULES don't work to guestfish. > > Since guestfish sets --if-newer parameter to supermin, so the environment > variables are not used under the following conditions. > - the output directory exists and, > - the dates of both input files and package database are > older than the output > > To solve that, rebuild the output it when SUPERMIN_KERNEL or > SUPERMIN_MODULES are defined even if --if-newer is set. > > Signed-off-by: Masayoshi Mizuma <msys.mizuma at gmail.com> > ---This approach switches from one side of the situation (= SUPERMIN_KERNEL and SUPERMIN_MODULES are not taken into account by --if-newer) to the very opposite side (= setting them always rebuild the appliance). I do not think this is a good idea, since the current situation is easy to workaround (`rm -rf $(guestfish get-cachedir)`), while using a different kernel will always rebuild the appliance after this change (and thus slow every run down). What is the goal here? Make sure that --if-newer actually rebuilds an appliance when changing the values of SUPERMIN_KERNEL and SUPERMIN_MODULES (even setting/unsetting them)? I agree that supermin ought to do better in --if-newer checks: for example, removing any of the files of a ext2 appliance (e.g. "root", or "kernel") will not make --if-newer rebuild the appliance. Maybe a better idea could be to record files/timestamps for appliances, so supermin can easily check what's missing/older. -- Pino Toscano -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part. URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190304/9890e380/attachment.sig>
Masayoshi Mizuma
2019-Mar-04 12:42 UTC
Re: [Libguestfs] [supermin PATCH] rebuild the output it when SUPERMIN_KERNEL or SUPERMIN_MODULES are defined
On Mon, Mar 04, 2019 at 01:17:26PM +0100, Pino Toscano wrote:> On Monday, 4 March 2019 12:18:58 CET Masayoshi Mizuma wrote: > > SUPERMIN_KERNEL and SUPERMIN_MODULES don't work to guestfish. > > > > Since guestfish sets --if-newer parameter to supermin, so the environment > > variables are not used under the following conditions. > > - the output directory exists and, > > - the dates of both input files and package database are > > older than the output > > > > To solve that, rebuild the output it when SUPERMIN_KERNEL or > > SUPERMIN_MODULES are defined even if --if-newer is set. > > > > Signed-off-by: Masayoshi Mizuma <msys.mizuma@gmail.com> > > --- > > This approach switches from one side of the situation > (= SUPERMIN_KERNEL and SUPERMIN_MODULES are not taken into account by > --if-newer) to the very opposite side (= setting them always rebuild > the appliance). I do not think this is a good idea, since the current > situation is easy to workaround (`rm -rf $(guestfish get-cachedir)`), > while using a different kernel will always rebuild the appliance after > this change (and thus slow every run down).Thanks. I didn't know the workaround.> > What is the goal here? Make sure that --if-newer actually rebuilds an > appliance when changing the values of SUPERMIN_KERNEL and > SUPERMIN_MODULES (even setting/unsetting them)?Yes, that is my goal.> I agree that supermin ought to do better in --if-newer checks: for > example, removing any of the files of a ext2 appliance (e.g. "root", > or "kernel") will not make --if-newer rebuild the appliance. > Maybe a better idea could be to record files/timestamps for appliances, > so supermin can easily check what's missing/older.It's great idea, thanks! I'll try to implement that. - Masa