mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-15 19:06:19 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d7c7074457 | ||
![]() |
5f4fd52e38 | ||
![]() |
1b25190176 | ||
![]() |
030e6af880 | ||
![]() |
662d6c5274 | ||
![]() |
3de03e8b1f | ||
![]() |
720b7c9b05 | ||
![]() |
0ea7e9e0e5 | ||
![]() |
be5f54c95c | ||
![]() |
5c6e13a672 |
11
Makefile
11
Makefile
@@ -1,6 +1,6 @@
|
|||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
|
|
||||||
V=1.0.2
|
V=1.0.3
|
||||||
BUILDTOOLVER ?= $(V)
|
BUILDTOOLVER ?= $(V)
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
@@ -17,7 +17,6 @@ LIBRARY = $(addprefix $(BUILDDIR)/,$(patsubst src/%,%,$(patsubst %.in,%,$(LIBRAR
|
|||||||
MAKEPKG_CONFIGS=$(wildcard config/makepkg/*)
|
MAKEPKG_CONFIGS=$(wildcard config/makepkg/*)
|
||||||
PACMAN_CONFIGS=$(wildcard config/pacman/*)
|
PACMAN_CONFIGS=$(wildcard config/pacman/*)
|
||||||
SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
|
SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
|
||||||
INIT_SCRIPTS = $(wildcard config/init.d/*)
|
|
||||||
MANS = $(addprefix $(BUILDDIR)/,$(patsubst %.asciidoc,%,$(wildcard doc/man/*.asciidoc)))
|
MANS = $(addprefix $(BUILDDIR)/,$(patsubst %.asciidoc,%,$(wildcard doc/man/*.asciidoc)))
|
||||||
|
|
||||||
COMMITPKG_LINKS = \
|
COMMITPKG_LINKS = \
|
||||||
@@ -90,7 +89,6 @@ endef
|
|||||||
|
|
||||||
$(eval $(call buildInScript,build/bin,src/,.in,755))
|
$(eval $(call buildInScript,build/bin,src/,.in,755))
|
||||||
$(eval $(call buildInScript,build/lib,src/lib/,,644))
|
$(eval $(call buildInScript,build/lib,src/lib/,,644))
|
||||||
$(eval $(call buildInScript,build/init.d,config/init.d/,,644))
|
|
||||||
$(foreach completion,$(wildcard contrib/completion/*),$(eval $(call buildInScript,build/$(completion),$(completion)/,.in,444)))
|
$(foreach completion,$(wildcard contrib/completion/*),$(eval $(call buildInScript,build/$(completion),$(completion)/,.in,444)))
|
||||||
|
|
||||||
$(BUILDDIR)/doc/man/%: doc/man/%.asciidoc doc/asciidoc.conf doc/man/include/footer.asciidoc
|
$(BUILDDIR)/doc/man/%: doc/man/%.asciidoc doc/asciidoc.conf doc/man/include/footer.asciidoc
|
||||||
@@ -102,8 +100,6 @@ conf:
|
|||||||
@install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/pacman.conf.d
|
@install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/pacman.conf.d
|
||||||
@cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
|
@cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
|
||||||
@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
|
@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
|
||||||
@install -d $(BUILDDIR)/init.d
|
|
||||||
@cp -a $(INIT_SCRIPTS) $(BUILDDIR)/init.d
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILDDIR)
|
rm -rf $(BUILDDIR)
|
||||||
@@ -113,14 +109,12 @@ install: all
|
|||||||
install -dm0755 $(DESTDIR)$(DATADIR)/setarch-aliases.d
|
install -dm0755 $(DESTDIR)$(DATADIR)/setarch-aliases.d
|
||||||
install -dm0755 $(DESTDIR)$(DATADIR)/makepkg.conf.d
|
install -dm0755 $(DESTDIR)$(DATADIR)/makepkg.conf.d
|
||||||
install -dm0755 $(DESTDIR)$(DATADIR)/pacman.conf.d
|
install -dm0755 $(DESTDIR)$(DATADIR)/pacman.conf.d
|
||||||
install -dm0755 $(DESTDIR)$(DATADIR)/init.d
|
|
||||||
install -m0755 ${BINPROGS} $(DESTDIR)$(PREFIX)/bin
|
install -m0755 ${BINPROGS} $(DESTDIR)$(PREFIX)/bin
|
||||||
install -dm0755 $(DESTDIR)$(DATADIR)/lib
|
install -dm0755 $(DESTDIR)$(DATADIR)/lib
|
||||||
cp -ra $(BUILDDIR)/lib/* $(DESTDIR)$(DATADIR)/lib
|
cp -ra $(BUILDDIR)/lib/* $(DESTDIR)$(DATADIR)/lib
|
||||||
for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
|
for conf in $(notdir $(MAKEPKG_CONFIGS)); do install -Dm0644 $(BUILDDIR)/makepkg.conf.d/$$conf $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
|
||||||
for conf in $(notdir $(PACMAN_CONFIGS)); do install -Dm0644 $(BUILDDIR)/pacman.conf.d/$$conf $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
|
for conf in $(notdir $(PACMAN_CONFIGS)); do install -Dm0644 $(BUILDDIR)/pacman.conf.d/$$conf $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
|
||||||
for a in ${SETARCH_ALIASES}; do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
|
for a in ${SETARCH_ALIASES}; do install -m0644 $$a -t $(DESTDIR)$(DATADIR)/setarch-aliases.d; done
|
||||||
for f in $(notdir ${INIT_SCRIPTS}); do install -m0644 $(BUILDDIR)/init.d/$$f -t $(DESTDIR)$(DATADIR)/init.d; done
|
|
||||||
for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done
|
for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done
|
||||||
for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done
|
for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done
|
||||||
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
|
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
|
||||||
@@ -138,7 +132,6 @@ uninstall:
|
|||||||
for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
|
for conf in $(notdir $(MAKEPKG_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/makepkg.conf.d/$${conf##*/}; done
|
||||||
for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
|
for conf in $(notdir $(PACMAN_CONFIGS)); do rm -f $(DESTDIR)$(DATADIR)/pacman.conf.d/$${conf##*/}; done
|
||||||
for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
|
for f in $(notdir $(SETARCH_ALIASES)); do rm -f $(DESTDIR)$(DATADIR)/setarch-aliases.d/$$f; done
|
||||||
for f in $(notdir $(INIT_SCRIPTS)); do rm -f $(DESTDIR)$(DATADIR)/init.d/$$f; done
|
|
||||||
for l in ${COMMITPKG_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
|
for l in ${COMMITPKG_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
|
||||||
for l in ${ARCHBUILD_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
|
for l in ${ARCHBUILD_LINKS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$l; done
|
||||||
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
|
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/devtools
|
||||||
@@ -160,7 +153,7 @@ tag:
|
|||||||
git tag --sign --message "Version v$$VERSION" v$$VERSION
|
git tag --sign --message "Version v$$VERSION" v$$VERSION
|
||||||
|
|
||||||
release: dist
|
release: dist
|
||||||
glab release create v$(RELEASE) devtools-$(RELEASE).tar.gz*
|
glab release create v$(V) devtools-$(V).tar.gz*
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
git archive --format=tar --prefix=devtools-$(V)/ v$(V) | gzip > devtools-$(V).tar.gz
|
git archive --format=tar --prefix=devtools-$(V)/ v$(V) | gzip > devtools-$(V).tar.gz
|
||||||
|
@@ -42,8 +42,8 @@ will automatically build the project and proxy all calls to the local build dire
|
|||||||
- binutils
|
- binutils
|
||||||
- coreutils
|
- coreutils
|
||||||
- diffutils
|
- diffutils
|
||||||
|
- fakeroot
|
||||||
- findutils
|
- findutils
|
||||||
- fzf
|
|
||||||
- grep
|
- grep
|
||||||
- jq
|
- jq
|
||||||
- ncurses
|
- ncurses
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
function pkgctl {
|
|
||||||
local cmd cmd_file code
|
|
||||||
cmd_file=$(mktemp --tmpdir "pkgctl.outcmd.XXXXXXXXXX")
|
|
||||||
|
|
||||||
if PKGCTL_OUTCMD="${cmd_file}" command pkgctl "$@"; then
|
|
||||||
cmd=$(<"$cmd_file")
|
|
||||||
command rm -f "$cmd_file"
|
|
||||||
eval "$cmd"
|
|
||||||
else
|
|
||||||
code=$?
|
|
||||||
command rm -f "$cmd_file"
|
|
||||||
return "$code"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#\builtin alias pkgctl=__pkgctl
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
#
|
|
||||||
# To initialize pkgctl, add this to your configuration (usually ~/.zshrc):
|
|
||||||
#
|
|
||||||
# eval "$(pkgctl init bash)"
|
|
@@ -1,28 +0,0 @@
|
|||||||
# This script was automatically generated by pkgctl
|
|
||||||
# This function starts pkgctl and executes the command
|
|
||||||
# it produces, if any.
|
|
||||||
# It's needed because some shell commands, like `cd`,
|
|
||||||
# have no useful effect if executed in a subshell.
|
|
||||||
function pkgctl {
|
|
||||||
local cmd cmd_file code
|
|
||||||
cmd_file=$(mktemp --tmpdir "pkgctl.outcmd.XXXXXXXXXX")
|
|
||||||
|
|
||||||
if PKGCTL_OUTCMD="${cmd_file}" command pkgctl "$@"; then
|
|
||||||
cmd=$(<"$cmd_file")
|
|
||||||
command rm -f "$cmd_file"
|
|
||||||
eval "$cmd"
|
|
||||||
else
|
|
||||||
code=$?
|
|
||||||
command rm -f "$cmd_file"
|
|
||||||
return "$code"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#\builtin alias pkgctl=__pkgctl
|
|
||||||
#\compdef __pkgctl=pkgctl
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
#
|
|
||||||
# To initialize pkgctl, add this to your configuration (usually ~/.zshrc):
|
|
||||||
#
|
|
||||||
# eval "$(pkgctl init zsh)"
|
|
@@ -135,7 +135,6 @@ _pkgctl_cmds=(
|
|||||||
release
|
release
|
||||||
repo
|
repo
|
||||||
version
|
version
|
||||||
workspace
|
|
||||||
)
|
)
|
||||||
_pkgctl_args=(
|
_pkgctl_args=(
|
||||||
-V --version
|
-V --version
|
||||||
@@ -323,103 +322,6 @@ _pkgctl_repo_web_args=(
|
|||||||
_pkgctl_repo_web_opts() { _filedir -d; }
|
_pkgctl_repo_web_opts() { _filedir -d; }
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_cmds=(
|
|
||||||
add
|
|
||||||
cd
|
|
||||||
list
|
|
||||||
remove
|
|
||||||
show
|
|
||||||
switch
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_add_args=(
|
|
||||||
-f --force
|
|
||||||
-s --switch
|
|
||||||
-c --cd
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
_pkgctl_workspace_add_opts() {
|
|
||||||
local subcommand args
|
|
||||||
subcommand=(workspace add)
|
|
||||||
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
|
||||||
|
|
||||||
if (( args == 0 )); then
|
|
||||||
:
|
|
||||||
elif (( args == 1 )); then
|
|
||||||
_filedir -d;
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_cd_args=(
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
_pkgctl_workspace_cd_opts() {
|
|
||||||
local subcommand args
|
|
||||||
subcommand=(workspace cd)
|
|
||||||
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
|
||||||
|
|
||||||
if (( args == 0 )); then
|
|
||||||
_devtools_completions_all_workspaces
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_list_args=(
|
|
||||||
-n --name
|
|
||||||
-p --path
|
|
||||||
-l --local
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_remove_args=(
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
_pkgctl_workspace_remove_opts() {
|
|
||||||
local subcommand args
|
|
||||||
subcommand=(workspace remove)
|
|
||||||
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
|
||||||
|
|
||||||
if (( args == 0 )); then
|
|
||||||
_devtools_completions_local_workspaces
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_show_args=(
|
|
||||||
-n --name
|
|
||||||
-p --path
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
_pkgctl_workspace_show_opts() {
|
|
||||||
local subcommand args
|
|
||||||
subcommand=(workspace show)
|
|
||||||
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
|
||||||
|
|
||||||
if (( args == 0 )); then
|
|
||||||
_devtools_completions_all_workspaces
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_workspace_switch_args=(
|
|
||||||
-i --interactive
|
|
||||||
-c --cd
|
|
||||||
-h --help
|
|
||||||
)
|
|
||||||
_pkgctl_workspace_switch_opts() {
|
|
||||||
local subcommand args
|
|
||||||
subcommand=(workspace switch)
|
|
||||||
args=$(__pkgctl_word_count_after_subcommand "${subcommand[@]}")
|
|
||||||
|
|
||||||
if (( args == 0 )); then
|
|
||||||
_devtools_completions_all_workspaces
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_pkgctl_diff_args=(
|
_pkgctl_diff_args=(
|
||||||
-l --list
|
-l --list
|
||||||
-d --diffoscope
|
-d --diffoscope
|
||||||
@@ -465,12 +367,6 @@ _devtools_completions_build_repo() {
|
|||||||
_devtools_completions_all_packages() {
|
_devtools_completions_all_packages() {
|
||||||
mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur")
|
mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur")
|
||||||
}
|
}
|
||||||
_devtools_completions_all_workspaces() {
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "$(pkgctl workspace list --name)" -- "$cur")
|
|
||||||
}
|
|
||||||
_devtools_completions_local_workspaces() {
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "$(pkgctl workspace list --local --name)" -- "$cur")
|
|
||||||
}
|
|
||||||
_devtools_completions_protocol() {
|
_devtools_completions_protocol() {
|
||||||
mapfile -t COMPREPLY < <(compgen -W "https" -- "$cur")
|
mapfile -t COMPREPLY < <(compgen -W "https" -- "$cur")
|
||||||
}
|
}
|
||||||
|
@@ -134,56 +134,6 @@ _pkgctl_repo_web_args=(
|
|||||||
'*:git_dir:_files -/'
|
'*:git_dir:_files -/'
|
||||||
)
|
)
|
||||||
|
|
||||||
_pkgctl_workspace_cmds=(
|
|
||||||
"pkgctl workspace command"
|
|
||||||
"add[TODO a]"
|
|
||||||
"cd[TODO a]"
|
|
||||||
"list[TODO a]"
|
|
||||||
"remove[TODO a]"
|
|
||||||
"show[TODOa a]"
|
|
||||||
"switch[TODO a]"
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_add_args=(
|
|
||||||
'(-f --force)'{-f,--force}'[TODO name]'
|
|
||||||
'(-s --switch)'{-s,--switch}'[TODO path]'
|
|
||||||
'(-c --cd)'{-c,--cd}'[TODO path]'
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
'1:workspace'
|
|
||||||
'2:path:_files -/'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_cd_args=(
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
'1:workspace:_devtools_completions_all_workspaces'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_list_args=(
|
|
||||||
'(-n --name)'{-n,--name}'[TODO name]'
|
|
||||||
'(-p --path)'{-p,--path}'[TODO path]'
|
|
||||||
'(-l --local)'{-l,--local}'[TODO path]'
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_remove_args=(
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
'1:workspace:_devtools_completions_local_workspaces'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_show_args=(
|
|
||||||
'(-n --name)'{-n,--name}'[TODO name]'
|
|
||||||
'(-p --path)'{-p,--path}'[TODO path]'
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
'1:workspace:_devtools_completions_all_workspaces'
|
|
||||||
)
|
|
||||||
|
|
||||||
_pkgctl_workspace_switch_args=(
|
|
||||||
'(-i --interactive)'{-i,--interactive}'[TODO]'
|
|
||||||
'(-c --cd)'{-c,--cd}'[TODO]'
|
|
||||||
'(-h --help)'{-h,--help}'[Display usage]'
|
|
||||||
'1:workspace:_devtools_completions_all_workspaces'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arch_nspawn_args=(
|
_arch_nspawn_args=(
|
||||||
'-C[Location of a pacman config file]:pacman_config:_files -g "*.conf(.)"'
|
'-C[Location of a pacman config file]:pacman_config:_files -g "*.conf(.)"'
|
||||||
'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
|
'-M[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
|
||||||
@@ -287,28 +237,15 @@ _devtools_completions_all_packages() {
|
|||||||
compadd - "${(@)packages}"
|
compadd - "${(@)packages}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_devtools_completions_all_workspaces() {
|
|
||||||
typeset -U workspaces
|
|
||||||
workspaces=($(_call_program workspaces pkgctl workspace list --name))
|
|
||||||
compadd - "${(@)workspaces}"
|
|
||||||
}
|
|
||||||
|
|
||||||
_devtools_completions_local_workspaces() {
|
|
||||||
typeset -U local_workspaces
|
|
||||||
local_workspaces=($(_call_program local_workspaces pkgctl workspace list --local --name))
|
|
||||||
compadd - "${(@)local_workspaces}"
|
|
||||||
}
|
|
||||||
|
|
||||||
_pkgctl_cmds=(
|
_pkgctl_cmds=(
|
||||||
"pkgctl command"
|
"pkgctl command"
|
||||||
"auth[Authenticate with services like GitLab]"
|
"auth[Authenticate with services like GitLab]"
|
||||||
"build[Build packages inside a clean chroot]"
|
"build[Build packages inside a clean chroot]"
|
||||||
"db[Pacman database modification for packge update, move etc]"
|
"db[Pacman database modification for package update, move etc]"
|
||||||
"diff[Compare package files using different modes]"
|
"diff[Compare package files using different modes]"
|
||||||
"release[Release step to commit, tag and upload build artifacts]"
|
"release[Release step to commit, tag and upload build artifacts]"
|
||||||
"repo[Manage Git packaging repositories and their configuration]"
|
"repo[Manage Git packaging repositories and their configuration]"
|
||||||
"version[Show pkgctl version information]"
|
"version[Show pkgctl version information]"
|
||||||
"workspace[TODO]"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_pkgctl_args=(
|
_pkgctl_args=(
|
||||||
|
@@ -33,7 +33,7 @@ pkgctl build::
|
|||||||
Build packages inside a clean chroot
|
Build packages inside a clean chroot
|
||||||
|
|
||||||
pkgctl db::
|
pkgctl db::
|
||||||
Pacman database modification for packge update, move etc
|
Pacman database modification for package update, move etc
|
||||||
|
|
||||||
pkgctl diff::
|
pkgctl diff::
|
||||||
Compare package files using different modes
|
Compare package files using different modes
|
||||||
|
@@ -16,7 +16,6 @@ umask 0022
|
|||||||
working_dir=''
|
working_dir=''
|
||||||
|
|
||||||
files=()
|
files=()
|
||||||
mount_args=()
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
|
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
|
||||||
@@ -56,6 +55,16 @@ shift 1
|
|||||||
|
|
||||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||||
|
|
||||||
|
nspawn_args=(
|
||||||
|
--quiet
|
||||||
|
--directory="$working_dir"
|
||||||
|
--setenv="PATH=/usr/local/sbin:/usr/local/bin:/usr/bin"
|
||||||
|
--register=no
|
||||||
|
--slice="devtools-$(systemd-escape "${SUDO_USER:-$USER}")"
|
||||||
|
--machine="arch-nspawn-$$"
|
||||||
|
--as-pid2
|
||||||
|
)
|
||||||
|
|
||||||
if (( ${#cache_dirs[@]} == 0 )); then
|
if (( ${#cache_dirs[@]} == 0 )); then
|
||||||
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
|
mapfile -t cache_dirs < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
|
||||||
fi
|
fi
|
||||||
@@ -83,10 +92,10 @@ while read -r line; do
|
|||||||
done
|
done
|
||||||
done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
|
done < <(pacman-conf --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
|
||||||
|
|
||||||
mount_args+=("--bind=${cache_dirs[0]//:/\\:}")
|
nspawn_args+=(--bind="${cache_dirs[0]//:/\\:}")
|
||||||
|
|
||||||
for cache_dir in "${cache_dirs[@]:1}"; do
|
for cache_dir in "${cache_dirs[@]:1}"; do
|
||||||
mount_args+=("--bind-ro=${cache_dir//:/\\:}")
|
nspawn_args+=(--bind-ro="${cache_dir//:/\\:}")
|
||||||
done
|
done
|
||||||
|
|
||||||
# {{{ functions
|
# {{{ functions
|
||||||
@@ -129,9 +138,4 @@ else
|
|||||||
set_arch="${CARCH}"
|
set_arch="${CARCH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec ${CARCH:+setarch "$set_arch"} systemd-nspawn -q \
|
exec ${CARCH:+setarch "$set_arch"} systemd-nspawn "${nspawn_args[@]}" "$@"
|
||||||
-D "$working_dir" \
|
|
||||||
-E "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \
|
|
||||||
--register=no --keep-unit --as-pid2 \
|
|
||||||
"${mount_args[@]}" \
|
|
||||||
"$@"
|
|
||||||
|
@@ -7,6 +7,8 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||||
# shellcheck source=src/lib/valid-tags.sh
|
# shellcheck source=src/lib/valid-tags.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh
|
||||||
|
# shellcheck source=src/lib/util/git.sh
|
||||||
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -55,8 +57,8 @@ gittag=$(get_tag_from_pkgver "$pkgver")
|
|||||||
if ! branchname=$(git symbolic-ref --short HEAD); then
|
if ! branchname=$(git symbolic-ref --short HEAD); then
|
||||||
die 'not on any branch'
|
die 'not on any branch'
|
||||||
fi
|
fi
|
||||||
if [[ "${branchname}" != main ]]; then
|
if ! is_valid_release_branch "${branchname}"; then
|
||||||
die 'must be run from the main branch'
|
die 'must be run from a valid release branch (%s)' "${VALID_RELEASE_BRANCHES[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if remote origin is setup properly
|
# Check if remote origin is setup properly
|
||||||
@@ -85,10 +87,10 @@ if git tag --verify "$gittag" &> /dev/null; then
|
|||||||
if [[ "$cwd_checksum" != "$tag_checksum" ]]; then
|
if [[ "$cwd_checksum" != "$tag_checksum" ]]; then
|
||||||
die "tagged PKGBUILD is not the same as the working dir PKGBUILD"
|
die "tagged PKGBUILD is not the same as the working dir PKGBUILD"
|
||||||
fi
|
fi
|
||||||
git push --tags --set-upstream origin main || abort
|
git push --tags --set-upstream origin "${branchname}" || abort
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg "Releasing package"
|
msg "Releasing package"
|
||||||
git tag --sign --message="Package release ${pkgver}" "$gittag" || abort
|
git tag --sign --message="Package release ${pkgver}" "$gittag" || abort
|
||||||
git push --tags --set-upstream origin main || abort
|
git push --tags --set-upstream origin "${branchname}" || abort
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||||
# shellcheck source=src/lib/common.sh
|
# shellcheck source=src/lib/common.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||||
|
# shellcheck source=src/lib/util/git.sh
|
||||||
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||||
|
|
||||||
source /usr/share/makepkg/util/util.sh
|
source /usr/share/makepkg/util/util.sh
|
||||||
|
|
||||||
@@ -70,8 +72,12 @@ if ! repo_spec=$(git config --local devtools.version) || [[ ${repo_spec} != "${G
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$(git symbolic-ref --short HEAD)" != main ]]; then
|
if ! branchname=$(git symbolic-ref --short HEAD); then
|
||||||
die 'must be run from the main branch'
|
die 'not on any branch'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! is_valid_release_branch "${branchname}"; then
|
||||||
|
die 'must be run from a valid release branch (%s)' "${VALID_RELEASE_BRANCHES[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source=()
|
source=()
|
||||||
@@ -95,6 +101,9 @@ case "$cmd" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "${branchname}" == "unstable" ]] && [[ "$repo" != *"unstable" ]]; then
|
||||||
|
die 'Cannot release from unstable branch into non-unstable repo: %s' "${repo}"
|
||||||
|
fi
|
||||||
|
|
||||||
if (( ${#validpgpkeys[@]} != 0 )); then
|
if (( ${#validpgpkeys[@]} != 0 )); then
|
||||||
if [[ -d keys ]]; then
|
if [[ -d keys ]]; then
|
||||||
@@ -111,7 +120,7 @@ if (( ${#validpgpkeys[@]} != 0 )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# find files which should be under source control
|
# find files which should be under source control
|
||||||
needsversioning=()
|
needsversioning=(PKGBUILD)
|
||||||
for s in "${source[@]}"; do
|
for s in "${source[@]}"; do
|
||||||
[[ $s != *://* ]] && needsversioning+=("$s")
|
[[ $s != *://* ]] && needsversioning+=("$s")
|
||||||
done
|
done
|
||||||
|
@@ -16,8 +16,6 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/release.sh
|
|||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||||
# shellcheck source=src/lib/util/pacman.sh
|
# shellcheck source=src/lib/util/pacman.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/pacman.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/pacman.sh
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
# shellcheck source=src/lib/valid-repos.sh
|
# shellcheck source=src/lib/valid-repos.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
|
||||||
# shellcheck source=src/lib/valid-tags.sh
|
# shellcheck source=src/lib/valid-tags.sh
|
||||||
@@ -131,7 +129,7 @@ pkgctl_build() {
|
|||||||
local WORKER_SLOT=
|
local WORKER_SLOT=
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
local path pkgbase pkgrepo source
|
local loop_arch path pkgbase pkgrepo source
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
case $1 in
|
case $1 in
|
||||||
@@ -280,8 +278,6 @@ pkgctl_build() {
|
|||||||
die "Invalid repository target: %s" "${REPO}"
|
die "Invalid repository target: %s" "${REPO}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enter_workspace
|
|
||||||
|
|
||||||
for path in "${paths[@]}"; do
|
for path in "${paths[@]}"; do
|
||||||
pushd "${path}" >/dev/null
|
pushd "${path}" >/dev/null
|
||||||
|
|
||||||
@@ -322,7 +318,13 @@ pkgctl_build() {
|
|||||||
if in_array any "${arch[@]}"; then
|
if in_array any "${arch[@]}"; then
|
||||||
BUILD_ARCH=("${_arch[0]}")
|
BUILD_ARCH=("${_arch[0]}")
|
||||||
else
|
else
|
||||||
BUILD_ARCH+=("${arch[@]}")
|
for loop_arch in "${arch[@]}"; do
|
||||||
|
if in_array "${loop_arch}" "${_arch[@]}"; then
|
||||||
|
BUILD_ARCH+=("$loop_arch")
|
||||||
|
else
|
||||||
|
warning 'invalid architecture, not building for: %s' "${loop_arch}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -333,7 +335,7 @@ pkgctl_build() {
|
|||||||
|
|
||||||
# increment pkgrel on rebuild
|
# increment pkgrel on rebuild
|
||||||
if (( REBUILD )); then
|
if (( REBUILD )); then
|
||||||
# try to figure out of pkgrel has been changed
|
# try to figure out if pkgrel has been changed
|
||||||
if ! old_pkgrel=$(git_diff_tree HEAD PKGBUILD | grep --perl-regexp --only-matching --max-count=1 '^-pkgrel=\K\w+'); then
|
if ! old_pkgrel=$(git_diff_tree HEAD PKGBUILD | grep --perl-regexp --only-matching --max-count=1 '^-pkgrel=\K\w+'); then
|
||||||
old_pkgrel=${pkgrel}
|
old_pkgrel=${pkgrel}
|
||||||
fi
|
fi
|
||||||
|
@@ -29,6 +29,8 @@ export GIT_PACKAGING_URL_SSH="git@${GITLAB_HOST}:${GIT_PACKAGING_NAMESPACE}"
|
|||||||
export GIT_PACKAGING_URL_HTTPS="https://${GITLAB_HOST}/${GIT_PACKAGING_NAMESPACE}"
|
export GIT_PACKAGING_URL_HTTPS="https://${GITLAB_HOST}/${GIT_PACKAGING_NAMESPACE}"
|
||||||
export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org
|
export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org
|
||||||
|
|
||||||
|
export VALID_RELEASE_BRANCHES=(main unstable)
|
||||||
|
|
||||||
# check if messages are to be printed using color
|
# check if messages are to be printed using color
|
||||||
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
|
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
|
||||||
colorize
|
colorize
|
||||||
|
@@ -15,7 +15,7 @@ pkgctl_db_usage() {
|
|||||||
cat <<- _EOF_
|
cat <<- _EOF_
|
||||||
Usage: ${COMMAND} [COMMAND] [OPTIONS]
|
Usage: ${COMMAND} [COMMAND] [OPTIONS]
|
||||||
|
|
||||||
Pacman database modification for packge update, move etc
|
Pacman database modification for package update, move etc
|
||||||
|
|
||||||
COMMANDS
|
COMMANDS
|
||||||
move Move packages between pacman repositories
|
move Move packages between pacman repositories
|
||||||
|
@@ -1,58 +0,0 @@
|
|||||||
#!/hint/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_INIT_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_INIT_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_init_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] [SHELL]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
eval "\$(pkgctl init bash)"
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
$ ${COMMAND} clone libfoo linux libbar
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_init() {
|
|
||||||
if (( $# < 1 )); then
|
|
||||||
pkgctl_init_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# option checking
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_init_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
zsh)
|
|
||||||
cat "${_DEVTOOLS_LIBRARY_DIR}"/init.d/init.zsh
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
bash)
|
|
||||||
cat "${_DEVTOOLS_LIBRARY_DIR}"/init.d/init.bash
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "invalid command: %s" "$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
@@ -10,8 +10,6 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/db/update.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/db/update.sh
|
||||||
# shellcheck source=src/lib/util/pacman.sh
|
# shellcheck source=src/lib/util/pacman.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/pacman.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/pacman.sh
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
# shellcheck source=src/lib/valid-repos.sh
|
# shellcheck source=src/lib/valid-repos.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
|
||||||
|
|
||||||
@@ -132,8 +130,6 @@ pkgctl_release() {
|
|||||||
die "Invalid repository target: %s" "${REPO}"
|
die "Invalid repository target: %s" "${REPO}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enter_workspace
|
|
||||||
|
|
||||||
for path in "${PKGBASES[@]}"; do
|
for path in "${PKGBASES[@]}"; do
|
||||||
pushd "${path}" >/dev/null
|
pushd "${path}" >/dev/null
|
||||||
pkgbase=$(basename "${path}")
|
pkgbase=$(basename "${path}")
|
||||||
|
@@ -27,7 +27,6 @@ pkgctl_repo_usage() {
|
|||||||
without SSH access using read-only HTTPS.
|
without SSH access using read-only HTTPS.
|
||||||
|
|
||||||
COMMANDS
|
COMMANDS
|
||||||
cd Change current working directory into the repository
|
|
||||||
clone Clone a package repository
|
clone Clone a package repository
|
||||||
configure Configure a clone according to distro specs
|
configure Configure a clone according to distro specs
|
||||||
create Create a new GitLab package repository
|
create Create a new GitLab package repository
|
||||||
@@ -60,14 +59,6 @@ pkgctl_repo() {
|
|||||||
pkgctl_repo_usage
|
pkgctl_repo_usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
cd)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/repo/cd.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/cd.sh
|
|
||||||
pkgctl_repo_cd "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
clone)
|
clone)
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
_DEVTOOLS_COMMAND+=" $1"
|
||||||
shift
|
shift
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_REPO_CD_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_REPO_CD_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_repo_cd_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] [PKGBASE]...
|
|
||||||
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
$ ${COMMAND}
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_repo_cd() {
|
|
||||||
# options
|
|
||||||
local pkgbase
|
|
||||||
|
|
||||||
# variables
|
|
||||||
local path
|
|
||||||
local workspace
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_repo_cd_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
pkgbase=$1
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z ${PKGCTL_OUTCMD} ]]; then
|
|
||||||
die "setup shell"
|
|
||||||
fi
|
|
||||||
|
|
||||||
workspace=$(get_active_workspace_name)
|
|
||||||
path=$(get_workspace_path_from_name "${workspace}")
|
|
||||||
|
|
||||||
printf "builtin cd -- %s\n" "${path}/${pkgbase}" >> "${PKGCTL_OUTCMD}"
|
|
||||||
}
|
|
@@ -12,8 +12,6 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
|
||||||
# shellcheck source=src/lib/repo/configure.sh
|
# shellcheck source=src/lib/repo/configure.sh
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/configure.sh
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/configure.sh
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
source /usr/share/makepkg/util/message.sh
|
||||||
|
|
||||||
@@ -180,8 +178,6 @@ pkgctl_repo_clone() {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enter_workspace
|
|
||||||
|
|
||||||
for pkgbase in "${pkgbases[@]}"; do
|
for pkgbase in "${pkgbases[@]}"; do
|
||||||
if [[ ! -d ${pkgbase} ]]; then
|
if [[ ! -d ${pkgbase} ]]; then
|
||||||
msg "Cloning ${pkgbase} ..."
|
msg "Cloning ${pkgbase} ..."
|
||||||
@@ -200,6 +196,4 @@ pkgctl_repo_clone() {
|
|||||||
pkgctl_repo_switch "${VERSION}" "${pkgbase}"
|
pkgctl_repo_switch "${VERSION}" "${pkgbase}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
leave_workspace
|
|
||||||
}
|
}
|
||||||
|
@@ -22,3 +22,8 @@ git_diff_tree() {
|
|||||||
"${commit}" \
|
"${commit}" \
|
||||||
-- "${path}"
|
-- "${path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_valid_release_branch() {
|
||||||
|
local branch=$1
|
||||||
|
in_array "${branch}" "${VALID_RELEASE_BRANCHES[@]}"
|
||||||
|
}
|
||||||
|
@@ -1,107 +0,0 @@
|
|||||||
#!/hint/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [COMMAND] [OPTIONS]
|
|
||||||
|
|
||||||
Manage package workspace locations and settings
|
|
||||||
|
|
||||||
COMMANDS
|
|
||||||
add Add a new workspace
|
|
||||||
cd Change into the directory of the workspace
|
|
||||||
list, ls List availiable workspaces
|
|
||||||
remove, rm Remove a workspace
|
|
||||||
show Show details about a workspace
|
|
||||||
switch Switch the current worspace
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
$ ${COMMAND} workspace show
|
|
||||||
$ ${COMMAND} workspace list
|
|
||||||
$ ${COMMAND} workspace add test --cd
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace() {
|
|
||||||
if (( $# < 1 )); then
|
|
||||||
pkgctl_workspace_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# option checking
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
add)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/add.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/add.sh
|
|
||||||
pkgctl_workspace_add "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
cd)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/cd.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/cd.sh
|
|
||||||
pkgctl_workspace_cd "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
list|ls)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/list.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/list.sh
|
|
||||||
pkgctl_workspace_list "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
remove|rm)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/remove.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/remove.sh
|
|
||||||
pkgctl_workspace_remove "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
show)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/show.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/show.sh
|
|
||||||
pkgctl_workspace_show "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
switch)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace/switch.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/switch.sh
|
|
||||||
pkgctl_workspace_switch "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "invalid command: %s" "$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
@@ -1,124 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_ADD_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_ADD_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_add_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] NAME [PATH]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-f, --force Overwrite if the workspace already exists
|
|
||||||
-s, --switch Switch to the new workspace
|
|
||||||
-c, --cd Change the current working directory
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
$ ${COMMAND} aur
|
|
||||||
$ ${COMMAND} --force foobar ~/packages
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_add() {
|
|
||||||
if (( $# < 1 )); then
|
|
||||||
pkgctl_workspace_add_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# options
|
|
||||||
local force=0
|
|
||||||
local switch=0
|
|
||||||
local change_cwd=0
|
|
||||||
local name
|
|
||||||
local path
|
|
||||||
|
|
||||||
# variables
|
|
||||||
local full_path
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_add_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-c|--cd)
|
|
||||||
# shellcheck source=src/lib/workspace/cd.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/cd.sh
|
|
||||||
change_cwd=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-s|--switch)
|
|
||||||
# shellcheck source=src/lib/workspace/switch.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/switch.sh
|
|
||||||
switch=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-f|--force)
|
|
||||||
force=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ -n ${name} ]]; then
|
|
||||||
path=$1
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
name=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# path fallback inside XDG workspace dir
|
|
||||||
if [[ -z ${path} ]]; then
|
|
||||||
path=${name}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ! force )) && get_workspace_path_from_name "${name}" &>/dev/null; then
|
|
||||||
die "cannot create workspce '%s': Workspace already exists" "${name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: xdg shorthand needs to be resolved into path
|
|
||||||
# TODO: detect relative paths (no leading /)
|
|
||||||
|
|
||||||
full_path=$(get_absolute_workspace_path "${path}")
|
|
||||||
|
|
||||||
if ! mkdir -p "${full_path}"; then
|
|
||||||
die "failed to create workspace path %s" "${full_path}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ -w ${full_path} ]]; then
|
|
||||||
die "workspace path %s is not writable" "${full_path}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
set_workspace "${name}" "${path}"
|
|
||||||
|
|
||||||
if (( switch )); then
|
|
||||||
pkgctl_workspace_switch "${name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( change_cwd )); then
|
|
||||||
pkgctl_workspace_cd "${name}"
|
|
||||||
fi
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_CD_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_CD_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_cd_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] [NAME]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_cd() {
|
|
||||||
# options
|
|
||||||
local workspace=
|
|
||||||
|
|
||||||
# variables
|
|
||||||
local path
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_cd_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
workspace=$1
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z ${PKGCTL_OUTCMD} ]]; then
|
|
||||||
die "setup shell"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z ${workspace} ]]; then
|
|
||||||
workspace=$(get_active_workspace_name)
|
|
||||||
fi
|
|
||||||
path=$(get_workspace_path_from_name "${workspace}")
|
|
||||||
|
|
||||||
printf "builtin cd -- %s\n" "${path}" >> "${PKGCTL_OUTCMD}"
|
|
||||||
}
|
|
@@ -1,134 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_LIST_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_LIST_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_list_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-n, --name Only list raw workspace names
|
|
||||||
-p, --path Only list raw workspace paths
|
|
||||||
-l, --local None default workspaces only
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_list_check_option_group() {
|
|
||||||
local option=$1
|
|
||||||
local print_mode=$2
|
|
||||||
if [[ ${print_mode} != pretty ]] && [[ ${print_mode} != "${option}" ]]; then
|
|
||||||
die "The argument '%s' cannot be used with one or more of the other specified arguments" "${option}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_list() {
|
|
||||||
# options
|
|
||||||
local print_mode=pretty
|
|
||||||
local only_local=0
|
|
||||||
|
|
||||||
# variables
|
|
||||||
local names name path active_workspace marker packages
|
|
||||||
local pad
|
|
||||||
local name_len=0
|
|
||||||
local packages_len=0
|
|
||||||
local workspaces
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_list_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-p|--path)
|
|
||||||
pkgctl_workspace_list_check_option_group --path "${print_mode}"
|
|
||||||
print_mode=path
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-n|--name)
|
|
||||||
pkgctl_workspace_list_check_option_group --name "${print_mode}"
|
|
||||||
print_mode=name
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-l|--local)
|
|
||||||
only_local=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
active_workspace=$(get_active_workspace_name)
|
|
||||||
mapfile -t names < <(get_all_workspace_names "${only_local}")
|
|
||||||
|
|
||||||
# cache values for pretty printing
|
|
||||||
if [[ ${print_mode} == pretty ]]; then
|
|
||||||
declare -A workspaces
|
|
||||||
pad=$(printf '%0.1s' " "{1..60})
|
|
||||||
for name in "${names[@]}"; do
|
|
||||||
echo "inter $name"
|
|
||||||
path=$(get_workspace_path_from_name "${name}")
|
|
||||||
packages=$(workspace_package_count "${name}")
|
|
||||||
|
|
||||||
if (( ${#name} > name_len )); then
|
|
||||||
name_len=${#name}
|
|
||||||
fi
|
|
||||||
if (( ${#packages} > packages_len )); then
|
|
||||||
packages_len=${#packages}
|
|
||||||
fi
|
|
||||||
|
|
||||||
workspaces["${name}->packages"]="${packages}"
|
|
||||||
workspaces["${name}->path"]="${path}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
for name in "${names[@]}"; do
|
|
||||||
case ${print_mode} in
|
|
||||||
path)
|
|
||||||
path=$(get_workspace_path_from_name "${name}")
|
|
||||||
printf "%s\n" "${path}"
|
|
||||||
;;
|
|
||||||
name)
|
|
||||||
printf "%s\n" "${name}"
|
|
||||||
;;
|
|
||||||
pretty)
|
|
||||||
marker=" "
|
|
||||||
packages="${workspaces[${name}->packages]}"
|
|
||||||
path="${workspaces[${name}->path]}"
|
|
||||||
if [[ $name == "$active_workspace" ]]; then
|
|
||||||
marker="${GREEN}${BOLD}✓${ALL_OFF}${BOLD}"
|
|
||||||
fi
|
|
||||||
printf '%s %s %*.*s' "${marker}" "${name}" 0 $((name_len - ${#name} )) "${pad}"
|
|
||||||
printf ' 📦 %*.*s%s' 0 $((packages_len - ${#packages} )) "${pad}" "${packages}"
|
|
||||||
printf ' 📂 %s%s' "${path}" "${ALL_OFF}"
|
|
||||||
printf "%s\n" "${ALL_OFF}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_REMOVE_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_REMOVE_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_remove_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] NAME
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_remove() {
|
|
||||||
if (( $# < 1 )); then
|
|
||||||
pkgctl_workspace_remove_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# options
|
|
||||||
local name current
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_remove_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
name=$1
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# TODO: check current
|
|
||||||
current=$(get_active_workspace_name)
|
|
||||||
|
|
||||||
# TODO: check builtin default cwd
|
|
||||||
|
|
||||||
if ! remove_workspace "${name}"; then
|
|
||||||
die 'failed to remove workspace %s' "${name}"
|
|
||||||
fi
|
|
||||||
}
|
|
@@ -1,101 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_SHOW_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_SHOW_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_show_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] [NAME]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-n, --name Print the workspace name
|
|
||||||
-p, --path Print the workspace location
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_show_check_option_group() {
|
|
||||||
local option=$1
|
|
||||||
local print_mode=$2
|
|
||||||
if [[ ${print_mode} != pretty ]] && [[ ${print_mode} != "${option}" ]]; then
|
|
||||||
die "The argument '%s' cannot be used with one or more of the other specified arguments" "${option}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_show() {
|
|
||||||
# options
|
|
||||||
local print_mode=pretty
|
|
||||||
local workspace
|
|
||||||
|
|
||||||
# variables
|
|
||||||
local path packages
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_show_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-p|--path)
|
|
||||||
pkgctl_workspace_show_check_option_group --path "${print_mode}"
|
|
||||||
print_mode=path
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-n|--name)
|
|
||||||
pkgctl_workspace_show_check_option_group --name "${print_mode}"
|
|
||||||
print_mode=name
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
workspace=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# use the active workspace if none is provided
|
|
||||||
if [[ -z ${workspace} ]]; then
|
|
||||||
workspace=$(get_active_workspace_name)
|
|
||||||
fi
|
|
||||||
|
|
||||||
path=$(get_workspace_path_from_name "${workspace}")
|
|
||||||
packages=$(workspace_package_count "${workspace}")
|
|
||||||
|
|
||||||
case ${print_mode} in
|
|
||||||
path)
|
|
||||||
printf "%s\n" "${path}"
|
|
||||||
;;
|
|
||||||
name)
|
|
||||||
printf "%s\n" "${workspace}"
|
|
||||||
;;
|
|
||||||
pretty)
|
|
||||||
msg2 "${workspace}: ${packages} packages ${path}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
@@ -1,121 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_SWITCH_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_SWITCH_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
# shellcheck source=src/lib/workspace/add.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/add.sh
|
|
||||||
# shellcheck source=src/lib/workspace/cd.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/cd.sh
|
|
||||||
# shellcheck source=src/lib/workspace/list.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/list.sh
|
|
||||||
# shellcheck source=src/lib/workspace/util.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace/util.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
pkgctl_workspace_switch_usage() {
|
|
||||||
local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
|
|
||||||
cat <<- _EOF_
|
|
||||||
Usage: ${COMMAND} [OPTIONS] [NAME]
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-i, --interactive Interactively select the workspace
|
|
||||||
-c, --create Create a new workspace before switching
|
|
||||||
--cd Change the working directory to the new workspace
|
|
||||||
-h, --help Show this help text
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
_EOF_
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgctl_workspace_switch() {
|
|
||||||
if (( $# < 1 )); then
|
|
||||||
pkgctl_workspace_switch_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# options
|
|
||||||
local name=
|
|
||||||
local path=
|
|
||||||
local change_cwd=0
|
|
||||||
local interactive=0
|
|
||||||
local create=0
|
|
||||||
|
|
||||||
while (( $# )); do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
pkgctl_workspace_switch_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-c|--create)
|
|
||||||
create=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--cd)
|
|
||||||
change_cwd=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-i|--interactive)
|
|
||||||
interactive=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ -z ${name} ]]; then
|
|
||||||
name=$1
|
|
||||||
elif [[ -z ${path} ]]; then
|
|
||||||
path=$1
|
|
||||||
else
|
|
||||||
die "invalid argument: %s" "$1"
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z ${name} ]]; then
|
|
||||||
name=default
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( interactive )); then
|
|
||||||
# TODO: check for fzf
|
|
||||||
name=$(pkgctl_workspace_list --name | sort | \
|
|
||||||
fzf --exit-0 --ansi --no-multi --keep-right --height=45%)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( create )); then
|
|
||||||
if ! pkgctl_workspace_add "${name}"; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! path=$(get_workspace_path_from_name "${name}"); then
|
|
||||||
die 'workspace does not exist: %s' "${name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! set_current_workspace "${name}"; then
|
|
||||||
die 'failed to set current workspace'
|
|
||||||
fi
|
|
||||||
|
|
||||||
msg "Switched to workspace %s" "${name}"
|
|
||||||
|
|
||||||
if (( change_cwd )); then
|
|
||||||
pkgctl_workspace_cd "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
@@ -1,188 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
[[ -z ${DEVTOOLS_INCLUDE_WORKSPACE_UTIL_SH:-} ]] || return 0
|
|
||||||
DEVTOOLS_INCLUDE_WORKSPACE_UTIL_SH=1
|
|
||||||
|
|
||||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
||||||
# shellcheck source=src/lib/common.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
||||||
|
|
||||||
source /usr/share/makepkg/util/message.sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
is_xdg_workspace() {
|
|
||||||
local path=$1
|
|
||||||
[[ $path != */* ]] && [[ $path != . ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
get_all_workspace_names() {
|
|
||||||
local only_local=$1
|
|
||||||
local names=()
|
|
||||||
local builtins=(default cwd)
|
|
||||||
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/workspace.toml
|
|
||||||
|
|
||||||
if (( ! only_local )); then
|
|
||||||
printf "%s\n" "${builtins[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mapfile -t names < <(${TOML} get ${CONFIG} . | jq -r 'keys | join("\n")' | grep -v '^$')
|
|
||||||
if (( ${#names[@]} )); then
|
|
||||||
printf "%s\n" "${names[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${#names[@]}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
get_workspace_path_from_name() {
|
|
||||||
local name=$1
|
|
||||||
local path
|
|
||||||
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/workspace.toml
|
|
||||||
|
|
||||||
case $name in
|
|
||||||
cwd)
|
|
||||||
path="${PWD}"
|
|
||||||
;;
|
|
||||||
default)
|
|
||||||
path=$name
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if ! path="$(${TOML} get --raw ${CONFIG} -- "${name}.path")"; then
|
|
||||||
error "unknown workspace name: %s" "${name}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
get_absolute_workspace_path "${path}"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_absolute_workspace_path() {
|
|
||||||
local path=$1
|
|
||||||
|
|
||||||
# TODO XDG detection
|
|
||||||
XDG_PKGCTL_WORKSPACES=~/.local/state/pkgctl/workspace
|
|
||||||
|
|
||||||
if is_xdg_workspace "${path}"; then
|
|
||||||
printf "%s/%s" "${XDG_PKGCTL_WORKSPACES}" "${path}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $path == . ]]; then
|
|
||||||
printf "%s" "${PWD}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "%s" "${path}"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_active_workspace_name() {
|
|
||||||
local workspace
|
|
||||||
if [[ -n ${PKGCTL_WORKSPACE} ]]; then
|
|
||||||
workspace="${PKGCTL_WORKSPACE}"
|
|
||||||
else
|
|
||||||
workspace=$(get_current_workspace_name)
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "%s" "${workspace}"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_current_workspace_name() {
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/config.toml
|
|
||||||
|
|
||||||
DEFAULT_WORKSPACE=default
|
|
||||||
if ! workspace=$(${TOML} get --raw ${CONFIG} -- pkgctl.workspace); then
|
|
||||||
workspace=${DEFAULT_WORKSPACE}
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "%s" "${workspace}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: name should reflect absolute?
|
|
||||||
get_current_workspace_path() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
|
|
||||||
set_workspace() {
|
|
||||||
local name=$1
|
|
||||||
local path=${2:-$name}
|
|
||||||
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/workspace.toml
|
|
||||||
|
|
||||||
[[ -z ${WORKDIR:-} ]] && setup_workdir
|
|
||||||
outfile=$(mktemp --tmpdir="${WORKDIR}" pkgctl-workspace.toml.XXXXXXXXXX)
|
|
||||||
|
|
||||||
${TOML} set "${CONFIG}" -- "${name}.path" "${path}" > "${outfile}"
|
|
||||||
mv "${outfile}" "${CONFIG}"
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_workspace() {
|
|
||||||
local name=$1
|
|
||||||
local path=${2:-$name}
|
|
||||||
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/workspace.toml
|
|
||||||
|
|
||||||
[[ -z ${WORKDIR:-} ]] && setup_workdir
|
|
||||||
outfile=$(mktemp --tmpdir="${WORKDIR}" pkgctl-workspace.toml.XXXXXXXXXX)
|
|
||||||
|
|
||||||
tomlq --toml-output "del(.${name})" "${CONFIG}" > "${outfile}"
|
|
||||||
mv "${outfile}" "${CONFIG}"
|
|
||||||
}
|
|
||||||
|
|
||||||
set_current_workspace() {
|
|
||||||
local name=$1
|
|
||||||
|
|
||||||
TOML=~/.local/share/cargo/bin/toml
|
|
||||||
CONFIG=~/.config/devtools/config.toml
|
|
||||||
|
|
||||||
[[ -z ${WORKDIR:-} ]] && setup_workdir
|
|
||||||
outfile=$(mktemp --tmpdir="${WORKDIR}" pkgctl-workspace.toml.XXXXXXXXXX)
|
|
||||||
|
|
||||||
${TOML} set "${CONFIG}" -- "pkgctl.workspace" "${name}" > "${outfile}"
|
|
||||||
mv "${outfile}" "${CONFIG}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: maybe by path instead?
|
|
||||||
workspace_package_count() {
|
|
||||||
local workspace=$1
|
|
||||||
|
|
||||||
path=$(get_workspace_path_from_name "${workspace}")
|
|
||||||
|
|
||||||
shopt -s nullglob
|
|
||||||
packages=("${path}/"*/PKGBUILD)
|
|
||||||
|
|
||||||
printf "%s" "${#packages[*]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
PKGCTL_START_DIR=$(pwd)
|
|
||||||
PKGCTL_WORKSPACE_ACTIVE=0
|
|
||||||
enter_workspace() {
|
|
||||||
local path
|
|
||||||
local workspace
|
|
||||||
|
|
||||||
(( PKGCTL_WORKSPACE_ACTIVE )) && return
|
|
||||||
|
|
||||||
workspace=$(get_active_workspace_name)
|
|
||||||
|
|
||||||
path=$(get_workspace_path_from_name "${workspace}")
|
|
||||||
|
|
||||||
msg "Entering workspace %s in %s" "${workspace}" "${path}"
|
|
||||||
PKGCTL_WORKSPACE_ACTIVE=1
|
|
||||||
cd "${path}"
|
|
||||||
}
|
|
||||||
|
|
||||||
leave_workspace() {
|
|
||||||
(( ! PKGCTL_WORKSPACE_ACTIVE )) && return
|
|
||||||
PKGCTL_WORKSPACE_ACTIVE=0
|
|
||||||
cd "${PKGCTL_START_DIR}"
|
|
||||||
}
|
|
@@ -19,19 +19,16 @@ usage() {
|
|||||||
Unified command-line frontend for devtools.
|
Unified command-line frontend for devtools.
|
||||||
|
|
||||||
COMMANDS
|
COMMANDS
|
||||||
auth Authenticate with services like GitLab
|
auth Authenticate with services like GitLab
|
||||||
build Build packages inside a clean chroot
|
build Build packages inside a clean chroot
|
||||||
db Pacman database modification for packge update, move etc
|
db Pacman database modification for package update, move etc
|
||||||
diff Compare package files using different modes
|
diff Compare package files using different modes
|
||||||
init Generate and print the shell configuration
|
release Release step to commit, tag and upload build artifacts
|
||||||
release Release step to commit, tag and upload build artifacts
|
repo Manage Git packaging repositories and their configuration
|
||||||
repo Manage Git packaging repositories and their configuration
|
version Show pkgctl version information
|
||||||
version Show pkgctl version information
|
|
||||||
workspace Manage package workspace locations and settings
|
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-w, --workspace NAME Override the configured workspace to use (default: xdg, cwd)
|
-h, --help Show this help text
|
||||||
-h, --help Show this help text
|
|
||||||
_EOF_
|
_EOF_
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +38,6 @@ if (( $# < 1 )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export _DEVTOOLS_COMMAND='pkgctl'
|
export _DEVTOOLS_COMMAND='pkgctl'
|
||||||
export PKGCTL_WORKSPACE=""
|
|
||||||
|
|
||||||
load_devtools_config
|
load_devtools_config
|
||||||
|
|
||||||
@@ -52,11 +48,6 @@ while (( $# )); do
|
|||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-w|--workspace)
|
|
||||||
(( $# <= 1 )) && die "missing argument for %s" "$1"
|
|
||||||
PKGCTL_WORKSPACE=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
build)
|
build)
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
_DEVTOOLS_COMMAND+=" $1"
|
||||||
shift
|
shift
|
||||||
@@ -95,14 +86,6 @@ while (( $# )); do
|
|||||||
diffpkg "$@"
|
diffpkg "$@"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
init)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/release.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/init/init.sh
|
|
||||||
pkgctl_init "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
release)
|
release)
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
_DEVTOOLS_COMMAND+=" $1"
|
||||||
shift
|
shift
|
||||||
@@ -119,14 +102,6 @@ while (( $# )); do
|
|||||||
pkgctl_version "$@"
|
pkgctl_version "$@"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
workspace)
|
|
||||||
_DEVTOOLS_COMMAND+=" $1"
|
|
||||||
shift
|
|
||||||
# shellcheck source=src/lib/workspace.sh
|
|
||||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/workspace.sh
|
|
||||||
pkgctl_workspace "$@"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
die "invalid command: %s" "$1"
|
die "invalid command: %s" "$1"
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user