@@ -331,20 +331,19 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
331331 // To avoid unnecessary apt-get update calls, we check the timestamp of this file.
332332 // If it is newer than 10 minutes, we skip apt-get update.
333333 stat , err := os .Stat ("/var/lib/dpkg/status" )
334- if err != nil {
335- klog .Infof ("Error getting dpkg status info: %v" , err )
334+ if err == nil && stat . ModTime (). After ( time . Now (). Add ( - 10 * time . Minute )) {
335+ klog .V ( 2 ). Infof ("Skipping fetching the list of available packages" )
336336 } else {
337- if stat .ModTime ().After (time .Now ().Add (- 10 * time .Minute )) {
338- klog .Infof ("Skipping package install as /var/lib/dpkg/status is newer than 10 minutes" )
339- } else {
340- args := []string {"apt-get" , "update" }
341- klog .Infof ("Running command %s" , args )
342- cmd := exec .Command (args [0 ], args [1 :]... )
343- cmd .Env = env
344- output , err := cmd .CombinedOutput ()
345- if err != nil {
346- klog .Infof ("Error fetching the latest list of available packages: %v:\n %s" , err , string (output ))
347- }
337+ if err != nil && ! os .IsNotExist (err ) {
338+ klog .Warningf ("Error getting dpkg status info: %v" , err )
339+ }
340+ args := []string {"apt-get" , "update" }
341+ klog .Infof ("Running command %s" , args )
342+ cmd := exec .Command (args [0 ], args [1 :]... )
343+ cmd .Env = env
344+ output , err := cmd .CombinedOutput ()
345+ if err != nil {
346+ return fmt .Errorf ("error fetching the list of available packages: %v:\n %s" , err , string (output ))
348347 }
349348 }
350349 }
0 commit comments