Commit Graph

121 Commits

Author SHA1 Message Date
Morten Linderud c848600b4b
db-functions: Add more (terrible) heuristics for detecting debug packages
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-12-16 19:27:46 +01:00
Morten Linderud 90d3b8ba03
db-move: Implement maybe_getpkgfile and simplify debug handling
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-12-16 19:06:48 +01:00
Morten Linderud 93c0352e55
Remove debug prints
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-12-09 22:51:00 +01:00
Morten Linderud 672004c624
db-functions: Create DEBUGREPOS and DEBUGPKGPOOL
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-11-20 16:48:07 +01:00
Eli Schwartz 9e1e5f1b30
debug prints 2021-11-20 16:48:07 +01:00
Eli Schwartz b862bca856
wip: add support for debug packages 2021-11-20 16:48:07 +01:00
Eli Schwartz 998155b16b
wip: debug: lock/unlock both repos at once 2021-11-20 16:48:07 +01:00
Johannes Löthberg 9dcd82a64c
db-move: Check that the specified repositories are ones dbscripts was configured for
Otherwise if you use the dbscripts for core/extra for community repos,
or vice versa, you'll get an error saying that you don't have
permissions to move packages from or to the given repositories, which
can be confusing if you don't immediately notice your mistake.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2021-10-26 15:07:50 +02:00
Eli Schwartz eb1a090c5b
rewrite issplitpkg check to be compatible with pacman 5.1
We tried to optimize out checking packages which aren't even split
packages, by skipping the ones with no pkgbase. But pacman 5.1 always
writes the pkgbase in order to simplify parsing of the .PKGINFO, so this
was no longer reliable. Instead, check how many pkgnames are in the
corresponding PKGBUILD. This is the master source of truth anyway.
2020-06-04 23:15:37 -04:00
Eli Schwartz 60d036ead2
db-update: performance optimization when checking if a buildinfo exists
Use the --fast-read option to quit as soon as the file is first found. A
package file should never contain two of these anyway, but even if it
did, we simply want to know that one exists!

makepkg guarantees its internal .METADATA files are tar'ed up first, so
this should usually be quite rapidly found. For very large packages,
crawling the entire package file to check for a later entry overriding
the first one, is... pointless... and worst of all, slow.

This reflects the identical mode used for extracting the pkginfo file,
which was inconsistently implemented from the initial feature addition.
2019-10-17 19:06:22 -04:00
Florian Pritz 0706db69d4 Look for repro packages in live repo pool too
I've cleaned older packages from the archive, but sometimes we do not
rebuild packages in a long long time. We still keep have them in the
repository, but this check does not look for the package there, thus
when trying to db-update, the user sees an error. We fix this by also
looking at currently live packages instead of only relying on the
archive.

This is mostly a hotfix until a better solution is created. Depending on
when/how the ftpdir-cleanup cronjob removes such packages, users may
still see errors when an old package is updated and the cronjob removes
it from the repository before db-update is run.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2019-07-13 21:00:47 +02:00
Eli Schwartz f2e8d57e7f
Handle split packages properly in staging repos check.
This needs to check the pkgbase, not the pkgname, as for split packages
we need to lookup a PKGBUILD using the basename.
2019-01-13 15:03:48 -05:00
Eli Schwartz 8804e63f44
db-update: die when trying to update a package without updating a pending rebuild
A semi-common pattern is for one maintainer to stage a rebuild of a
package due to e.g. cascading repository-wide python/boost/whatever
rebuilds, and then for the original maintainer of the package to not
notice and update the package in the stable repo, leaving an out of date
rebuild in staging or testing.

Then the the out of date package gets moved and ends up breaking things,
possibly via a package downgrade, possibly via breaking compatibility
with a much more targeted rebuild uploaded all at once. Ultimately,
Things Happen™ and the repository hierarchy gets broken.

Prevent this by enforcing for all packages that exist in
multiple levels of the repo: staging -> testing -> stable

That updates to one must come with an update to all the others.
2019-01-10 13:38:45 -05:00
Eli Schwartz f11a038c43
Add reproducible archive of packages.
Whenever adding new package files to the pool of distributed packages,
copy the file into a longterm archive. This is the first step to merging
the functionality of archivetools, as this implements the shared pool
while also guaranteeing that all packages are archived at the time of
entry rather than once per day if they still exist.
2019-01-09 16:42:53 -05:00
Eli Schwartz d6b48bd61e
Preliminary work to break out svn-specific code.
Introduce "db-functions-$VCS" which will eventually contain all
VCS-specific code, and make this configurable in config.

