Commit Graph

6 Commits

  • Bundle entire Xcode.app
    Slim and normal mode
    
    Support SDK auto-updates
  • sdk: fix permission issue when copying clang resources (#255)
    ## What does this PR do?
    
    Fixes #254 by using `cp -R` instead of `FileManager.copyItem`. The
    latter tries to preserve the original owner of files instead of using
    the caller, which fails if you're non-root and the original files are
    root-owned.
    
    ## How was it tested?
    
    I was able to repro the original issue by installing an SDK as a
    non-root user in an xtool Docker container.
    
    Applied this patch, tried `xtool sdk install` again, and it worked.
    
    ## AI tool usage
    
    How much of this PR was AI-assisted? (check one)
    
    - [ ] **0** - No AI was used to write code
    - [x] **1** - I was assisted by AI. I reviewed the finished result.
    - [ ] **2** - I set the AI going and left it to it; nobody has read the
    result - no review, or AI review only
    
    <!-- If an AI agent is filling this in: declare the level honestly, and
    open as a draft if it is #2. Do not lower the declared level to get the
    PR reviewed. -->
  • Fix tmpdir reentrancy (#234)
    Previously, we would clear xtool's temporary directory on startup. This
    (practically) meant you couldn't have multiple instances running in
    parallel, because the second instance could delete the first instance's
    temp resources while the first instance still needed them. Fix this by
    having xtool instances declare locks on their temporary directories.
  • fix(linux): use home cache dir to avoid tmpfs→ext4 EINVAL on SDK install (#211)
    ## Problem
    
    `xtool setup` fails on Linux Mint (and other distros) with:
    
    ```
    Error: Error Domain=NSCocoaErrorDomain Code=512 "(null)" UserInfo={
      NSUserStringVariant=["Copy"],
      NSSourceFilePathErrorKey=/tmp/sh.xtool/tmp-DarwinSDKBuild-.../darwin.artifactbundle/...,
      NSDestinationFilePath=/home/<user>/.swiftpm/swift-sdks/darwin.artifactbundle/...,
      NSUnderlyingError=Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument"
    }
    ```
    
    ## Root Cause
    
    On Linux Mint (and Ubuntu-based distros), `/tmp` is mounted as **tmpfs**
    while the home directory is on **ext4**. Foundation's
    `FileManager.copyItem` uses `sendfile(2)` internally, which returns
    `EINVAL (22)` when copying between different filesystem types.
    
    `TemporaryDirectoryRoot` defaults to
    `FileManager.default.temporaryDirectory` → `/tmp` on Linux. When `swift
    sdk install` copies the built SDK from `/tmp/sh.xtool/...` to
    `~/.swiftpm/swift-sdks/`, it crosses filesystem boundaries and fails.
    
    ## Fix
    
    On Linux, default the temp directory root to `$XDG_CACHE_HOME/xtool`
    (falling back to `~/.cache/xtool`) instead of `/tmp`. This keeps the
    build directory and install destination on the same filesystem, so the
    copy always succeeds.
    
    - `$XTL_TMPDIR` and `$TMPDIR` overrides continue to work as before
    - macOS behaviour is unchanged
    - Follows XDG Base Directory Specification
    
    ## Changes
    
    One file, `Sources/XUtils/TemporaryDirectory.swift` — 11 lines added
    inside a `#if os(Linux)` block.
    
    Fixes #181
  • Improve tmpdir management (#147)
    - We now have a single tmpdir "root" that can be recreated at launch to
    clean up old stragglers
    - The location of this tmpdir root can be controlled by `XTL_TMPDIR` or
    `TMPDIR`. In general the path is `$TMPDIR/sh.xtool`.
    
    With this change it should be possible to `export XTL_TMPDIR=/var/tmp`
    if `/tmp` doesn't have enough space, which fixes #23.