diff --git a/docs/README.md b/docs/README.md index 3a3933c..16fec5e 100755 --- a/docs/README.md +++ b/docs/README.md @@ -46,23 +46,34 @@ zi pack"5.2.4" for zsh zi pack"5.1.1" for zsh ``` -### Default Profile +### System installation (opt-in) -The ZI command that'll be run will be equivalent to: +By default the package builds Zsh into `$ZPFX` and does **not** touch the system +shell. To also replace `/bin/zsh`, set `ZSH_INSTALL_SYSTEM=1` when installing. +The original is backed up to `/bin/zsh.bkp`; if that backup already exists, +the system replacement step fails instead of overwriting it: ```shell -zi ice as"null" lucid atclone'./.preconfig; print -P %F{208}Building \ - Zsh...%f; CPPFLAGS="-I/usr/include -I/usr/local/include" CFLAGS="-g \ - -O2 -Wall" LDFLAGS="-L/usr/libs -L/usr/local/libs" \ - ./configure --prefix="$ZPFX" --enable-shared >/dev/null && make install.bin install.fns \ - install.modules >/dev/null && sudo rm -f /bin/zsh && sudo cp -vf \ - Src/zsh /bin/zsh && print -P %F{208}The build succeeded.%f || print \ - -P %F{160}The build failed.%f' - atpull"%atclone" nocompile countdown git for \ - zsh-users/zsh +ZSH_INSTALL_SYSTEM=1 zi pack for zsh ``` -It copies the zsh binary onto `/bin/zsh`. +### Default Profile + +The ZI command that runs for the default profile is generated from `scripts/build-manifest.py` and mirrored in `package.json`. + +In short, the default profile: + +- runs `./.preconfig`, then `./configure --prefix="$ZPFX"` +- uses `LDFLAGS="-L/usr/lib -L/usr/local/lib"` +- runs `make install` when `yodl` is available, otherwise falls back to `make install.bin install.fns install.modules` +- installs into `$ZPFX` by default +- copies the built shell to `/bin/zsh` only when `ZSH_INSTALL_SYSTEM=1` is set and `/bin/zsh.bkp` does not already exist + +By default it never replaces `/bin/zsh`. System replacement requires: + +```shell +ZSH_INSTALL_SYSTEM=1 zi pack for zsh +``` ### ZI Completions Control diff --git a/package.json b/package.json index 6809465..e768ebf 100755 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -f /bin/zsh ]] && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -32,7 +32,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.1.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -f /bin/zsh ]] && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.1.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -43,7 +43,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.2.4; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -f /bin/zsh ]] && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.2.4; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -54,7 +54,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.3.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.3.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -65,7 +65,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.4.2; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.4.2; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -76,7 +76,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.5.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.5.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -87,7 +87,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.6.2; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.6.2; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -98,7 +98,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.7.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.7.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -109,7 +109,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.8; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.8; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -120,7 +120,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.8.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.8.1; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", @@ -131,7 +131,7 @@ "git": "", "lucid": "", "as": "null", - "atclone": "git checkout --quiet zsh-5.9; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/libs -L/usr/local/libs' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; ((1)); } && m {ok}The build succeeded. || m {failure}The build failed.", + "atclone": "git checkout --quiet zsh-5.9; ./.preconfig; m {nl}{hi}Building Zsh{…}; CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' LDFLAGS='-L/usr/lib -L/usr/local/lib' ./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && { type yodl >> /dev/null 2>&1 || { m -u2 {warn}WARNING{ehi}:{rst}{warn} No {cmd}yodl{warn}, manual pages will not be built.; ((0)); } && { make install; ((1)); } || make install.bin install.fns install.modules } >> /dev/null 2>&1 && { [[ ${ZSH_INSTALL_SYSTEM:-} != 1 ]] || { type sudo >> /dev/null 2>&1 && [[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && sudo cp -vf Src/zsh /bin/zsh; }; } && m {ok}The build succeeded. || m {failure}The build failed.", "atpull": "%atclone", "nocompile": "", "nocompletions": "", diff --git a/scripts/build-manifest.py b/scripts/build-manifest.py new file mode 100644 index 0000000..926b05c --- /dev/null +++ b/scripts/build-manifest.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""Generate package.json (the Zi package manifest) from a single recipe template. + +Why this exists: the manifest defines one Zi install profile per Zsh version, and +every profile's `atclone` build recipe is identical except for the `git checkout` +line. Hand-maintaining 11 ~600-char copies caused drift (e.g. an inconsistent +`-f /bin/zsh` guard). This script is the single source of truth: edit BUILD / +VERSIONS / METADATA here, run `python3 scripts/build-manifest.py`, and commit the +regenerated package.json. + +Notes on the recipe: +- Builds into $ZPFX (the Zi prefix) via `./configure --prefix="$ZPFX"`. +- Replacing the *system* /bin/zsh is opt-in: it only happens when the installer + sets `ZSH_INSTALL_SYSTEM=1`. By default the + package never touches /bin/zsh. +""" +import json +import pathlib + +METADATA = { + "name": "zsh", + "description": "Zsh – the programmer's shell", + "homepage": "https://github.com/zsh-users/zsh", + "bugs": {"url": "https://github.com/zsh-users/zsh/issues"}, + "keywords": ["zpackage", "zshell", "zsh"], +} + +PLUGIN_INFO = {"user": "zsh-users", "plugin": "zsh"} + +# Selectable version profiles, in addition to the unpinned "default". +VERSIONS = ["5.1.1", "5.2.4", "5.3.1", "5.4.2", "5.5.1", "5.6.2", + "5.7.1", "5.8", "5.8.1", "5.9"] + +# Single source of truth for the build recipe. `{checkout}` is replaced per +# profile (empty for "default"). +BUILD = ( + "{checkout}" + "./.preconfig; m {{nl}}{{hi}}Building Zsh{{…}}; " + "CPPFLAGS='-I/usr/include -I/usr/local/include' CFLAGS='-g -O2 -Wall' " + "LDFLAGS='-L/usr/lib -L/usr/local/lib' " + "./configure --prefix=\"$ZPFX\" >> /dev/null 2>&1 && " + "{{ type yodl >> /dev/null 2>&1 || {{ m -u2 {{warn}}WARNING{{ehi}}:{{rst}}{{warn}} " + "No {{cmd}}yodl{{warn}}, manual pages will not be built.; ((0)); }} && " + "{{ make install; ((1)); }} || make install.bin install.fns install.modules }} " + ">> /dev/null 2>&1 && " + "{{ [[ ${{ZSH_INSTALL_SYSTEM:-}} != 1 ]] || {{ type sudo >> /dev/null 2>&1 && " + "[[ -e /bin/zsh ]] && [[ ! -e /bin/zsh.bkp ]] && sudo mv /bin/zsh /bin/zsh.bkp && " + "sudo cp -vf Src/zsh /bin/zsh; }}; }} && m {{ok}}The build succeeded. || m {{failure}}The build failed." +) + + +def ice(checkout: str) -> dict: + return { + "requires": "cc;make;cp;rm", + "git": "", + "lucid": "", + "as": "null", + "atclone": BUILD.format(checkout=checkout), + "atpull": "%atclone", + "nocompile": "", + "nocompletions": "", + "countdown": "", + } + + +def main() -> None: + ices = {"default": ice("")} + for v in VERSIONS: + ices[v] = ice(f"git checkout --quiet zsh-{v}; ") + + manifest = dict(METADATA) + manifest["zsh-data"] = {"plugin-info": PLUGIN_INFO, "zi-ices": ices} + + out = pathlib.Path(__file__).resolve().parent.parent / "package.json" + out.write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n", + encoding="utf-8") + print(f"Wrote {out} with {len(ices)} profiles (default + {len(VERSIONS)} versions).") + + +if __name__ == "__main__": + main()