Move private arch_svn function and svn acl handling here, and introduce
a new source_pkgbuild function to handle discovering PKGBUILDs from the
configured VCS and sourcing them to extract metadata.

The PKGBUILD is the only file we ever check out from version control,
and only ever to scrape information from it, except for when we actually
want to db-move a whole directory (which is by necessity considerably
dependent on the VCS in use).

source_pkgbuild is inspired by commits from the dbscripts rewrite,
authored by Florian Pritz <bluewind@xinu.at>
2018-10-07 21:06:15 -04:00
anthraxx 0b630e25a3
fix potential bsdtar stream close error by grep
This silences a useless error message that confuses the user.

bsdtar doesn't like it when the stream gets closed before it finishes
which may be the case when grep found its match on potentially huge
archives. Instead of suppressing the whole stderr , we find all matches
with grep, then use a second pass with `tail` to find only the last
match, which ensures the stream remains open for bsdtar but we may still
catch and see useful messages on stderr.

This works because tail has the useful property of not closing early.
2018-09-09 12:32:10 -04:00
Luke Shumaker 5b4b19cd7f
Fixup quoting around variables, especially arrays
Search for unquoted variables using the command:

    grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )'

and ignore a bunch of false positives.

You may verify that the only differences between the lines removed and
lines added are double-quotes:

        diff -u \
          <(git show|sed -n 's/^-//p'|grep -v '^-- a/'|sed 's/"//g') \
          <(git show|sed -n 's/^+//p'|grep -v '^++ b/'|sed 's/"//g')
2018-04-08 16:18:19 -04:00
Luke Shumaker 8cc8e9cbbe
Clean up printf-formatters for user messages
- db-functions: getpkgfile: The .sig file extension should be part of
   the filename parameter, not part of the message format string.

 - db-functions: arch_repo_modify: Shouldn't use ${action}
   string-interpolation in the message format string.  Since the
   entire message is a command, and we're using @Q to escape arguments
   anyway, go ahead and just construct the entire command as a single
   string that way, and feed it to '%s'.
2018-03-21 12:34:25 -04:00
Luke Shumaker 0432cffc42
Fixups near unquoted variables
Using the following command to find unquoted variables (and ignoring
more than a a few false positives),

    grep -Prn --exclude-dir=.git '(?<!["=]|\[\[ |\[\[ -[zn] )\$(?!{?#|\(|\? )'

one is lead to find a few cleanups that are something other than "add
double-quotes".  That's what these are.  We'll leave dumb adding of
double-quotes for another commit.

Most of these are still fixing quoting issues, just with a better fix.

 - parse_pkgbuilds.sh: Avoid having to escape quotes in `eval` strings
   by using `declare -p`. Updates the logic copied from makepkg, with the
   latest logic copied from makepkg. See
   https://git.archlinux.org/pacman.git/commit/?id=9e52a36794552b77ecf26f7f34b226d096978f1e
 - sourceballs: Avoid using ary=($string) to do field separation by
   using `read` and test that multiple licenses actually work as
   expected.
 - sourceballs: Replace `[[ -z ${ary[*]} ]]` with test for the array
   length
 - db-functions: Replace mangling echo field separators using sed, with
   printf formatters
 - db-functions: Replace for/echo loop to print an array line by line,
   with `printf '%s\n'`
 - db-functions: set_repo_permissions: Line up error messages, quote
   "$group"
 - db-move: Replace `$(echo ${array[@]})` with `${array[*]}`
 - testing2x: Use `"$@"` instead of `$*` when looping over an array

Also, not really quoting related but on the same line as a quoting
issue, optimize:

 - db-functions: Replace
	[[ -n "$(... | sort | uniq -D)" ]]
   with
	! ... | awk 'a[$0]++{exit 1}'
2018-03-21 12:23:17 -04:00
Luke Shumaker 36087fbd8b
Remove uses of the "v=true; if $v ..." anti-pattern
Instead, compare the value of $v to 'true'.
2018-03-19 23:50:20 -04:00
Luke Shumaker 23c2b82c33
Don't use `grep -q` when operating on piped stdin
(By default, prefer `grep &>/dev/null`)

