                     ;; and prints anything in a particular repository
                     ;; that has an mtime greater than the last build
                     ;; time for that repository.
-                    ;;
-                    ;; Just FYI, this find(1) command is compatible
-                    ;; with both GNU and BSD find. But not apparently
-                    ;; with busybox/find, see [1].
-                    ;;
-                    ;; [1]: https://github.com/raxod502/straight.el/issues/78
-                    (setq args (append (list "-o"
-                                             "-path"
-                                             (format "./%s/*" local-repo)
-                                             "-newermt"
-                                             mtime
-                                             "-print")
-                                       args))
+                    (let ((newer-or-newermt nil)
+                          (mtime-or-file nil))
+                      (pcase straight-find-flavor
+                        (`gnu/bsd
+                         (setq newer-or-newermt "-newermt")
+                         (setq mtime-or-file mtime))
+                        (`busybox
+                         (setq newer-or-newermt "-newer")
+                         (setq mtime-or-file (straight--make-mtime mtime)))
+                        (_ (error "Unexpected `straight-find-flavor': %S"
+                                  straight-find-flavor)))
+                      (setq args (append (list "-o"
+                                               "-path"
+                                               (format "./%s/*" local-repo)
+                                               newer-or-newermt
+                                               mtime-or-file
+                                               "-print")
+                                         args)))
                   ;; If no mtime is specified, it means the package
                   ;; definitely needs to be (re)built. Probably there
                   ;; was an error and we couldn't finish building the


;;;;; Cache handling

(defun straight--finalize-build (recipe)
  "Update `straight--build-cache' to reflect a successful build of RECIPE.
RECIPE should be a straight.el-style plist. The build mtime and

generated at the end of an init from the keys of
`straight--profile-cache'.")

(defvar straight--build-cache-version :jes
  "The current version of the build cache format.
When the format on disk changes, this value is changed, so that
straight.el knows to regenerate the whole cache.")

(defun straight--load-build-cache ()
  "Load data from build-cache.el into memory.
This sets the variables `straight--build-cache' and
`straight--eagerly-checked-packages'. If the build cache is
malformed, don't signal an error, but set these variables to
empty values (all packages will be rebuilt, with no caching)."
  ;; Start by clearing the build cache. If the one on disk is
  ;; malformed (or outdated), these values will be use.
  (setq straight--build-cache (make-hash-table :test #'equal))
  (setq straight--eagerly-checked-packages nil)
  (ignore-errors
    (with-temp-buffer
      ;; Using `insert-file-contents-literally' avoids
      ;; `find-file-hook', etc.
      (insert-file-contents-literally
       (straight--file "build-cache.el"))
      (let ((version (read (current-buffer)))
            (find-flavor (read (current-buffer)))
            (cache (read (current-buffer)))
            (packages (read (current-buffer))))
        (unless (and
                 ;; Format version should be the symbol currently in
                 ;; use.
                 (symbolp version)
                 (eq version straight--build-cache-version)
                 ;; Find flavor should be the symbol currently in use.
                 (symbolp find-flavor)
                 (eq find-flavor straight-find-flavor)
                 ;; Build cache should be a hash table.
                 (hash-table-p cache)
                 (eq (hash-table-test cache) #'equal)
                 ;; Eagerly checked packages should be a list of
                 ;; strings.
                 (listp packages)
                 (cl-every #'stringp packages))
          ;; If anything is wrong, abort and use the default values.
          (error "Malformed or outdated build cache"))
        ;; Otherwise, we can load from disk.
        (setq straight--build-cache cache)
        (setq straight--eagerly-checked-packages packages)))))

(defun straight--save-build-cache ()
  "Write data from memory into build-cache.el."
  (with-temp-file (straight--file "build-cache.el")
    ;; Prevent mangling of the form being printed in the case that
    ;; this function was called by an `eval-expression' invocation of
    ;; `straight-use-package'.
    (let ((print-level nil)
          (print-level nil))
      ;; The version of the build cache.
      (print straight--build-cache-version (current-buffer))
      ;; The format of the timestamps that were saved; if this changes
      ;; (due to a new find(1) command installed), we will have to
      ;; re-generate the build cache. It would be more efficient to
      ;; save the timestamps in an OS-independent way, but this
      ;; approach is simpler.
      (print straight-find-flavor (current-buffer))
      ;; The actual build cache.
      (print straight--build-cache (current-buffer))
      ;; Which packages should be checked eagerly next init.
      (print (hash-table-keys straight--profile-cache) (current-buffer)))))

;;;;; Bulk checking
