gitpod-io / dockerfreeze

Freeze your development environment as a Dockerfile
MIT License
12 stars 4 forks source link

Brainstorm: How should we implement fsh checking? #47

Open Kreyren opened 4 years ago

Kreyren commented 4 years ago

ping @JesterOrNot How should we implement the fsh checking?

Reminder: This is done for binaries that are not in PATH like 70% of binaries on my system.

Currently i have this:

// Detect File System Hierarchy
// FIXME: Export as an invidual crate?
// FIXME: What do we want this to return?
pub fn detect_filesystem_hierarchy() -> ??? {
    if cfg!(target_os = "unix") {
        // See File System Hierarchy Standard https://refspecs.linuxfoundation.org/fhs.shtml
        // FIXME-QA: What about lib32 and lib64?
        // FIXME-QA: Not all systems follow standard for /srv
        // FIXME-QA: Needs more definitions
        let fsh3_0 = ["/bin", "/boot", "/etc", "/dev", "/etc", "/home", "/lib", "/media", "/mnt", "/opt", "/root", "/run", "/sbin", "/srv", "/tmp", "/usr" ];

    } else if cfg!(target_os = "windows") {
        unimplemented!("Windows is not implemented in detect_filesystem_hierarchy function")
    } else {
        // FIXME: Add msg
        exit(255);
    }
}

Where the issues are:

  1. ostree shares the directories with fsh3.0
  2. Some of the linux distros are not following fsh3.0 (like archlinux)
  3. Custom filesystems like my LFS which has /kreyrock/strata/foo with other filesystems that are sandboxed to be accesible from the same terminal.

Proposed solutions

Assuming this being exported as a crate

  1. Define arrays for known filesystems and then capture the data in enums to be used by developers i.e enum that defines all known binaries (could be used on my project as well)
  2. Define arrays for known filesystems and export logic to output the filesystem.
  3. Check only for known destinctions like /ostree to detect ostree

Assuming the being a non-crate

  1. Same as 2.
  2. Use something like find $ROOT -type f -executable to output all files with executable permission.
    • This may not work on windows
Kreyren commented 4 years ago

@JesterOrNot Can you take a look at this?

I need a brainstorm to finish https://github.com/gitpod-io/dockerfreeze/pull/39