Skip to content

Commit ce6318a

Browse files
author
Pablo Lezaeta
committed
install(ps1): XDG-aware mapping, create dirs, dotify unmapped root files, skip etc/ and README.md
1 parent 1639d23 commit ce6318a

File tree

7 files changed

+64
-6
lines changed

7 files changed

+64
-6
lines changed

.githooks/post-checkout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
3+
git lfs post-checkout "$@"

.githooks/post-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
3+
git lfs post-commit "$@"

.githooks/post-merge

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
3+
git lfs post-merge "$@"

.githooks/pre-push

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
command -v git-lfs >/dev/null 2>&1 || { printf >&2 "\n%s\n\n" "This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks')."; exit 2; }
3+
git lfs pre-push "$@"

distros/PKGBUILD/micropolis-java

Submodule micropolis-java updated from ceeadbb to 0d96f11
Submodule xapp-symbolic-icons updated from 3c1110e to 6100cab

scripts/install.ps1

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ if ($Modules.Count -eq 0) {
1717
$Modules = @('modules/shell/bash','modules/shell/zsh','modules/apps/tmux','modules/apps/xmms')
1818
}
1919

20+
# XDG fallback variables (Windows: prefer APPDATA / LOCALAPPDATA but respect XDG vars if set)
21+
$HOME = $env:USERPROFILE
22+
$XDG_CONFIG_HOME = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } elseif ($env:APPDATA) { $env:APPDATA } else { Join-Path $HOME '.config' }
23+
$XDG_DATA_HOME = if ($env:XDG_DATA_HOME) { $env:XDG_DATA_HOME } elseif ($env:LOCALAPPDATA) { $env:LOCALAPPDATA } else { Join-Path $HOME '.local\share' }
24+
$XDG_STATE_HOME = if ($env:XDG_STATE_HOME) { $env:XDG_STATE_HOME } elseif ($env:LOCALAPPDATA) { $env:LOCALAPPDATA } else { Join-Path $HOME '.local\state' }
25+
2026
if (-not (Test-GitLFS)) {
2127
Write-Warning "git-lfs no disponible; algunas características (LFS) pueden no funcionar"
2228
}
@@ -27,12 +33,50 @@ foreach ($module in $Modules) {
2733
Write-Host "Advertencia: módulo $modulePath no existe" -ForegroundColor Yellow
2834
continue
2935
}
36+
# Safety: skip modules that contain system-level paths (etc/) — installer doesn't touch /etc
37+
if (Get-ChildItem -Path $modulePath -Recurse -File | Where-Object { $_.FullName -like '*\\etc\\*' }) {
38+
Write-Host "Skipping module $modulePath because it contains system-level files under 'etc/'." -ForegroundColor Yellow
39+
continue
40+
}
41+
42+
# Map target path for a module relative file (respect XDG where applicable)
43+
function Map-Target {
44+
param($relPath, $moduleName)
45+
# nested paths -> keep relative under HOME
46+
if ($relPath -match '\\') { return Join-Path $HOME $relPath }
47+
# dotfile already? place under HOME directly
48+
if ($relPath -match '^\.') { return Join-Path $HOME $relPath }
49+
switch -regex ($relPath) {
50+
'^config\.fish$' { return Join-Path $XDG_CONFIG_HOME 'fish\\config.fish' }
51+
'^init\.vim$' { return Join-Path $XDG_CONFIG_HOME 'nvim\\init.vim' }
52+
'^settings\.json$' {
53+
if ($moduleName -match 'vscode') { return Join-Path $XDG_CONFIG_HOME 'Code\\User\\settings.json' }
54+
if ($moduleName -match 'micro') { return Join-Path $XDG_CONFIG_HOME 'micro\\settings.json' }
55+
return Join-Path $HOME $relPath
56+
}
57+
'^config\.json$' { if ($moduleName -match 'micro') { return Join-Path $XDG_CONFIG_HOME 'micro\\config.json' } else { return Join-Path $HOME $relPath } }
58+
'^init\.el$' { if ($moduleName -match 'emacs') { return Join-Path $HOME '.emacs.d\\init.el' } else { return Join-Path $HOME $relPath } }
59+
'^config\.toml$' {
60+
if ($moduleName -match 'helix') { return Join-Path $XDG_CONFIG_HOME 'helix\\config.toml' }
61+
if ($moduleName -match 'nushell') { return Join-Path $XDG_CONFIG_HOME 'nushell\\config.toml' }
62+
return Join-Path $HOME $relPath
63+
}
64+
'^kakrc$' { return Join-Path $XDG_CONFIG_HOME 'kak\\kakrc' }
65+
'^kateconfig$' { return Join-Path $XDG_CONFIG_HOME 'kate\\kateconfig' }
66+
'^gedit-settings\.xml$' { return Join-Path $XDG_CONFIG_HOME 'gedit\\gedit-settings.xml' }
67+
'^chrome-flags\.conf$' { return Join-Path $XDG_CONFIG_HOME 'chrome\\chrome-flags.conf' }
68+
default { return Join-Path $HOME ('.' + $relPath) }
69+
}
70+
}
71+
3072
# Phase 1 - collect all files and detect conflicts
3173
$allFiles = Get-ChildItem -Path $modulePath -File -Recurse
3274
$conflicts = @()
3375
foreach ($f in $allFiles) {
34-
$rel = $f.FullName.Substring($modulePath.Length).TrimStart('\')
35-
$dest = Join-Path $env:USERPROFILE $rel
76+
# Skip README and module docs — not intended to be linked into $HOME
77+
if ($f.Name -ieq 'README.md') { continue }
78+
$rel = $f.FullName.Substring($modulePath.Length).TrimStart('\\')
79+
$dest = Map-Target -relPath $rel -moduleName (Split-Path $module -Leaf)
3680
$destDir = Split-Path $dest -Parent
3781
if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Force -Path $destDir | Out-Null }
3882
if (Test-Path $dest) {
@@ -66,8 +110,10 @@ foreach ($module in $Modules) {
66110
}
67111
# After resolving conflicts, create symlinks for all files
68112
foreach ($f in $allFiles) {
69-
$rel = $f.FullName.Substring($modulePath.Length).TrimStart('\')
70-
$dest = Join-Path $env:USERPROFILE $rel
113+
# Skip README and module docs — not intended to be linked into $HOME
114+
if ($f.Name -ieq 'README.md') { continue }
115+
$rel = $f.FullName.Substring($modulePath.Length).TrimStart('\\')
116+
$dest = Map-Target -relPath $rel -moduleName (Split-Path $module -Leaf)
71117
$destDir = Split-Path $dest -Parent
72118
if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Force -Path $destDir | Out-Null }
73119
if (Test-Path $dest) { Remove-Item -Recurse -Force -Path $dest -ErrorAction SilentlyContinue }

0 commit comments

Comments
 (0)