Commit graph

31 commits

Author SHA1 Message Date
Lukas Fleischer
dc3fd60715 Use setuptools to install Python modules
Instead of using relative imports, add support for installing the config
and db Python modules to a proper location using setuptools. Change all
git-interface scripts to access those modules from the search path.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-29 22:07:06 +02:00
Lukas Fleischer
8468b6be4b git-serve: Move entry point to a main() method
Move the main program logic of git-serve to a main() method such that it
can be used as a module and easily be invoked by setuptools wrapper
scripts.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-29 22:07:06 +02:00
Lukas Fleischer
b8318d2587 git-serve: Pass user and privileges as parameters
Move the main program logic of git-server to a main() method such that
it can be used as a module and easily be invoked by setuptools wrapper
scripts.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-29 22:07:06 +02:00
Lukas Fleischer
94ac084d9d git-serve: Add support for setting co-maintainers
Add support for changing co-maintainers from the SSH interface. The
syntax is `set-comaintainers <pkgbase> <user1> <user2>...`.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-18 14:01:08 +02:00
Lukas Fleischer
9b983ac03e git-serve: Add support for disowning package bases
Add support for disowning packages from the SSH interface. The syntax is
`disown <pkgbase>`.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-18 14:01:08 +02:00
Lukas Fleischer
ce12e3b82d git-serve: Add support for adopting package bases
Add support for adopting packages from the SSH interface. The syntax is
`adopt <pkgbase>`.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-17 20:17:39 +02:00
Lukas Fleischer
e045069421 git-serve: Format usage text automatically
Remove the formatting of the usage text and add code to columnize it
automatically instead.

Also, add more strict tests for the usage output. These new tests ensure
that the usage header is printed, commands are indented properly and no
overly long lines are produced.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-17 20:17:11 +02:00
Lukas Fleischer
ab228fd3c3 git-serve: Mark setup-repo as deprecated
Since 0c1187c (git-serve: Deprecate setup-repo, 2016-07-24), it is no
longer recommended to use setup-repo. Mark the command as deprecated in
the usage/help text.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-09-12 08:45:38 +02:00
Lukas Fleischer
936ee66f1e Lazy-add new package bases
Create new package bases just before saving package metadata. This
protects from stray package bases left behind when new packages are
rejected, e.g. when the user tries to push a package that is available
from the official repositories already.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-10 20:14:17 +02:00
Lukas Fleischer
f2a6bd207d git-interface: Do not use UNIX_TIMESTAMP
Avoid using UNIX_TIMESTAMP which is not part of the SQL standard.
Retrieve the current UNIX time in Python and substitute it into the SQL
queries instead.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-05 12:05:22 +02:00
Lukas Fleischer
2f5f5583be git-interface: Factor out configuration file parsing
Add a new module that automatically locates the configuration file and
provides methods to obtain the values of configuration options.

Use the new module instead of ConfigParser everywhere.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-05 12:05:22 +02:00
Lukas Fleischer
2915abb9d3 git-interface: Add database abstraction layer
Add a new class that connects to the database specified in the
configuration file and provides an interface to execute SQL queries.
Prepared statements with qmark ("?") placeholders are supported.

Replace all direct database accesses with calls to the new abstraction
layer.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-05 12:05:22 +02:00
Lukas Fleischer
0c1187caa4 git-serve: Deprecate setup-repo
Since 02dd9c5 (git-serve.py: Automatically create repositories,
2015-01-06), one can create new package bases by running `git push`. It
is no longer necessary to run setup-repo manually.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-04 21:37:52 +02:00
Lukas Fleischer
573715afd9 git-serve: Refactor environment variable access
Read all environment variables at the beginning of the script and
immediately pre-process their values.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-08-04 13:04:44 +02:00
Lukas Fleischer
dc41a5afa5 git-serve: Change syntax for setting keywords
Instead of `config <pkgbase> keywords <keyword1> <keyword2>...`, the new
syntax is `set-keywords <pkgbase> <keyword1> <keyword2>...`.

The `config` keyword was rather general and it was not obvious that it
could be used to change package base settings. Instead of replacing it
with an even more verbose expression, remove that unnecessary level of
indirection. Since we do not (and probably never will) support keywords
anywhere else, the chance of name conflicts is small.

