Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix archives that are wrapped in a directory #11

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

gorkem
Copy link
Collaborator

@gorkem gorkem commented May 2, 2024

Fixes the case if kit binary is wrapped in a directory.

Fixes the case if kit binary is wrapped in a
directory. Also fixes the markdownlint issues.
Comment on lines +78 to +96
const extractedDir = path.dirname(extractedPath)
const files = fs.readdirSync(extractedDir, {
withFileTypes: true,
recursive: true
})
const kitExecutable = files.filter(
file => file.isFile() && file.name === getExecutableBinaryName()
)
if (kitExecutable.length === 0) {
throw new Error(
`Failed to find executable binary in extracted archive: ${archive}`
)
}
// In some cases, the extracted binary is in a subdirectory of the extracted archive
// In this case, move the binary to the root of the extracted archive
ghCore.debug(
`Checking if extracted binary is in a subdirectory for ${kitExecutable[0].name} on path ${kitExecutable[0].path}`
)
if (kitExecutable[0].path === extractedPath) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to still not work:

  • In the files.filter() call, won't checking file => isFile() prevent getting any dirs (assuming you want to match the wrapping directory)
  • Checking file.name === getExecutableBinaryName() also might not work; in the case of wrapped dirs on macos, the dir name is kit-darwin-amd64 or similar (i.e. not kit). On windows, the binary name is kit.exe which will never match a dir.

Testing locally, I'm seeing failures (in both case, ::error::Failed to find executable binary in extracted archive: <longname>):

  • With latest, the jozu-bin dir contains
    /var/[...]/jozu-bin
    ├── LICENSE
    ├── README.md
    └── kit
    
  • With v0.1.3, the jozu-bin dir contains
    /var/[...]/jozu-bin
    └── kitops-darwin-arm64
        ├── LICENSE
        ├── README.md
        └── kit
    

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking locally, I don't know if

  const extractedDir = path.dirname(extractedPath)

is correct -- on my system, extractedPath is /var/[...]/T/jozu-bin, so taking the dirname gives /var/[...]/T/, which will not contain the extracted files.

@gorkem gorkem marked this pull request as draft August 20, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants