Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .devcontainer/features/src/features/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

set -e

feature_dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)

prefix=/opt/devcontainer-config
state_path=/var/lib/devcontainer-config/features

Expand All @@ -20,11 +18,11 @@ case $FEATURES_PATH in
esac

mkdir -p "$prefix"
install -m 0755 "$feature_dir/features-run" "$prefix/features-run"
install -m 0755 ./features-run "$prefix/features-run"

printf '%s\n' "$FEATURES_PATH" > "$prefix/features-path"

mkdir -p "$FEATURES_PATH" "$state_path"
chmod a+rwx "$FEATURES_PATH" "$state_path"
chmod a+rwx "$state_path"

exec "$prefix/features-run" install
18 changes: 18 additions & 0 deletions features/Features/SymbolicLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace DevcontainerConfig.Features;

public static class SymbolicLink
{
public static void Replace(string path, string target)
{
string temp = Path.Join(Path.GetDirectoryName(path), $".{Path.GetFileName(path)}-{Guid.NewGuid():N}");
File.CreateSymbolicLink(temp, target);
try
{
File.Move(temp, path, overwrite: true);
}
finally
{
File.Delete(temp);
}
}
}
7 changes: 4 additions & 3 deletions features/code-server/Feature/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ namespace DevcontainerConfig.CodeServer.Feature;
internal static class Install
{
private const string BinDir = "/usr/local/bin";
private const string LinkPath = "/usr/local/bin/code-server";

internal static void Run(string stagedDir)
{
Options options = OptionsFile.Read(stagedDir, OptionsContext.Default.FeatureOptions);
options.Validate();

Directory.CreateDirectory(BinDir);
File.Delete(LinkPath);
File.CreateSymbolicLink(LinkPath, Path.Join(stagedDir, "code-server", "bin", "code-server"));
SymbolicLink.Replace(
Path.Join(BinDir, "code-server"),
Path.Join(stagedDir, "code-server", "bin", "code-server")
);
}
}
2 changes: 1 addition & 1 deletion features/code-server/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": 1,
"revision": 2,
"versions": {
"4.145.2": {
"linux-x64": {
Expand Down
16 changes: 3 additions & 13 deletions features/dotnet/Feature/Registration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using DevcontainerConfig.Features;

namespace DevcontainerConfig.Dotnet.Feature;

internal static class Registration
Expand All @@ -24,19 +26,7 @@ private static void WriteInstallLocation(string root)
private static void CreateSymlink(string root)
{
string target = Path.Join(root, "dotnet");

// rename(2) replaces whatever else the path holds (absent, symlink or regular file) and never resolves the
// destination, so the link lands in one step; a real directory fails the rename.
string temp = Path.Join(Path.GetDirectoryName(LinkPath), $".dotnet-{Guid.NewGuid():N}");
File.CreateSymbolicLink(temp, target);
try
{
File.Move(temp, LinkPath, overwrite: true);
}
finally
{
File.Delete(temp);
}
SymbolicLink.Replace(LinkPath, target);
Console.WriteLine($"install: linked {LinkPath} to {target}");
}

Expand Down
2 changes: 1 addition & 1 deletion features/dotnet/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": 7,
"revision": 8,
"components": {
"sdk": {
"versions": {
Expand Down
16 changes: 8 additions & 8 deletions features/ripgrep/NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Installed files

| Source | Destination | Mode |
| ------------------------------------- | ---------------------------------------------------- | ---- |
| `rg` | `/usr/local/bin/rg` | 0755 |
| `doc/rg.1` | `/usr/local/share/man/man1/rg.1` | 0644 |
| `complete/rg.bash` | `/usr/local/share/bash-completion/completions/rg` | 0644 |
| `complete/_rg` | `/usr/local/share/zsh/site-functions/_rg` | 0644 |
| `complete/rg.fish` | `/usr/local/share/fish/vendor_completions.d/rg.fish` | 0644 |
| `COPYING`, `LICENSE-MIT`, `UNLICENSE` | `/usr/local/share/doc/ripgrep/` | 0644 |
| Source | Destination |
| ------------------------------------- | ---------------------------------------------------- |
| `rg` | `/usr/local/bin/rg` |
| `doc/rg.1` | `/usr/local/share/man/man1/rg.1` |
| `complete/rg.bash` | `/usr/local/share/bash-completion/completions/rg` |
| `complete/_rg` | `/usr/local/share/zsh/site-functions/_rg` |
| `complete/rg.fish` | `/usr/local/share/fish/vendor_completions.d/rg.fish` |
| `COPYING`, `LICENSE-MIT`, `UNLICENSE` | `/usr/local/share/doc/ripgrep/` |
16 changes: 8 additions & 8 deletions features/ripgrep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ COPY --from=ripgrep /features/ripgrep/ /opt/devcontainer-config/features/ripgrep

## Installed files

| Source | Destination | Mode |
| ------------------------------------- | ---------------------------------------------------- | ---- |
| `rg` | `/usr/local/bin/rg` | 0755 |
| `doc/rg.1` | `/usr/local/share/man/man1/rg.1` | 0644 |
| `complete/rg.bash` | `/usr/local/share/bash-completion/completions/rg` | 0644 |
| `complete/_rg` | `/usr/local/share/zsh/site-functions/_rg` | 0644 |
| `complete/rg.fish` | `/usr/local/share/fish/vendor_completions.d/rg.fish` | 0644 |
| `COPYING`, `LICENSE-MIT`, `UNLICENSE` | `/usr/local/share/doc/ripgrep/` | 0644 |
| Source | Destination |
| ------------------------------------- | ---------------------------------------------------- |
| `rg` | `/usr/local/bin/rg` |
| `doc/rg.1` | `/usr/local/share/man/man1/rg.1` |
| `complete/rg.bash` | `/usr/local/share/bash-completion/completions/rg` |
| `complete/_rg` | `/usr/local/share/zsh/site-functions/_rg` |
| `complete/rg.fish` | `/usr/local/share/fish/vendor_completions.d/rg.fish` |
| `COPYING`, `LICENSE-MIT`, `UNLICENSE` | `/usr/local/share/doc/ripgrep/` |

---

Expand Down
2 changes: 1 addition & 1 deletion features/ripgrep/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": 3,
"revision": 4,
"versions": {
"15.2.0": {
"x86_64-unknown-linux-musl": {
Expand Down
2 changes: 1 addition & 1 deletion features/ripgrep/install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

mkdir -p /usr/local/bin
cp -p rg /usr/local/bin/rg
ln -sfn "$PWD/rg" /usr/local/bin/rg

mkdir -p /usr/local/share/man/man1
cp -p doc/rg.1 /usr/local/share/man/man1/rg.1
Expand Down
3 changes: 1 addition & 2 deletions features/uv/Feature/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ private static void InstallBinaries(string stagedDir)
Directory.CreateDirectory(BinDir);
foreach (string binary in Binaries)
{
string target = Path.Join(BinDir, binary);
File.Copy(Path.Join(stagedDir, "uv", binary), target, overwrite: true);
SymbolicLink.Replace(Path.Join(BinDir, binary), Path.Join(stagedDir, "uv", binary));
}
}
}
2 changes: 1 addition & 1 deletion features/uv/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": 2,
"revision": 3,
"components": {
"uv": {
"versions": {
Expand Down
4 changes: 4 additions & 0 deletions scripts/verify/ripgrep/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const defaultExecs = (version: string): Exec[] => [
command: ["sh", "-c", "command -v rg"],
expect: { stdout: ["/usr/local/bin/rg"] },
},
{
command: ["readlink", "-f", "/usr/local/bin/rg"],
expect: { stdout: ["/opt/devcontainer-config/features/ripgrep/rg"] },
},
{
command: ["sh", "-c", "printf 'alpha\\nbeta\\n' | rg beta"],
expect: { stdout: ["beta"] },
Expand Down
9 changes: 8 additions & 1 deletion scripts/verify/uv/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ const binariesExecs = (selection: Selection): Exec[] => [
command: ["sh", "-c", "command -v uv; command -v uvx"],
expect: { stdout: ["/usr/local/bin/uv", "/usr/local/bin/uvx"] },
},
{ command: ["stat", "-c", "%a", "/usr/local/bin/uv", "/usr/local/bin/uvx"], expect: { stdout: ["755", "755"] } },
{
command: ["readlink", "-f", "/usr/local/bin/uv", "/usr/local/bin/uvx"],
expect: { stdout: [`${featureDir}/uv/uv`, `${featureDir}/uv/uvx`] },
},
{
command: ["stat", "-Lc", "%a", "/usr/local/bin/uv", "/usr/local/bin/uvx"],
expect: { stdout: ["755", "755"] },
},
{
command: ["sh", "-c", `for file in ${completionFiles.join(" ")}; do test -s "$file" || exit 1; done; echo present`],
expect: { stdout: ["present"] },
Expand Down
Loading