`grep -q` may exit as soon as it finds a match; this is a good optimization
for when the input is a file.  However, if the input is the output of
another program, then that other program will receive SIGPIPE, and further
writes will fail.  When this happens, it might (bsdtar does) print a
message about a "write error" to stderr.  Which is going to confuse and
alarm the user.

In one of the cases (in common.bash, in the test suite), this had
already been mitigated by wrapping bsdtar in "echo "$(bsdtar ...)", as
Bash builtin echo doesn't complain if it gets SIGPIPE.  However, that
means we're storing the entire output of bsdtar in memory, which is
silly.  Additionally, the way it was implemented is also wrong;
because it was being used with `grep -qv` instead of just `grep -q`,
it *always* found a non-matching line (even something inconsequential
like `%NAME%`), and *never* triggered a test failure.

Looking at a few of these cases, it might also make sense to switch to
using `bsdtar tf` instead of `bsdtar xf` when checking membership, but
that's work for another day.
2018-03-19 23:43:46 -04:00
Luke Shumaker 97e17a5996
Add "#!/hint/bash" to the beginning of several files
It is a method of notifying text-editors that a file is in Bash syntax
without giving it a propper shebang (which would be confusing, as it
would suggest that the file should be executable), as well as working
across virtually all text-editors (unlike "-*- Mode: Bash -*-" or
whatever).
2018-03-19 23:43:46 -04:00
Luke Shumaker 41333413f1
Export TMPDIR, and use mktemp -t instead of making it part of the template 2018-03-19 23:43:46 -04:00
Eli Schwartz 5c867ea3b8
fixup! Update messages to make fuller use of printf formatters
pkgs should be passed as a single argument
2018-03-16 00:14:17 -04:00
Luke Shumaker 33aae31854
Update messages to make fuller use of printf formatters
These are things that were (IMO) missed in 5afac1e.  I found them using:

    git grep -E '(plain|msg|msg2|warning|error|die) "[^"]*\$'

I went a little above-and-beyond for escaping strings for the error
messages in db-functions' arch_repo_add and arch_repo_remove.  The
code should explain itself, but I wanted to point it out, as it's more than
the usual "slap %s in there, and move the ${...} to the right".
2018-03-15 21:52:39 -04:00
Eli Schwartz f22f155472
db-functions: unify the repo-add/repo-remove caller
Use less duplicated logic, opening the way to more elegantly change
the interface for the repo-add/repo-remove scripts which are themselves
symlinked together and mostly have the same interface.
2018-02-26 17:57:31 -05:00
Eli Schwartz e53cad6e4a
Globally set $PKGEXT to a bash extended glob representing valid choices.
The current glob `*.pkg.tar.?z` is both less restrictive and more
restrictive than makepkg, as it accepts any valid unicode character.

To be more exact, it's almost completely orthogonal to the one in makepkg.

makepkg only accepts .tar.gz, .tar.bz2, .tar.xz, .tar.lzo, .tar.lrz, and
.tar.Z and most of those fail to match against a two-char compression type.

dbscripts accepts .pkg.tar.💩z which incidentally is what I think of
cherry-picking xz and gz as supported methods.

Since this can be anything makepkg.conf accepts, it needs to be able to
match all that, unless we decide to perform additional restrictions in
which case we should still explicitly list each allowed extension. Using
bash extended globbing allows us to do this relatively painlessly.

Document the fact that this has *always* been some sort of glob, and
update the two cases where this was (not!) being evaluated by bash
[[ ... ]], to use a not-elegant-at-all proxy function is_globfile() to
evaluate globs *before* testing if they exist.
2018-02-22 00:20:32 -05:00
Eli Schwartz 3e01ba9a82
db-update: replace external find command with bash globbing
Don't bother emitting errors. bash doesn't show globbing errors if it
cannot read a directory to try globbing there. And the former code never
aborted on errors anyway, as without `set -o pipefail` the sort command
swallowed the return code.
2018-02-20 00:34:41 -05:00
Eli Schwartz 07e6a91da1
Fix overloading PKGEXT to mean two things.
PKGEXT is a makepkg variable referring to a fixed filename suffix, but
we were also using it to mean a bash glob referring to candidate
filenames. This is wrong, so rename it to PKGEXTS which is more
descriptive of its purpose.