Suggested-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-02-09 21:03:47 +01:00
Lukas Fleischer
3412de21d3 Rename the CommentNotify table to PackageNotifications
As a preparatory step to adding support for package notifications on
events other than comments, rename the database table accordingly.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-02-07 10:39:22 +01:00
Lukas Fleischer
f8b3cb97e5 Fix issues reported by pyflakes
Fix several style issues and remove unneeded imports/assignments.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-02-06 16:23:01 +01:00
Mark Weiman
39280152ea git-serve: Fix pkgbase_exists()
Fixes a regression introduced in 8c87b1d (git-serve: Add support for
setting keywords, 2015-10-22).

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-11-26 17:22:22 +01:00
Lukas Fleischer
8c87b1df0c git-serve: Add support for setting keywords
This allows for setting keywords using the SSH interface. The syntax is
`config <pkgbase> keywords <keyword1> <keyword2>...`.

Implements FS#45627.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 16:22:43 +02:00
Lukas Fleischer
4112e572aa Add a restore command to the SSH interface
Implement a new command that can be used to restore deleted package
bases without having to push a new commit.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-16 06:49:12 +02:00
Johannes Löthberg
e93f198ede git-serve: Drop direct AccountType checking, use AUR_PRIVILEGED
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 13:04:03 +02:00
Johannes Löthberg
e9485531be git: Use AUR_USER env var instead of ForceCommand argument
Also add an utility function for formatting the ForceCommand, using
shlex.quote to quote the value.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 13:04:03 +02:00
Johannes Löthberg
ae2907a57e git: Use .format everywhere instead of %
% formatting is deprecated, and .format should be used instead.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 13:04:03 +02:00
Johannes Löthberg
3158e038c8 git-serve: Support cloning with simplified paths
This commit adds support for cloning repositories over SSH without a
leading slash or with a trailing .git

Fixes FS#45260

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-12 16:58:00 +02:00
Lukas Fleischer
078f7256e3 Support exceptions in the maintenance mode
Allow for excluding certain IP addresses from the maintenance mode. This
allows administrators to view the web page while the site is still under
maintenance for the rest of the world.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-11 14:48:01 +02:00
Lukas Fleischer
a45b5073ca Implement a maintenance mode
Add support for a maintenance mode that disables both the website and
the SSH interface and can be enabled easily using a configuration
option.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-11 14:32:21 +02:00
Lukas Fleischer
2164750f1e Do not use symrefs for manually created Git refs
When creating the refs for the package base branch and the HEAD ref
workaround, directly use commit IDs instead of symrefs. It looks like
Git cannot pack symrefs, so this is expected to improve space
efficiency. Also, since the refs are now only created (or updated) when
new objects are actually received, this fixes a problem with dangling
refs that were created when a user initialized a repository but did not
push anything.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-11 14:03:56 +02:00
Wieland Hoffmann
d5beada7c3 git-serve: Use pkgbase for errors about invalid names
`repo` is not defined at the point it's used, so you would get errors
like

> Traceback (most recent call last):
>   File "/srv/http/vhosts/aur-dev.archlinux.org/public/git-interface/git-serve.py", line 138, in <module>
>     die('%s: invalid repository name: %s' % (action, repo))
> NameError: name 'repo' is not defined

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-08 12:43:58 +02:00
Lukas Fleischer
c38f95f632 config.proto: Cleanup
Remove the template-path and git-update-hook options which are no longer
used. Update the git_clone_uri_anon default value.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-02 15:16:24 +02:00
Lukas Fleischer
6fe8792508 Setup Git repositories even if package base exists
Sometimes, we need to initialize the Git repository even if the package
base already exists (e.g. when using a non-empty package database with
empty repositories during the AUR 4.0.0 migration period). Make sure
that the package branch and the namespaced HEAD ref is always created.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-02 15:12:00 +02:00
Lukas Fleischer
10ecd3982d Restructure scripts
* Move scripts/git-integration/ to git-interface/.
* Move scripts/aurblup/aurblup.py to scripts/aurblup.py.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-02 10:34:34 +02:00
Renamed from scripts/git-integration/git-serve.py (Browse further)