feat(configure): ship default ignore via exclude

BREAKING CHANGE: Increments the repo spec version which requires to
reconfigure all existing packaging repo clones.

Fixes #129

Component: pkgctl repo configure
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Levente Polyak 2023-06-11 23:31:18 +02:00
parent c2d73d73ae
commit d00a2b9890
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
18 changed files with 80 additions and 3 deletions

View File

@ -16,6 +16,7 @@ LIBRARY_SRC = $(call rwildcard,src/lib,*.sh)
LIBRARY = $(addprefix $(BUILDDIR)/,$(patsubst src/%,%,$(patsubst %.in,%,$(LIBRARY_SRC)))) LIBRARY = $(addprefix $(BUILDDIR)/,$(patsubst src/%,%,$(patsubst %.in,%,$(LIBRARY_SRC))))
MAKEPKG_CONFIGS=$(wildcard config/makepkg/*) MAKEPKG_CONFIGS=$(wildcard config/makepkg/*)
PACMAN_CONFIGS=$(wildcard config/pacman/*) PACMAN_CONFIGS=$(wildcard config/pacman/*)
GIT_CONFIGS = $(wildcard config/git/*)
SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*) SETARCH_ALIASES = $(wildcard config/setarch-aliases.d/*)
MANS = $(addprefix $(BUILDDIR)/,$(patsubst %.asciidoc,%,$(wildcard doc/man/*.asciidoc))) MANS = $(addprefix $(BUILDDIR)/,$(patsubst %.asciidoc,%,$(wildcard doc/man/*.asciidoc)))
@ -97,9 +98,12 @@ $(BUILDDIR)/doc/man/%: doc/man/%.asciidoc doc/asciidoc.conf doc/man/include/foot
@a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage --destination-dir=$(BUILDDIR)/doc/man -a pkgdatadir=$(DATADIR) $< @a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage --destination-dir=$(BUILDDIR)/doc/man -a pkgdatadir=$(DATADIR) $<
conf: conf:
@install -d $(BUILDDIR)/makepkg.conf.d $(BUILDDIR)/pacman.conf.d @install -d $(BUILDDIR)/makepkg.conf.d
@cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d @cp -a $(MAKEPKG_CONFIGS) $(BUILDDIR)/makepkg.conf.d
@install -d $(BUILDDIR)/pacman.conf.d
@cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d @cp -a $(PACMAN_CONFIGS) $(BUILDDIR)/pacman.conf.d
@install -d $(BUILDDIR)/git.conf.d
cp -a $(GIT_CONFIGS) $(BUILDDIR)/git.conf.d
clean: clean:
rm -rf $(BUILDDIR) rm -rf $(BUILDDIR)
@ -112,6 +116,7 @@ install: all
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
cp -a $(BUILDDIR)/git.conf.d -t $(DESTDIR)$(DATADIR)
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
@ -129,6 +134,7 @@ uninstall:
for f in $(notdir $(BINPROGS)); do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done for f in $(notdir $(BINPROGS)); do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done for f in $(notdir $(LIBRARY)); do rm -f $(DESTDIR)$(DATADIR)/lib/$$f; done
rm -rf $(DESTDIR)$(DATADIR)/lib rm -rf $(DESTDIR)$(DATADIR)/lib
rm -rf $(DESTDIR)$(DATADIR)/git.conf.d
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

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -0,0 +1,28 @@
/pkg
/src
/*/
!/keys/
/*.log
/*.tar.*
/*.tar
/*.tgz
/*.zst
/*.gz
/*.xz
/*.bz2
/*.zip
/*.xpi
/*.jar
/*.whl
/*.war
/*.deb
/*.ttf
/*.dat
/*.iso
/*.asc
/*.sig
/*.signature
/*.sign
/*.SHA256SUMS
/*.sha256

View File

@ -22,6 +22,8 @@ The remote protocol is automatically determined from the author email
address by choosing SSH for all official packager identities and address by choosing SSH for all official packager identities and
read-only HTTPS otherwise. read-only HTTPS otherwise.
Git default excludes and hooks are applied to the configured repo.
Options Options
------- -------

View File

@ -71,6 +71,12 @@ if ! repo_spec=$(git config --local devtools.version) || [[ ${repo_spec} != "${G
exit 1 exit 1
fi fi
if ! repo_variant=$(git config --local devtools.variant) || [[ ${repo_variant} != canonical ]]; then
error "cannot release from a repository with none canonical specs (%s), try:" "${repo_variant:-development}"
msg2 'pkgctl repo configure'
exit 1
fi
if [[ "$(git symbolic-ref --short HEAD)" != main ]]; then if [[ "$(git symbolic-ref --short HEAD)" != main ]]; then
die 'must be run from the main branch' die 'must be run from the main branch'
fi fi

View File

@ -22,7 +22,7 @@ export BUILDTOOLVER=@buildtoolver@
# Set common properties # Set common properties
export PACMAN_KEYRING_DIR=/etc/pacman.d/gnupg export PACMAN_KEYRING_DIR=/etc/pacman.d/gnupg
export GITLAB_HOST=gitlab.archlinux.org export GITLAB_HOST=gitlab.archlinux.org
export GIT_REPO_SPEC_VERSION=1 export GIT_REPO_SPEC_VERSION=2
export GIT_PACKAGING_NAMESPACE=archlinux/packaging/packages export GIT_PACKAGING_NAMESPACE=archlinux/packaging/packages
export GIT_PACKAGING_NAMESPACE_ID=11323 export GIT_PACKAGING_NAMESPACE_ID=11323
export GIT_PACKAGING_URL_SSH="git@${GITLAB_HOST}:${GIT_PACKAGING_NAMESPACE}" export GIT_PACKAGING_URL_SSH="git@${GITLAB_HOST}:${GIT_PACKAGING_NAMESPACE}"

View File

@ -17,6 +17,7 @@ source /usr/share/makepkg/util/config.sh
source /usr/share/makepkg/util/message.sh source /usr/share/makepkg/util/message.sh
set -e set -e
shopt -s nullglob
pkgctl_repo_configure_usage() { pkgctl_repo_configure_usage() {
@ -34,6 +35,8 @@ pkgctl_repo_configure_usage() {
address by choosing SSH for all official packager identities and address by choosing SSH for all official packager identities and
read-only HTTPS otherwise. read-only HTTPS otherwise.
Git default excludes and hooks are applied to the configured repo.
OPTIONS OPTIONS
--protocol https Configure remote url to use https --protocol https Configure remote url to use https
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
@ -104,7 +107,7 @@ pkgctl_repo_configure() {
# variables # variables
local -r command=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} local -r command=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}}
local path realpath pkgbase remote_url project_path local path realpath pkgbase remote_url project_path hook
local PACKAGER GPGKEY packager_name packager_email local PACKAGER GPGKEY packager_name packager_email
while (( $# )); do while (( $# )); do
@ -230,7 +233,15 @@ pkgctl_repo_configure() {
git config branch.main.merge refs/heads/main git config branch.main.merge refs/heads/main
fi fi
# configure spec version and variant to avoid using development hooks in production
git config devtools.version "${GIT_REPO_SPEC_VERSION}" git config devtools.version "${GIT_REPO_SPEC_VERSION}"
if [[ ${_DEVTOOLS_LIBRARY_DIR} == /usr/share/devtools ]]; then
git config devtools.variant canonical
else
warning "Configuring with development version of pkgctl, do not use this repo in production"
git config devtools.variant development
fi
git config pull.rebase true git config pull.rebase true
git config branch.autoSetupRebase always git config branch.autoSetupRebase always
git config branch.main.remote origin git config branch.main.remote origin
@ -257,6 +268,18 @@ pkgctl_repo_configure() {
git config user.signingKey "${GPGKEY}" git config user.signingKey "${GPGKEY}"
fi fi
# set default git exclude
mkdir -p .git/info
ln -sf "${_DEVTOOLS_LIBRARY_DIR}/git.conf.d/template/info/exclude" \
.git/info/exclude
# set default git hooks
mkdir -p .git/hooks
rm -f .git/hooks/*.sample
for hook in "${_DEVTOOLS_LIBRARY_DIR}"/git.conf.d/template/hooks/*; do
ln -sf "${hook}" ".git/hooks/$(basename "${hook}")"
done
if ! git ls-remote origin &>/dev/null; then if ! git ls-remote origin &>/dev/null; then
warning "configured remote origin may not exist, run:" warning "configured remote origin may not exist, run:"
msg2 "pkgctl repo create ${pkgbase}" msg2 "pkgctl repo create ${pkgbase}"