Exclude the testsuite from this change, as the testsuite actually uses
PKGEXT for its intended purpose. Fix the testsuite to consistently use
PKGEXT, as it hardcoded the file extension in several cases, and pin
its value to .pkg.tar.xz
2018-02-20 00:34:06 -05:00
Eli Schwartz 36b71d3231 db-functions: deduplicate some repeated logic
reuse getpkgfile() in getpkgfiles()
2018-02-15 16:41:37 +01:00
Eli Schwartz b61a7148ea Use more bashisms
Fix numerous instances of POSIX `[ ... ]`, including reliance on ugly
deprecated constructs like POSIX `-a`. Since we require bash regardless,
it makes sense to take full advantage of it.

bash `[[ ... ]]` does not require quoting variables as the shell
natively recognizes them as variables rather than expanded strings.

Use shell arithmetic rather than test, when checking numerical values.
2018-02-15 16:41:37 +01:00
Eli Schwartz f4f9d1a009 Use modern bash to append to strings/arrays.
Rather than using ugly hacks like arr[${#arr[*]}]="foo", bash 3.1 has
the += operator.

Update strings to use the same operator while we are at it.
2018-02-15 16:41:37 +01:00
Eli Schwartz a7b497e834 ARCHES is an array, do not attempt to call it as a string
This meant only the first array element was checked in
check_repo_permission(). Although arguably this should never cause real
issues as something else would have to be broken if multiple
architectures have different permissions, we should catch this now
anyway.
2018-02-15 16:41:37 +01:00
Eli Schwartz 5afac1ed83 Update messages to make full use of printf formatters
libmakepkg messaging functions provide automatic access to gettext
(which we do not currently make use of) in addition to cleanly
separating data from message strings.

In order for this to work properly, pass argv correctly from die() to
libmakepkg's error()
2018-02-15 16:41:37 +01:00
Eli Schwartz eec8e35eba Use return codes properly when checking for failed commands.
Rather than doing a test(1) on the numerical value of the return code,
use the `if !` and `||` operators during control flow.
2018-02-15 16:41:37 +01:00
Pierre Schmitz 76f95dd139 Allways build packages for all supported architectures 2017-04-20 21:55:23 +02:00
Pierre Schmitz 625fa02f6a use makepkg library instead of local function copies 2017-04-18 20:20:49 +02:00
Pierre Schmitz e84b36059f db-update: Disallow invalid package names 2017-04-18 18:13:01 +02:00
Pierre Schmitz ec7d4fdced Signing packages is no longer optional 2017-04-18 17:20:28 +02:00
Levente Polyak 282bf65c81 disallow packages not built in a chroot
double shame!
This will detect both, packages with missing .BUILDINFO (built in
non updated environments) and packages that are not built in a
chroot at all (indicated by non default builddir).

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2016-02-16 19:31:01 +01:00
Pierre Schmitz fbd17dc8ed Remove separate creation of file databases
With pacman 5.0 repo-add and repo-remove handle file databases by default.
2016-02-07 09:47:03 +01:00
Dave Reisner 4fcedea4ae disallow packages without a valid PACKAGER
Shame.

Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2014-11-01 12:13:34 +01:00
Florian Pritz 0b43e8cdee Add lastupdate file
This allows for faster checking if an update might be needed and helps
to let reporead run when something changed.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2013-11-02 10:29:29 +01:00
Jan Alexander Steffens (heftig) fbce7db101 sourceballs: fix ACL issues on nymeria
ACLs from the WORKDIR were used, leading to problems as these weren't
world-readable. Fix follows ftpdir-cleanup.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-11-02 10:18:36 +01:00
Pierre Schmitz 868adfa404 Grant the SVNUSER access to the working directory 2012-11-04 19:04:38 +01:00
Pierre Schmitz b2952784db Add the possibility to run all svn commands with a different user
* A SVNUSER can be configured in the config file
* This user needs to be able to call svn without a password
2012-10-27 14:39:47 +02:00
Pierre Schmitz a539598c64 Use pacman-key to check signatures as it now uses a correct exit value 2012-10-03 14:50:03 +02:00
Pierre Schmitz 332346d063 grep has been moved to /usr 2012-08-05 12:19:28 +02:00
Pierre Schmitz fe19d9cff1 Remove support for packages that are not in the package pool 2012-06-10 12:02:50 +02:00
Pierre Schmitz 180e655748 Respect TMPDIR config when creating the working directory 2012-04-29 09:18:52 +02:00