Compare commits

..

60 Commits

Author SHA1 Message Date
Levente Polyak
d8d2e23247 Version 20190821 2019-08-21 19:23:03 +02:00
Eli Schwartz
be44b9cde1 makechrootpkg: with -n, check if the package failed to install
We previously whitelisted this return code because split packages can
frequently conflict each other, so makepkg -i is *expected* to fail in
such a case. However, there is no good reason to let this succeed if the
pkgbase only builds one pkgname -- that will always be a severe issue.

Add a check for how many split

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:54 +02:00
Eli Schwartz
7b0a11677a makechrootpkg: make the -U option work for the first time ever
The -U option was initially introduced in commit
cda9cf436b in order to enable running
makechrootpkg as root, delegating to another, manually selected, user to
perform various non-root tasks (given that makepkg was modified to throw
fatal errors when run as root without the option of --asroot to disable
that). However, it was only ever implemented for the --verifysource
option outside of the chroot, and the builduser inside the chroot is
created with the same uid as the makechrootpkg invoker. It needs to run
as the same uid, because it needs rw access to $startdir and $SRCDEST!
Additionally this lets the invoking user more easily inspect the build
directory in case of problems...

The correct solution for this is to properly implement the initial
intention of the -U option, and make it override the autodetection of
the "invoking user" which is normally done by inspecting $SUDO_USER.
This is then used as the single source of truth for "who am I pretending
to be".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
93dbb14ab9 archrelease: actually fail in failure conditions
When svn ls fails due to network timeouts, this currently results in
archrelease deleting all files, then committing this as the changeset.
This causes data loss...

With bash 4.4 and using wait $! we can get return the return code of the
last backgrounded command -- which process substitution qualifies as.
Key off of this to make sure that `svn ls` actually succeeded.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
10c6efc440 archbuild: prefer repo/arch-specific configs if they exist
When mixing and matching different repos and architectures not present
in mainline archlinux, it is sometimes desirable to set up differing
presets with more granularity than devtools currently allows.

One example of this is when building for architectures that are only
supported by another project -- in order to coexist on a mainline
archlinux host, a different mirrorlist needs to be used.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
8e4293034b makechrootpkg: also downgrade packages when updating chroots
Packages should never be getting downgraded... unless a package is
pulled from testing, e.g. for example if gcc9 totally breaks the linux
kernel. In such cases, the master repo says there is a downgrade, so
we'd better go with that. Basically, ensure that packages match the repo
they are being built against. Consistency at all costs!

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
b7893a2ca8 makechrootpkg: when installing with -I, ensure package is installed
noconfirm is wrong here, as we don't want to accept the default answer
-- we want to install the new package, even if it conflicts and provides
an existing one. After all, we explicitly asked for it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
bec29e632b arch-nspawn: unshare the gpg namespace to prevent zombie processes
gpg-agent is really annoying and leaves useless copies of itself around.
Using unshare ensures that all such processes are killed as soon as the
main gpg process dies.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
70f3b8ddb8 finddeps: suppress error messages for unreadable directories
If the find command cannot descend into a directory in order to search
for a PKGBUILD, it is likely a "$pkgdir" which makepkg sets as
unreadable. As far as finddeps is concerned, this error message is not
needed.

Also convert to using null-delimited paths on general principle to
prevent read from splitting on odd paths.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:53 +02:00
Eli Schwartz
5fcd90a212 makechrootpkg: accept arguments useful to verifysource
And pass them on to download_sources outside the chroot.

Fixes FS#35652

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
f6f4da26cb makechrootpkg: fix breakage in makepkg option parsing
In commit bd826752c9, support for short
options was added to the heuristic for --noextract, but in the process,
we changed to loop over the set of user options plus the builtin
defaults for inside the chroot. This was wrong, as we only care about
the user options -- moreover, it prevents us from adding verifysource
support *outside* the chroot, for options that are also chroot options,
like --holdver.

Also remove uselessly duplicated line.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
40a90e2cab ensure that sane umask is used where needed
If a user umask is restrictive, a chroot may be created as root without the
ability for the user to read it, which then causes makepkg
--verifysource to fail.

Do not set this in lib/common.sh, where it would apply to all scripts,
as we do not want to override the user's policy for things like $SRCDEST
files, svn checkouts, etc.

Fixes FS#47625

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
74a6641946 Escape paths with ":" that are passed to systemd-nspawn --bind
When parsing paths to automatically make available to the container, the
":" is used internally by systemd-nspawn to signify destinations in the
container. Replace automatically with "\:" for the mounts that we set
up, in order to safely handle a working directory etc. that contains
this character.

For bind options exposed to the user, it is assumed the user takes care
of passing systemd-nspawn compatible paths themselves.

Fixes FS#60845

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
69112171e5 arch-nspawn: support bind-mounting custom file:/// repositories
Fixes FS#45882

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
c14338c0fe checkpkg: implement comparison against alternative targets
This allows comparing the currently built set of packages against
targets named by filename, url, or pkgname. One example use is to
compare a package against a different version that was never in the
repos; another example use is to compare a *-git package against the
non-git version.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
8dbf95cdd4 makechrootpkg: check truthiness using shell arithmetic
Using the literal strings "true" and "false" is inaccurate and may
result in uncertainty of whether it is set when doing string comparison,
or simply rely on the shell implementation of treating the string as a
command builtin, then executing the value as a shell command. Emulate
makepkg, which makes heavy use of shell arithmetic for this purpose.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:52 +02:00
Eli Schwartz
46d614d91a Revert "makechrootpkg: Have functions be more function-y."
This reverts (the bulk of) commit 2fd5931a8c.

Reducing globals makes little sense in in a oneshot bash script, but
reduces code clarity and in fact resulted in bugs because even the
commit author couldn't keep track of the script state.

An exit was changed to a return, even though that made no sense outside
of a function, and has been duly returned to being an exit. This was
never tested and later papered over by wrapping the entire script in a
main() function and then calling the function for hysterical raisins.

The functiony nature of sync_chroot/delete_chroot is preserved, as those
functions demonstrate meaningfully standalone functionality -- who
knows? we may want to reuse this. Everything else is tightly bound to
the internal logic of makechrootpkg.

Completely separate functionality that was silently implemented in the
original commit is also preserved:
- declare a couple of variables as locals
- move the abort-on-no-PKGBUILD outside the install_packages function

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz
df0d6b867b Revert "makechrootpkg: Avoid having code floating around outside of a function."
This reverts commit 49088b0860.

The fundamental intention was flawed and broken, it caused annoying
issues and regressions, and the self-avowed sole purpose of the change
was so that a downstream project could *post-modify the script and
source it as a library*.

That is not okay. You don't wrap non-factorable code in a function
called main() and call it a library. The only possible use for this is
to treat makechrootpkg *internals* as a library, which is not supported.

Downstream projects that wish to use the functionality of makechrootpkg
should treat makepkg as a command with a public API in the form of
command line options. That is kind of how commands of all kinds work,
since forever. That is how all users of makechrootpkg *except for
parabola* use it.

Arguments that "it saves us the cost of fork+exec to bash" are simply
invalid.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz
8f5a02b23d Don't rely on $0 to determine script names.
Programs can freely define the value of argv0 and thus it means nothing.
Instead, use the bash-specific variable explicitly designed to safely
and accurately reference the name of the currently sourced file.

This also fixes the case where simple debugging mechanisms like using
"bash -x foo" tried to treat "foo" as the unqualified $0 and therefore
broke horribly due to lack of pathnames.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz
e76d560477 Revert "mkarchroot: Don't let the environment affect pacstrap (sans proxy settings)."
This reverts commit 578a62f1e0.

mkarchroot is run as root (via check_root if needed) so the environment
should already be clean. If not, the user has broken their root
environment, and we cannot support this. It's unclear what environment
settings may or may not be messing with anything, ever, but the original
bug report happened on Parabola who perform extensive patching to
"libretools" such that the code no longer resembles devtools at all.
It's therefore likely any such bug is parabola specific, but we will
never know since the original commit message states that they don't know
why they do it either.

Parsing the user's entire exported environment via both sed and grep is
overkill for a non-bug, especially when it doesn't work for variables
declared -rx and doesn't work for things like:

export fooled_you=$'wow such hax\ndeclare -x http_proxy=lol'

Also if done properly this would rely on compgen -e to print all
exported shell variables. Or even better, loop through /proc/$$/environ
which is both null-delimited and easily parsed with the read builtin and
[[ ]]

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Brian Bidulock
27ff286ee7 arch-nspawn should not take pacman cache from host
Previously, arch-nspawn was using the hosts' pacman cache in
the chroot even when the chroot was set up with a different
cache by mkarchroot, unless specified with the -c flag.
Problem is that makechrootpkg passes no -C, -M nor -c flags
to arch-nspawn, so all values must be obtained from the
working directory.

This change take the cache directories from the pacman.conf
specified with the -C option unless the -c option was given
(as is the case when the chroot is set up with mkarchroot),
and, when neither -C nor -c is given (as is the case when
invoked by makechrootpkg), the cache directory is taken
from the pacman.conf in the working directory.

This wasn't such an issue when i686 was mainline, however,
which building packages in a chroot against archlinux32 on
an x86_64 platform, the cache of the host should _never_ be
used.

Rebased by eschwartz on top of cachedir reworking.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz
2180aabc81 arch-nspawn: don't delete the guest gpg configuration
It's important to ensure the guest has up to date data because updating
a chroot after quite some time can potentially rely on updated
archlinux-keyring, something which the host machine either kept up to
date on or manually fixed, but it kills automation to mess around with
chroot configs like that. Alternatively, signed packages added with -I
need to work, and we assume the host is configured to accept these.

That is *not* a good reason to completely nuke whatever is in the guest,
though. A guest might have been manually configured to accept keys which
aren't accepted by the host; one example of this happening in practice,
is archlinux32 when building 32-bit packages from an archlinux host.

The right solution is to append to, rather thna overwrite, the chrooted
guest's pacman keyring.

To do this, we will use gpg's native facility to dump the keyring from
one GNUPGHOME and import it into another. We'd use pacman-key's --import
option directly, but this doesn't support passing custom options like
--import-options import-local-sigs
Finally use pacman-key's native facility to import the trust status from
the host.

While we are at it, fix a bug where we didn't respect the host's
pacman.conf settings for the GpgDir. While it isn't wildly likely a user
will choose to customize this, it is a valid and supported use case and
we must think about this ourselves.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:41:51 +02:00
Eli Schwartz
2f929c961f fixup commit "arch-nspawn: get all mirrors from host"
In commit d9b7350448, a line was deleted
that had a shellcheck ignore marker, but the marker itself was left in
(and had nothing to do). So, remove it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz
c2bbcbed64 mkarchroot: don't create a broken chroot by default
It's incorrect to make pacman completely useless inside the chroot by
starting off with no pacman keyring. Assuming that the only consumers of
a new chroot will be arch-nspawn (which copies over the hostconf) is
bad design, and furthermore makes it impossible to fix other issues in
arch-nspawn itself.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz
b7ce90fefc makechrootpkg: load makepkg.conf variables correctly
Since makepkg.conf is a bash-compatible configuration file, it must be
sourced.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz
f52002955c Makefile: don't inject DESTDIR into the pkgdatadir
In commit 46c4def073, we added support for
nonstandard PREFIX installations, but DESTDIR was and is never supposed
to be a part of that. While DESTDIR isn't terribly likely to be used
during `make all` invocations, that's no reason to break horribly if it
is used for some reason.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:40:05 +02:00
Eli Schwartz
58374246c4 Migrate pacman.conf CacheDir parsing to pacman-conf
And while we're at it, make this more consistent. Currently we
unnecessarily support only one -c /path/to/cachedir option.

This requires slightly more thorough handling in mkarchroot to ensure
all custom cachedirs are passed on to arch-nspawn. Rework
to simply forward all arguments to arch-nspawn (minus final arguments
used for pacman -Sy packagelist).

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2019-08-09 19:39:45 +02:00
Levente Polyak
f522ce2277 offload-build: disable shellcheck false-positive for shell-escape 2019-06-13 00:17:11 +02:00
Eli Schwartz via arch-projects
7747749610 doc: add manpage for the new offload-build tool
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:10 +02:00
Eli Schwartz via arch-projects
25b4ef2799 Add new tool: offload-build
This tool is useful for running makechrootpkg on a remote build server,
and is by default hooked up to send a PKGBUILD and initiate a build on
our shiny new build server "dragon".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:10 +02:00
Eli Schwartz via arch-projects
ad4b66830a Revert "makechrootpkg: sync_chroot: Make more general."
This reverts commit 6d1992909c.

It has never worked. In commit c86823a2d4
it was noted that it compared the device numbers for [[ $1 = $1 ]] which
was a useless check and always returned true, for *any* btrfs
filesystem. Now that the function is corrected to compare [[ $1 = $2 ]]
the check is still useless, but this time because it always returns
false -- btrfs subvolumes on the same filesystem do *not* share device
numbers.

So let's go back to the original working implementation that only
matters in terms of makechrootpkg, and just checks if makechrootpkg's
root working directory is btrfs (in which case we know it will be a
subvolume because mkarchroot will create it that way).

This restores our special support for the btrfs filesystem.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-06-12 23:42:05 +02:00
Erich Eckner
321e998020 fix whitespace/indentation errors
Some lines are indented by spaces, while adjacent lines are indentet by tabs.
We should use tabs on both.

Signed-off-by: Erich Eckner <git@eckner.net>
2019-04-20 17:58:55 +02:00
Erich Eckner
c86823a2d4 is_same_fs() in lib/archroot.sh should use $1 and $2, not $1 and $1
The old behaviour would always evaluate to true - this is certainly not
what that function should do.

Signed-off-by: Erich Eckner <git@eckner.net>
2019-04-20 17:55:31 +02:00
Levente Polyak
a49f55cbed Version 20190329 2019-03-29 21:40:28 +01:00
Levente Polyak
5c016c38f2 readme: fix faulty whitespace in release commands 2019-03-29 21:40:28 +01:00
Levente Polyak
1d4a60874b make: fix faulty install targets
This fixes a regression introduced in eeb1c0e59e
2019-03-29 21:40:28 +01:00
Eli Schwartz via arch-projects
b66ce081e7 fix up sogrep manpage to correspond with current sogrep command
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:55 +01:00
Eli Schwartz via arch-projects
1ab9b34c4c add sogrep command
This is the new and improved, canonical sogrep command, now with a valid
license.

The previous version of sogrep had several issues and inefficiencies,
and ultimately wasn't really the finished project I wanted it to be. Due
to a mistake in communication, I was totally unaware it was in the
process of being merged at all, nor that there was a licensing issue, or
I would have recommended waiting for both further improvements, and a
declaration of license intent; nevertheless, here it is now, and I
formally give this over into the GPLv2+ domain.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:55 +01:00
Eli Schwartz via arch-projects
ebba5a5885 sogrep: don't be templated when it is not templated
Partition the Makefile targets to only clean configured files, and make
the configured files be a subset of the bin programs.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-03-28 21:17:50 +01:00
Jelle van der Waa
c9b6f58f8e Create a general README
Introduce a README which describes where to send patches and how to
release a new version of devtools.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-25 23:32:16 +01:00
Matt Robinson
155798b8b1 makechrootpkg: keep *DEST, MAKEFLAGS & PACKAGER
If makechrootpkg is called as non-root, the {SRC,SRCPKG,PKG,LOG}DEST,
MAKEFLAGS and PACKAGER environment variables are lost in the call to
check_root().

Add these to the passed keepenv list so that they are preserved instead.
2019-03-25 23:32:13 +01:00
Christian Hesse
d9b7350448 arch-nspawn: get all mirrors from host
Now that pacconf gives us all mirrors we can use them, instead of just
the first one.

Signed-off-by: Christian Hesse <mail@eworm.de>
2019-03-25 23:32:04 +01:00
Jelle van der Waa
6645701cb1 sogrep: remove duplicate sogrep
The rename of sogrep to sogrep.in failed to remove sogrep and adding it
to .gitignore.

Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
2019-03-17 14:51:19 +01:00
Jelle van der Waa
657497c91a doc: Add myself as maintainer
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:35:21 +01:00
Jelle van der Waa
90bb423304 sogrep: rename to sogrep.in so make clean works
make clean removes all .in converted files to a file without .in which
in the make clean step is removed. So running make clean will remove
sogrep since it's specified as BINPROGS. In the future this steps should
be removed for sogrep since it is a standalone script.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:29:56 +01:00
Jelle van der Waa
23f248ccfb find-libdeps: fix indentation in case
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:27:13 +01:00
Jelle van der Waa
eeb1c0e59e doc: add man pages for find-{libdeps,libprovides}
Add a simple man page for find-libdeps and find-libprovides.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-16 18:25:55 +01:00
Jelle van der Waa
936ff8da2f doc: add Environment variables section to sogrep
Add a section about environment variables which influence sogrep's
behaviour.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-13 22:17:35 +01:00
Jelle van der Waa
d123fee8ec doc: add man page for mkarchroot 2019-03-13 22:13:51 +01:00
Jelle van der Waa
4a532e38e7 crossrepomove: do not set svn propset
svn propset's where determined to be non-reproducible and therefore
where removed from svn. Don't introduce them when moving packages
between repos.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2019-03-13 22:06:00 +01:00
Sven-Hendrik Haase
f61421a3f5 Add sogrep
This is from Eli's dotfiles after he'd cleaned it up but never actually went ahead and made this PR.
I figure it's time to add it.
2019-03-13 09:16:32 +01:00
Jelle van der Waa
26b2ffc665 remove arch rm as it's not really useful
archrm is a not much more fancy rm -rf and therefore not really useful
to ship.
2019-02-24 13:37:37 +01:00
Levente Polyak
62306018f2 conf: sync makepkg.conf with latest version from pacman package 2019-02-09 14:27:31 +01:00
Levente Polyak
65b50dac40 ci: adding travis support for basic check 2019-01-22 03:33:53 +01:00
Levente Polyak
799376904d find-libdeps: in functions use return instead of continue to abort
Even if continue would work, it does exactly the same as a return
in the way this function is being used.
2019-01-22 03:32:50 +01:00
Erich Eckner
8310abb348 remove empty tree if "--verifysource" failed
makechrootpkg's download_sources() leaves a stray directory if
"makepkg --verifysource" failed. We use "setup_workdir" instead
of "mktemp -d", because this ensures the correct garbage collection.

Signed-off-by: Erich Eckner <git@eckner.net>
2019-01-22 01:44:40 +01:00
Morten Linderud
7b09525003 Expand check_root keepenv variables
Les us source makepkg.conf settings from the environemnt. This also includes
`GNUPGHOME` which is present in `makechrootpkg`, but not included in archbuild.

Signed-off-by: Morten Linderud <foxboron@archlinux.org>
2019-01-22 01:29:06 +01:00
Jelle van der Waa
e9102b2ad8 doc: add find-libprovides man page 2018-09-09 21:02:45 +02:00
Jelle van der Waa
99969c67a9 doc: Add checkpkg man page 2018-09-09 21:02:44 +02:00
Jelle van der Waa
05c81038e5 doc: Add lddd man page 2018-09-09 21:02:43 +02:00
29 changed files with 917 additions and 288 deletions

2
.gitignore vendored
View File

@@ -3,7 +3,6 @@ devtools-*.tar.gz*
archbuild archbuild
archco archco
archrelease archrelease
archrm
bash_completion bash_completion
checkpkg checkpkg
commitpkg commitpkg
@@ -16,3 +15,4 @@ zsh_completion
find-libdeps find-libdeps
crossrepomove crossrepomove
arch-nspawn arch-nspawn
doc/*.1

28
.travis.yml Normal file
View File

@@ -0,0 +1,28 @@
language: shell
sudo: required
services:
- docker
arch:
packages:
- openssh
- subversion
- rsync
- arch-install-scripts
- git
- bzr
- mercurial
- diffutils
- asciidoc
- shellcheck
script:
- sudo pacman -Syu --noconfirm --needed "${CONFIG_PACKAGES[@]}"
- make PREFIX=/usr
- make PREFIX=/usr DESTDIR="$(mktemp -d)" install
- make check || true
- SHELLCHECK_OPTS="-S error" make check
script: 'curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash'
# vim: ft=yaml ts=2 sw=2 et:

View File

@@ -1,13 +1,13 @@
V=20180531 V=20190821
PREFIX = /usr/local PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
BINPROGS = \ IN_PROGS = \
checkpkg \ checkpkg \
commitpkg \ commitpkg \
archco \ archco \
archrelease \ archrelease \
archrm \
archbuild \ archbuild \
lddd \ lddd \
finddeps \ finddeps \
@@ -18,6 +18,11 @@ BINPROGS = \
mkarchroot \ mkarchroot \
makechrootpkg makechrootpkg
BINPROGS = \
$(IN_PROGS) \
offload-build \
sogrep
CONFIGFILES = \ CONFIGFILES = \
makepkg-x86_64.conf \ makepkg-x86_64.conf \
pacman-extra.conf \ pacman-extra.conf \
@@ -60,9 +65,21 @@ BASHCOMPLETION_LINKS = \
archco \ archco \
communityco communityco
all: $(BINPROGS) bash_completion zsh_completion
edit = sed -e "s|@pkgdatadir[@]|$(DESTDIR)$(PREFIX)/share/devtools|g" MANS = \
doc/lddd.1 \
doc/checkpkg.1 \
doc/offload-build.1 \
doc/sogrep.1 \
doc/mkarchroot.1 \
doc/find-libdeps.1 \
doc/find-libprovides.1
all: $(BINPROGS) bash_completion zsh_completion man
man: $(MANS)
edit = sed -e "s|@pkgdatadir[@]|$(PREFIX)/share/devtools|g"
%: %.in Makefile lib/common.sh %: %.in Makefile lib/common.sh
@echo "GEN $@" @echo "GEN $@"
@@ -72,8 +89,13 @@ edit = sed -e "s|@pkgdatadir[@]|$(DESTDIR)$(PREFIX)/share/devtools|g"
@chmod +x "$@" @chmod +x "$@"
@bash -O extglob -n "$@" @bash -O extglob -n "$@"
$(MANS): doc/asciidoc.conf doc/footer.asciidoc
doc/%: doc/%.asciidoc
a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage -D doc $<
clean: clean:
rm -f $(BINPROGS) bash_completion zsh_completion rm -f $(IN_PROGS) bash_completion zsh_completion $(MANS)
install: install:
install -dm0755 $(DESTDIR)$(PREFIX)/bin install -dm0755 $(DESTDIR)$(PREFIX)/bin
@@ -88,6 +110,9 @@ install:
for l in ${BASHCOMPLETION_LINKS}; do ln -sf devtools $(DESTDIR)/usr/share/bash-completion/completions/$$l; done for l in ${BASHCOMPLETION_LINKS}; do ln -sf devtools $(DESTDIR)/usr/share/bash-completion/completions/$$l; done
install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco
for manfile in $(MANS); do \
install -Dm644 $$manfile -t $(DESTDIR)$(MANDIR)/man$${manfile##*.}; \
done;
uninstall: uninstall:
for f in ${BINPROGS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done for f in ${BINPROGS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
@@ -99,6 +124,9 @@ uninstall:
rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/communityco
rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
for manfile in $(MANS); do \
rm -f $(DESTDIR)$(MANDIR)/man$${manfile##*.}/$${manfile#doc/}; \
done;
dist: dist:
git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz

24
README.md Normal file
View File

@@ -0,0 +1,24 @@
# Devtools - development tools for Arch Linux
This repository contains tools for the Arch Linux distribution for building
and maintaining official repository packages.
## Patches
Patches can be send to arch-projects@archlinux.org or via a pull request on
Github. When sending patches to the mailing list make sure to set a valid
subjectprefix otherwise the email is denied by mailman. Git can be configured
as following.
```
git config format.subjectprefix 'devtools] [PATCH'
```
## Releasing
1. bump the version in the Makefile
2. Commit everything as ```Version $(date +"%Y%m%d")```
3. Create a new tag ```git tag -s $(date +"%Y%m%d")```
4. Push changes
5. Upload the source tarball with ```make dist upload```
6. Update the package

View File

@@ -13,6 +13,10 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
m4_include(lib/archroot.sh) m4_include(lib/archroot.sh)
# umask might have been changed in /etc/profile
# ensure that sane default is set again
umask 0022
working_dir='' working_dir=''
files=() files=()
@@ -35,7 +39,7 @@ while getopts 'hC:M:c:f:s' arg; do
case "$arg" in case "$arg" in
C) pac_conf="$OPTARG" ;; C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;;
c) cache_dir="$OPTARG" ;; c) cache_dirs+=("$OPTARG") ;;
f) files+=("$OPTARG") ;; f) files+=("$OPTARG") ;;
s) nosetarch=1 ;; s) nosetarch=1 ;;
h|?) usage ;; h|?) usage ;;
@@ -52,36 +56,50 @@ shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.' [[ -z $working_dir ]] && die 'Please specify a working directory.'
if [[ -z $cache_dir ]]; then pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
else if (( ${#cache_dirs[@]} == 0 )); then
cache_dirs=("$cache_dir") mapfile -t cache_dirs < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
fi fi
pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
# shellcheck disable=2016 # shellcheck disable=2016
host_mirror=$($pacconf_cmd --repo extra Server 2> /dev/null | head -1 | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') host_mirrors=($($pacconf_cmd --repo extra Server 2> /dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#'))
# shellcheck disable=2016
[[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') while read -r line; do
mapfile -t lines < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" \
--repo $line Server | sed -r 's#(.*/)[^/]+/os/.+#\1$repo/os/$arch#')
if [[ ${lines[0]} != ${host_mirrors[0]} ]]; then
for line in "${lines[@]}"; do
if [[ $line = file://* ]]; then
line=${line#file://}
in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line")
fi
done
fi
done < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)
# {{{ functions # {{{ functions
build_mount_args() { build_mount_args() {
declare -g mount_args=() declare -g mount_args=()
if [[ -n $host_mirror_path ]]; then for host_mirror in "${host_mirrors[@]}"; do
mount_args+=("--bind-ro=$host_mirror_path") if [[ $host_mirror == *file://* ]]; then
fi host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
mount_args+=("--bind-ro=${host_mirror_path//:/\\:}")
fi
done
mount_args+=("--bind=${cache_dirs[0]}") mount_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") mount_args+=("--bind-ro=${cache_dir//:/\\:}")
done done
} }
copy_hostconf () { copy_hostconf () {
cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d" unshare --fork --pid gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1
echo "Server = $host_mirror" >"$working_dir/etc/pacman.d/mirrorlist" pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1
printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist"
[[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf" [[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf"
[[ -n $makepkg_conf ]] && cp "$makepkg_conf" "$working_dir/etc/makepkg.conf" [[ -n $makepkg_conf ]] && cp "$makepkg_conf" "$working_dir/etc/makepkg.conf"

View File

@@ -20,6 +20,15 @@ fi
chroots='/var/lib/archbuild' chroots='/var/lib/archbuild'
clean_first=false clean_first=false
pacman_config="@pkgdatadir@/pacman-${repo}.conf"
if [[ -f @pkgdatadir@/pacman-${repo}-${arch}.conf ]]; then
pacman_config="@pkgdatadir@/pacman-${repo}-${arch}.conf"
fi
makepkg_config="@pkgdatadir@/makepkg-${arch}.conf"
if [[ -f @pkgdatadir@/makepkg-${repo}-${arch}.conf ]]; then
makepkg_config="@pkgdatadir@/makepkg-${repo}-${arch}.conf"
fi
usage() { usage() {
echo "Usage: $cmd [options] -- [makechrootpkg args]" echo "Usage: $cmd [options] -- [makechrootpkg args]"
echo ' -h This help' echo ' -h This help'
@@ -39,7 +48,7 @@ while getopts 'hcr:' arg; do
esac esac
done done
check_root SOURCE_DATE_EPOCH check_root SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,MAKEFLAGS,PACKAGER,GNUPGHOME
# Pass all arguments after -- right to makepkg # Pass all arguments after -- right to makepkg
makechrootpkg_args+=("${@:$OPTIND}") makechrootpkg_args+=("${@:$OPTIND}")
@@ -59,19 +68,19 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
lock_close 9 lock_close 9
rm -rf --one-file-system "${chroots}/${repo}-${arch}" rm -rf --one-file-system "${chroots}/${repo}-${arch}"
mkdir -p "${chroots}/${repo}-${arch}" mkdir -m755 -p "${chroots}/${repo}-${arch}"
setarch "${arch}" mkarchroot \ setarch "${arch}" mkarchroot \
-C "@pkgdatadir@/pacman-${repo}.conf" \ -C "${pacman_config}" \
-M "@pkgdatadir@/makepkg-${arch}.conf" \ -M "${makepkg_config}" \
"${chroots}/${repo}-${arch}/root" \ "${chroots}/${repo}-${arch}/root" \
"${base_packages[@]}" || abort "${base_packages[@]}" || abort
else else
lock 9 "${chroots}/${repo}-${arch}/root.lock" "Locking clean chroot" lock 9 "${chroots}/${repo}-${arch}/root.lock" "Locking clean chroot"
arch-nspawn \ arch-nspawn \
-C "@pkgdatadir@/pacman-${repo}.conf" \ -C "${pacman_config}" \
-M "@pkgdatadir@/makepkg-${arch}.conf" \ -M "${makepkg_config}" \
"${chroots}/${repo}-${arch}/root" \ "${chroots}/${repo}-${arch}/root" \
pacman -Syu --noconfirm || abort pacman -Syuu --noconfirm || abort
fi fi
# Always build official packages reproducibly # Always build official packages reproducibly

View File

@@ -48,7 +48,8 @@ if [[ $(svn status -q) ]]; then
fi fi
pushd .. >/dev/null pushd .. >/dev/null
IFS=$'\n' read -r -d '' -a known_files < <(svn ls -r HEAD "$trunk") mapfile -t known_files < <(svn ls -r HEAD "$trunk")
wait $! || die "failed to discover committed files"
for file in "${known_files[@]}"; do for file in "${known_files[@]}"; do
if [[ ${file:(-1)} = '/' ]]; then if [[ ${file:(-1)} = '/' ]]; then
die "archrelease: subdirectories are not supported in package directories!" die "archrelease: subdirectories are not supported in package directories!"
@@ -65,12 +66,12 @@ for tag in "$@"; do
stat_busy "Copying %s to %s" "${trunk}" "${tag}" stat_busy "Copying %s to %s" "${trunk}" "${tag}"
if [[ -d repos/$tag ]]; then if [[ -d repos/$tag ]]; then
declare -a trash mapfile -t trash < <(svn ls "repos/$tag")
trash=() wait $! || die "failed to discover existing files"
while read -r file; do if (( ${#trash[@]} )); then
trash+=("repos/$tag/$file") trash=("${trash[@]/#/repos/$tag/}")
done < <(svn ls "repos/$tag") svn rm -q "${trash[@]/%/@}"
[[ ${#trash[@]} == 0 ]] || svn rm -q "${trash[@]/%/@}" fi
else else
mkdir -p "repos/$tag" mkdir -p "repos/$tag"
svn add --parents -q "repos/$tag" svn add --parents -q "repos/$tag"

View File

@@ -1,16 +0,0 @@
#!/bin/bash
# License: Unspecified
m4_include(lib/common.sh)
if [[ -z $1 ]]; then
echo 'Usage: archrm <path to checkout>'
exit 1
fi
# FIXME: Check if there are uncommited changes
#pushd $1
#
#popd
rm -rf "$1"

View File

@@ -36,6 +36,8 @@ STARTDIR=$(pwd)
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX) TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
for _pkgname in "${pkgname[@]}"; do for _pkgname in "${pkgname[@]}"; do
comparepkg=$_pkgname
pkgurl=
target_pkgver=$(get_full_version "$_pkgname") target_pkgver=$(get_full_version "$_pkgname")
if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then
die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver" die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver"
@@ -43,16 +45,29 @@ for _pkgname in "${pkgname[@]}"; do
ln -s "$pkgfile" "$TEMPDIR" ln -s "$pkgfile" "$TEMPDIR"
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname") || if (( $# )); then
die "Couldn't download previous package for %s." "$_pkgname" case $1 in
/*|*/*)
pkgurl=file://$(readlink -m "$1") ;;
*.pkg.tar*)
pkgurl=$1 ;;
'')
;;
*)
comparepkg=$1 ;;
esac
shift
fi
[[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$comparepkg") ||
die "Couldn't download previous package for %s." "$comparepkg"
oldpkg=${pkgurl##*://*/} oldpkg=${pkgurl##*/}
if [[ ${oldpkg##*/} = "${pkgfile##*/}" ]]; then if [[ ${oldpkg} = "${pkgfile##*/}" ]]; then
die "The built package (%s) is the one in the repo right now!" "$_pkgname" die "The built package (%s) is the one in the repo right now!" "$_pkgname"
fi fi
if [[ $pkgurl = file://* ]]; then if [[ $pkgurl = file://* || ( $pkgurl = /* && -f $pkgurl ) ]]; then
ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg" ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg"
elif [[ -f "$PKGDEST/$oldpkg" ]]; then elif [[ -f "$PKGDEST/$oldpkg" ]]; then
ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg" ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg"

View File

@@ -64,7 +64,6 @@ done
msg "Adding %s to %s" "${pkgbase}" "${target_repo}" msg "Adding %s to %s" "${pkgbase}" "${target_repo}"
svn -q add "target_checkout/${pkgbase}" svn -q add "target_checkout/${pkgbase}"
svn -q propset svn:keywords 'Id' "target_checkout/${pkgbase}/trunk/PKGBUILD"
svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" target_checkout svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" target_checkout
pushd "target_checkout/${pkgbase}/trunk" >/dev/null pushd "target_checkout/${pkgbase}/trunk" >/dev/null
archrelease "${arch[@]/#/$target_repo-}" || die archrelease "${arch[@]/#/$target_repo-}" || die

37
doc/asciidoc.conf Normal file
View File

@@ -0,0 +1,37 @@
## linkman: macro
# Inspired by/borrowed from the GIT source tree at Documentation/asciidoc.conf
#
# Usage: linkman:command[manpage-section]
#
# Note, {0} is the manpage section, while {target} is the command.
#
# Show man link as: <command>(<section>); if section is defined, else just show
# the command.
[macros]
(?su)[\\]?(?P<name>linkman):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
[attributes]
asterisk=&#42;
plus=&#43;
caret=&#94;
startsb=&#91;
endsb=&#93;
backslash=&#92;
tilde=&#126;
apostrophe=&#39;
backtick=&#96;
litdd=&#45;&#45;
ifdef::backend-docbook[]
[linkman-inlinemacro]
{0%{target}}
{0#<citerefentry>}
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
{0#</citerefentry>}
endif::backend-docbook[]
ifdef::backend-xhtml11[]
[linkman-inlinemacro]
<a href="{target}.{0}.html">{target}{0?({0})}</a>
endif::backend-xhtml11[]

27
doc/checkpkg.1.asciidoc Normal file
View File

@@ -0,0 +1,27 @@
checkpkg(1)
===========
Name
----
checkpkg - Compare the current build package with the repository version
Synopsis
--------
checkpkg
Description
-----------
Searches for a locally built package corresponding to the PKGBUILD, and
downloads the last version of that package from the Pacman repositories. It
then compares the list of .so files provided by each version of the package and
outputs if there are soname differences for the new package. A directory is
also created using mktemp with files containing a file list for both packages
and a library list for both packages.
See Also
--------
linkman:find-libprovides[1]
include::footer.asciidoc[]

View File

@@ -0,0 +1,24 @@
find-libdeps(1)
===============
Name
----
find-libdeps - Find soname dependencies for a package
Synopsis
--------
find-libdeps [options]
Description
-----------
Finds soname dependencies of a package and prints out a list in the following
format '<soname>=<soversion>-<soarch>'.
Options
-------
*--ignore-internal*::
Ignore internal libraries.
include::footer.asciidoc[]

View File

@@ -0,0 +1,24 @@
find-libprovides(1)
===================
Name
----
find-libprovides - Find soname's which are provided by a package
Synopsis
--------
find-libprovides [options]
Description
-----------
Finds soname's provided by a package and prints out a list in the following
format '<soname>=<soversion>-<soarch>'.
Options
-------
*--ignore-internal*::
Ignore internal libraries.
include::footer.asciidoc[]

29
doc/footer.asciidoc Normal file
View File

@@ -0,0 +1,29 @@
Bugs
----
Bugs can be reported on the bug tracker 'https://bugs.archlinux.org' in the Arch
Linux category and title prefixed with [devtools] or via
mailto:arch-projects@archlinux.org[].
Authors
-------
Maintainers:
* Aaron Griffin <aaronmgriffin@gmail.com>
* Allan McRae <allan@archlinux.org>
* Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
* Dan McGee <dan@archlinux.org>
* Dave Reisner <dreisner@archlinux.org>
* Evangelos Foutras <evangelos@foutrelis.com>
* Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
* Jelle van der Waa <jelle@archlinux.org>
* Levente Polyak <anthraxx@archlinux.org>
* Pierre Schmitz <pierre@archlinux.de>
* Sébastien Luttringer <seblu@seblu.net>
* Sven-Hendrik Haase <svenstaro@gmail.com>
* Thomas Bächler <thomas@archlinux.org>
For additional contributors, use `git shortlog -s` on the devtools.git
repository.

25
doc/lddd.1.asciidoc Normal file
View File

@@ -0,0 +1,25 @@
lddd(1)
=======
Name
----
lddd - Find broken library links on your system
Synopsis
--------
lddd
Description
-----------
Scans '$PATH', '/lib', '/usr/lib', '/usr/local/lib' and
'/etc/ld.so.conf.d/*.conf' directories for ELF files with references to missing
shared libraries, and suggests which packages might need to be rebuilt. The
collected data is written to a temporary directory created by mktemp.
See Also
--------
linkman:ldd[1]
include::footer.asciidoc[]

46
doc/mkarchroot.1.asciidoc Normal file
View File

@@ -0,0 +1,46 @@
mkarchroot(1)
==============
Name
----
mkarchroot - Creates an arch chroot in a specified location with a specified set of packages
Synopsis
--------
mkarchroot [options] [location] [packages]
Description
-----------
'mkarchroot' is a script to create an Arch Linux chroot at a specified location
with specified packages. Typically used by 'makechrootpkg' to create build
chroots. Apart from installing specified packages the chroot is created with an
en_US.UTF-8 and de_DE.UTF-8 locale and a generated machine-id.
Options
-------
*-C* <file>::
Location of a pacman config file.
*-M* <file>::
Location of a makepkg config file.
*-c* <dir>::
Set pacman cache.
*-f* <file>::
Copy file from the host to the chroot.
*-s*::
Do not run setarch.
*-h*::
Output command line options.
See Also
--------
linkman:pacman[1]
include::footer.asciidoc[]

View File

@@ -0,0 +1,52 @@
offload-build(1)
================
Name
----
offload-build - Build a PKGBUILD on a remote server using makechrootpkg
Synopsis
--------
offload-build [OPTIONS] -- [ARCHBUILD_OPTIONS]
Description
-----------
Build a PKGBUILD on a remote server using makechrootpkg. Requires a remote user
that can run archbuild in a non-interactive manner, e.g. must be able to
elevate permissions using passwordless sudo.
Options
-------
*-r, --repo* <reponame>::
Build against a specific repository. The default is `extra`, to build packages using
the stable repositories via extra-x86_64-build.
*-a, --arch* <architecture>::
Build against a specific architecture. The default is `x86_64`, the only
architecture officially supported by Arch Linux.
*-s, --server* <hostname>::
Offload to a specific build server. The default is dragon.archlinux.org
which is used as part of the build toolchain for the official Arch Linux
repos.
*-h, --help*::
Show a help text.
Passing options to archbuild
----------------------------
Options after a delimiting -- are passed on to archbuild on the remote.
archbuild in turn supports passing arguments on to makechrootpkg, which in turn
supports passing options to makepkg. Since each uses -- to delimit options that
are forwarded, make sure to escape them properly:
`offload-build offload-args -- archbuild-args -- makechrootpkg-args -- makepkg-args`
Example: To use a second `testing-x86_64-build` instance with another copydir:
`offload-build -r testing -- -- -l <chroot_copy>`
include::footer.asciidoc[]

48
doc/sogrep.1.asciidoc Normal file
View File

@@ -0,0 +1,48 @@
sogrep(1)
=========
Name
----
sogrep - Find shared library links in an Arch Linux repository
Synopsis
--------
sogrep [options] repo libname
Description
-----------
Check the soname links database for Arch Linux repositories containing packages
linked to a given shared library. If the repository specified is "all", then
all repositories will be searched, otherwise only the named repository will be
searched.
If the links database does not exist, it will be downloaded first.
Options
-------
*-v, --verbose*::
Provide detailed output containing the matched links for each package, the
repository it came from (in the event that all repositories are being
searched), and, in combination with `-r`, a progress bar for the links
database download.
*-r, --refresh*::
Refresh the links databases
*-h, --help*::
Show a help text
Environment Variables
---------------------
**SOLINKS_MIRROR**="https://mirror.foo.com"
Alternative mirror to use for downloading soname links database.
**SOCACHE_DIR**="/path/to/directory"::
Directory where soname links database is stored, overrides the default
directory set by the **XDG_CACHE_HOME** environment variable or the
**HOME** environment variable if **XDG_CACHE_HOME** is not set.
include::footer.asciidoc[]

View File

@@ -13,7 +13,7 @@ if [[ $1 = "--ignore-internal" ]]; then
shift shift
fi fi
script_mode=${0##*/find-lib} script_mode=${BASH_SOURCE[0]##*/find-lib}
case $script_mode in case $script_mode in
deps|provides) true;; deps|provides) true;;
@@ -46,7 +46,7 @@ process_sofile() {
# extract the major version: 1 # extract the major version: 1
soversion="${sofile##*\.so\.}" soversion="${sofile##*\.so\.}"
if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then
continue return
fi fi
if ! in_array "${soname}=${soversion}-${soarch}" "${soobjects[@]}"; then if ! in_array "${soname}=${soversion}-${soarch}" "${soobjects[@]}"; then
# libfoo.so=1-64 # libfoo.so=1-64
@@ -57,7 +57,7 @@ process_sofile() {
case $script_mode in case $script_mode in
deps) find_args=(-perm -u+x);; deps) find_args=(-perm -u+x);;
provides) find_args=(-name '*.so*');; provides) find_args=(-name '*.so*');;
esac esac
find . -type f "${find_args[@]}" | while read -r filename; do find . -type f "${find_args[@]}" | while read -r filename; do

View File

@@ -17,7 +17,7 @@ if [[ -z $match ]]; then
exit 1 exit 1
fi fi
find . -type d | while read -r d; do find . -type d -print0 2>/dev/null| while read -r -d '' d; do
if [[ -f "$d/PKGBUILD" ]]; then if [[ -f "$d/PKGBUILD" ]]; then
pkgname=() depends=() makedepends=() optdepends=() pkgname=() depends=() makedepends=() optdepends=()
# shellcheck source=PKGBUILD.proto # shellcheck source=PKGBUILD.proto

View File

@@ -8,7 +8,7 @@ CHROOT_VERSION='v4'
## ##
# usage : check_root $keepenv # usage : check_root $keepenv
## ##
orig_argv=("$0" "$@") orig_argv=("${BASH_SOURCE[0]}" "$@")
check_root() { check_root() {
local keepenv=$1 local keepenv=$1
@@ -37,14 +37,6 @@ is_subvolume() {
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]] [[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs && "$(stat -c %i "$1")" == 256 ]]
} }
##
# usage : is_same_fs( $path_a, $path_b )
# return : whether $path_a and $path_b are on the same filesystem
##
is_same_fs() {
[[ "$(stat -c %d "$1")" == "$(stat -c %d "$1")" ]]
}
## ##
# usage : subvolume_delete_recursive( $path ) # usage : subvolume_delete_recursive( $path )
# #

View File

@@ -15,6 +15,29 @@ m4_include(lib/archroot.sh)
shopt -s nullglob shopt -s nullglob
default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg)
makepkg_args=("${default_makepkg_args[@]}")
verifysource_args=()
chrootdir=
passeddir=
makepkg_user=
declare -a install_pkgs
declare -i ret=0
keepbuilddir=0
update_first=0
clean_first=0
run_namcap=0
temp_chroot=0
bindmounts_ro=()
bindmounts_rw=()
copy=$USER
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
[[ -z "$copy" || $copy = root ]] && copy=copy
src_owner=${SUDO_USER:-$USER}
usage() { usage() {
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]" echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
echo ' Run this script in a PKGBUILD dir to build a package inside a' echo ' Run this script in a PKGBUILD dir to build a package inside a'
@@ -69,43 +92,37 @@ load_vars() {
[[ -f $makepkg_conf ]] || return 1 [[ -f $makepkg_conf ]] || return 1
for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do
[[ -z ${!var:-} ]] && eval "$(grep -a "^${var}=" "$makepkg_conf")" [[ -z ${!var:-} ]] && eval "$(source "$makepkg_conf"; printf "%s='%s'" "$var" "${!var}")"
done done
return 0 return 0
} }
# Usage: sync_chroot $rootdir $copydir [$copy] # Usage: sync_chroot $chrootdir $copydir [$copy]
sync_chroot() { sync_chroot() {
local rootdir=$1 local chrootdir=$1
local copydir=$2 local copydir=$2
local copy=${3:-$2} local copy=${3:-$2}
if [[ "$rootdir" -ef "$copydir" ]]; then if [[ "$chrootdir/root" -ef "$copydir" ]]; then
error 'Cannot sync copy with itself: %s' "$copydir" error 'Cannot sync copy with itself: %s' "$copydir"
return 1 return 1
fi fi
# Get a read lock on the root chroot to make # Get a read lock on the root chroot to make
# sure we don't clone a half-updated chroot # sure we don't clone a half-updated chroot
slock 8 "$rootdir.lock" \ slock 8 "$chrootdir/root.lock" \
"Locking clean chroot [%s]" "$rootdir" "Locking clean chroot [%s]" "$chrootdir/root"
stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$rootdir" "$copy" stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copy"
if is_subvolume "$rootdir" && is_same_fs "$rootdir" "$(dirname -- "$copydir")" && ! mountpoint -q "$copydir"; then if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
if is_subvolume "$copydir"; then subvolume_delete_recursive "$copydir" ||
subvolume_delete_recursive "$copydir" || die "Unable to delete subvolume %s" "$copydir"
die "Unable to delete subvolume %s" "$copydir" btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
else
# avoid change of filesystem in case of an umount failure
rm --recursive --force --one-file-system "$copydir" ||
die "Unable to delete %s" "$copydir"
fi
btrfs subvolume snapshot "$rootdir" "$copydir" >/dev/null ||
die "Unable to create subvolume %s" "$copydir" die "Unable to create subvolume %s" "$copydir"
else else
mkdir -p "$copydir" mkdir -p "$copydir"
rsync -a --delete -q -W -x "$rootdir/" "$copydir" rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
fi fi
stat_done stat_done
@@ -136,11 +153,7 @@ delete_chroot() {
stat_done stat_done
} }
# Usage: install_packages $copydir $pkgs...
install_packages() { install_packages() {
local copydir=$1
local install_pkgs=("${@:2}")
local -a pkgnames local -a pkgnames
local ret local ret
@@ -148,28 +161,19 @@ install_packages() {
cp -- "${install_pkgs[@]}" "$copydir/root/" cp -- "${install_pkgs[@]}" "$copydir/root/"
arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
pacman -U --noconfirm -- "${pkgnames[@]/#//root/}" bash -c 'yes y | pacman -U -- "$@"' -bash "${pkgnames[@]/#//root/}"
ret=$? ret=$?
rm -- "${pkgnames[@]/#/$copydir/root/}" rm -- "${pkgnames[@]/#/$copydir/root/}"
return $ret return $ret
} }
# Usage: prepare_chroot $copydir $HOME $keepbuilddir $run_namcap
# Globals:
# - MAKEFLAGS
# - PACKAGER
prepare_chroot() { prepare_chroot() {
local copydir=$1 (( keepbuilddir )) || rm -rf "$copydir/build"
local USER_HOME=$2
local keepbuilddir=$3
local run_namcap=$4
[[ $keepbuilddir = true ]] || rm -rf "$copydir/build"
local builduser_uid builduser_gid local builduser_uid builduser_gid
builduser_uid="${SUDO_UID:-$UID}" builduser_uid="$(id -u "$makepkg_user")"
builduser_gid="$(id -g "$builduser_uid")" builduser_gid="$(id -g "$makepkg_user")"
local install="install -o $builduser_uid -g $builduser_gid" local install="install -o $builduser_uid -g $builduser_gid"
local x local x
@@ -204,7 +208,7 @@ EOF
declare -p SOURCE_DATE_EPOCH 2>/dev/null || true declare -p SOURCE_DATE_EPOCH 2>/dev/null || true
printf '_chrootbuild "$@" || exit\n' printf '_chrootbuild "$@" || exit\n'
if [[ $run_namcap = true ]]; then if (( run_namcap )); then
declare -f _chrootnamcap declare -f _chrootnamcap
printf '_chrootnamcap || exit\n' printf '_chrootnamcap || exit\n'
fi fi
@@ -228,8 +232,15 @@ _chrootbuild() {
sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@" sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@"
ret=$? ret=$?
case $ret in case $ret in
0|14) 0)
return 0;; return 0;;
14)
# whitelist "The package failed to install." but only if there are multiple split packages
# in which case they might be conflicting
local pkgfiles=(/pkgdest/*.pkg.tar.xz)
(( ${#pkgfiles[@]} > 1))
return $?;;
*) *)
return $ret;; return $ret;;
esac esac
@@ -243,36 +254,18 @@ _chrootnamcap() {
done done
} }
# Usage: download_sources $copydir $makepkg_user
# Globals:
# - SRCDEST
download_sources() { download_sources() {
local copydir=$1 setup_workdir
local makepkg_user=$2 chown "$makepkg_user:" "$WORKDIR"
local builddir
builddir="$(mktemp -d)"
chown "$makepkg_user:" "$builddir"
# Ensure sources are downloaded # Ensure sources are downloaded
sudo -u "$makepkg_user" --preserve-env=GNUPGHOME \ sudo -u "$makepkg_user" --preserve-env=GNUPGHOME \
env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ env SRCDEST="$SRCDEST" BUILDDIR="$WORKDIR" \
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o "${verifysource_args[@]}" ||
die "Could not download sources." die "Could not download sources."
# Clean up garbage from verifysource
rm -rf "$builddir"
} }
# Usage: move_products $copydir $owner
# Globals:
# - PKGDEST
# - LOGDEST
# - SRCPKGDEST
move_products() { move_products() {
local copydir=$1
local src_owner=$2
local pkgfile local pkgfile
for pkgfile in "$copydir"/pkgdest/*; do for pkgfile in "$copydir"/pkgdest/*; do
chown "$src_owner" "$pkgfile" chown "$src_owner" "$pkgfile"
@@ -303,140 +296,115 @@ move_products() {
} }
# }}} # }}}
main() { while getopts 'hcur:I:l:nTD:d:U:' arg; do
default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) case "$arg" in
makepkg_args=("${default_makepkg_args[@]}") c) clean_first=1 ;;
keepbuilddir=false D) bindmounts_ro+=("--bind-ro=$OPTARG") ;;
update_first=false d) bindmounts_rw+=("--bind=$OPTARG") ;;
clean_first=false u) update_first=1 ;;
run_namcap=false r) passeddir="$OPTARG" ;;
temp_chroot=false I) install_pkgs+=("$OPTARG") ;;
chrootdir= l) copy="$OPTARG" ;;
passeddir= n) run_namcap=1; makepkg_args+=(--install) ;;
makepkg_user= T) temp_chroot=1; copy+="-$$" ;;
declare -a install_pkgs U) makepkg_user="$OPTARG" ;;
declare -i ret=0 h|*) usage ;;
esac
done
bindmounts_ro=() [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
bindmounts_rw=() [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}}
copy=$USER check_root SOURCE_DATE_EPOCH,GNUPGHOME,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,MAKEFLAGS,PACKAGER
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
[[ -z "$copy" || $copy = root ]] && copy=copy
src_owner=${SUDO_USER:-$USER}
while getopts 'hcur:I:l:nTD:d:U:' arg; do # Canonicalize chrootdir, getting rid of trailing /
case "$arg" in chrootdir=$(readlink -e "$passeddir")
c) clean_first=true ;; [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
D) bindmounts_ro+=("--bind-ro=$OPTARG") ;; [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
d) bindmounts_rw+=("--bind=$OPTARG") ;;
u) update_first=true ;;
r) passeddir="$OPTARG" ;;
I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;;
n) run_namcap=true; makepkg_args+=(--install) ;;
T) temp_chroot=true; copy+="-$$" ;;
U) makepkg_user="$OPTARG" ;;
h|*) usage ;;
esac
done
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' if [[ ${copy:0:1} = / ]]; then
[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.' copydir=$copy
makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}} else
copydir="$chrootdir/$copy"
fi
check_root SOURCE_DATE_EPOCH,GNUPGHOME # Pass all arguments after -- right to makepkg
makepkg_args+=("${@:$OPTIND}")
# Canonicalize chrootdir, getting rid of trailing / # See if -R or -e was passed to makepkg
chrootdir=$(readlink -e "$passeddir") for arg in "${@:$OPTIND}"; do
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" case ${arg%%=*} in
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" --skip*|--holdver) verifysource_args+=("$arg") ;;
--repackage|--noextract) keepbuilddir=1 ;;
--*) ;;
-*R*|-*e*) keepbuilddir=1 ;;
esac
done
if [[ ${copy:0:1} = / ]]; then if [[ -n $SUDO_USER ]]; then
copydir=$copy eval "USER_HOME=~$SUDO_USER"
else else
copydir="$chrootdir/$copy" USER_HOME=$HOME
fi fi
# Pass all arguments after -- right to makepkg umask 0022
makepkg_args+=("${@:$OPTIND}")
# See if -R or -e was passed to makepkg load_vars "${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
for arg in "${makepkg_args[@]}"; do load_vars /etc/makepkg.conf
case ${arg%%=*} in
--repackage|--noextract) keepbuilddir=true; break ;;
--repackage|--noextract) keepbuilddir=true; break ;;
--*) ;;
-*R*|-*e*) keepbuilddir=true; break ;;
esac
done
if [[ -n $SUDO_USER ]]; then # Use PKGBUILD directory if these don't exist
eval "USER_HOME=~$SUDO_USER" [[ -d $PKGDEST ]] || PKGDEST=$PWD
else [[ -d $SRCDEST ]] || SRCDEST=$PWD
USER_HOME=$HOME [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
fi [[ -d $LOGDEST ]] || LOGDEST=$PWD
umask 0022 # Lock the chroot we want to use. We'll keep this lock until we exit.
lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
load_vars "${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf" if [[ ! -d $copydir ]] || (( clean_first )); then
load_vars /etc/makepkg.conf sync_chroot "$chrootdir" "$copydir" "$copy"
fi
# Use PKGBUILD directory if these don't exist (( update_first )) && arch-nspawn "$copydir" \
[[ -d $PKGDEST ]] || PKGDEST=$PWD
[[ -d $SRCDEST ]] || SRCDEST=$PWD
[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
[[ -d $LOGDEST ]] || LOGDEST=$PWD
# Lock the chroot we want to use. We'll keep this lock until we exit.
lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
if [[ ! -d $copydir ]] || $clean_first; then
sync_chroot "$chrootdir/root" "$copydir" "$copy"
fi
$update_first && arch-nspawn "$copydir" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
pacman -Syu --noconfirm
if [[ -n ${install_pkgs[*]:-} ]]; then
install_packages "$copydir" "${install_pkgs[@]}"
ret=$?
# If there is no PKGBUILD we have done
[[ -f PKGBUILD ]] || return $ret
fi
if [[ "$(id -u "$makepkg_user")" == 0 ]]; then
error "Running makepkg as root is not allowed."
exit 1
fi
download_sources "$copydir" "$makepkg_user"
prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap"
if arch-nspawn "$copydir" \
--bind="$PWD:/startdir" \
--bind="$SRCDEST:/srcdest" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
/chrootbuild "${makepkg_args[@]}" pacman -Syuu --noconfirm
then
move_products "$copydir" "$src_owner" if [[ -n ${install_pkgs[*]:-} ]]; then
install_packages
ret=$?
# If there is no PKGBUILD we are done
[[ -f PKGBUILD ]] || exit $ret
fi
if [[ "$(id -u "$makepkg_user")" == 0 ]]; then
error "Running makepkg as root is not allowed."
exit 1
fi
download_sources
prepare_chroot
if arch-nspawn "$copydir" \
--bind="${PWD//:/\\:}:/startdir" \
--bind="${SRCDEST//:/\\:}:/srcdest" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
/chrootbuild "${makepkg_args[@]}"
then
move_products
else
(( ret += 1 ))
fi
(( temp_chroot )) && delete_chroot "$copydir" "$copy"
if (( ret != 0 )); then
if (( temp_chroot )); then
die "Build failed"
else else
(( ret += 1 )) die "Build failed, check %s/build" "$copydir"
fi fi
else
$temp_chroot && delete_chroot "$copydir" "$copy" true
fi
if (( ret != 0 )); then
if $temp_chroot; then
die "Build failed"
else
die "Build failed, check %s/build" "$copydir"
fi
else
true
fi
}
main "$@"

View File

@@ -11,9 +11,10 @@
# #
#-- The download utilities that makepkg should use to acquire sources #-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent' # Format: 'protocol::agent'
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o' 'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o') 'scp::/usr/bin/scp -C %u %o')
@@ -37,11 +38,9 @@ CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu" CHOST="x86_64-pc-linux-gnu"
#-- Compiler and Linker Flags #-- Compiler and Linker Flags
# -march (or -mcpu) builds exclusively for an architecture
# -mtune optimizes for an architecture, but builds for whole processor family
CPPFLAGS="-D_FORTIFY_SOURCE=2" CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt" CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt" CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
#-- Make Flags: change this for DistCC/SMP systems #-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2" #MAKEFLAGS="-j2"
@@ -53,7 +52,7 @@ DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
# BUILD ENVIRONMENT # BUILD ENVIRONMENT
######################################################################### #########################################################################
# #
# Defaults: BUILDENV=(!distcc color !ccache check !sign) # Defaults: BUILDENV=(!distcc !color !ccache check !sign)
# A negated environment option will do the opposite of the comments below. # A negated environment option will do the opposite of the comments below.
# #
#-- distcc: Use the Distributed C/C++/ObjC compiler #-- distcc: Use the Distributed C/C++/ObjC compiler
@@ -76,7 +75,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings # These are default values for the options=() settings
######################################################################### #########################################################################
# #
# Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !optipng !upx !debug) # Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
# A negated option will do the opposite of the comments below. # A negated option will do the opposite of the comments below.
# #
#-- strip: Strip symbols from binaries/libraries #-- strip: Strip symbols from binaries/libraries
@@ -86,11 +85,9 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- emptydirs: Leave empty directories in packages #-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS #-- purge: Remove files specified by PURGE_TARGETS
#-- upx: Compress binary executable files using UPX
#-- optipng: Optimize PNG images with optipng
#-- debug: Add debugging flags as specified in DEBUG_* variables #-- debug: Add debugging flags as specified in DEBUG_* variables
# #
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !optipng !upx !debug) OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5) INTEGRITY_CHECK=(md5)
@@ -106,6 +103,8 @@ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified) #-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"
######################################################################### #########################################################################
# PACKAGE OUTPUT # PACKAGE OUTPUT

View File

@@ -13,9 +13,14 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
m4_include(lib/archroot.sh) m4_include(lib/archroot.sh)
# umask might have been changed in /etc/profile
# ensure that sane default is set again
umask 0022
working_dir='' working_dir=''
files=() files=()
nspawn_args=()
usage() { usage() {
echo "Usage: ${0##*/} [options] working-dir package-list..." echo "Usage: ${0##*/} [options] working-dir package-list..."
@@ -33,12 +38,14 @@ while getopts 'hC:M:c:f:s' arg; do
case "$arg" in case "$arg" in
C) pac_conf="$OPTARG" ;; C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;;
c) cache_dir="$OPTARG" ;; c) cache_dirs+=("$OPTARG") ;;
f) files+=("$OPTARG") ;; f) files+=("$OPTARG") ;;
s) nosetarch=1 ;; s) nosetarch=1 ;;
h|?) usage ;; h|?) usage ;;
*) error "invalid argument '%s'" "$arg"; usage ;; *) error "invalid argument '%s'" "$arg"; usage ;;
esac esac
nspawn_args+=("-$arg")
[[ -v OPTARG ]] && nspawn_args+=("$OPTARG")
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@@ -51,10 +58,10 @@ shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.' [[ -z $working_dir ]] && die 'Please specify a working directory.'
if [[ -z $cache_dir ]]; then pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
cache_dirs=($(pacman -v "$cache_conf" 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
else if (( ${#cache_dirs[@]} == 0 )); then
cache_dirs=(${cache_dir}) mapfile -t cache_dirs < <($pacconf_cmd CacheDir)
fi fi
umask 0022 umask 0022
@@ -78,13 +85,8 @@ for file in "${files[@]}"; do
cp "$file" "$working_dir$file" cp "$file" "$working_dir$file"
done done
_env=() pacstrap -Mcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
while read -r varname; do "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
_env+=("$varname=${!varname}")
done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
env -i "${_env[@]}" \
pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen" printf '%s.UTF-8 UTF-8\n' en_US de_DE > "$working_dir/etc/locale.gen"
echo 'LANG=en_US.UTF-8' > "$working_dir/etc/locale.conf" echo 'LANG=en_US.UTF-8' > "$working_dir/etc/locale.conf"
@@ -93,8 +95,5 @@ echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot"
systemd-machine-id-setup --root="$working_dir" systemd-machine-id-setup --root="$working_dir"
exec arch-nspawn \ exec arch-nspawn \
${nosetarch:+-s} \ "${nspawn_args[@]}" \
${pac_conf:+-C "$pac_conf"} \
${makepkg_conf:+-M "$makepkg_conf"} \
${cache_dir:+-c "$cache_dir"} \
"$working_dir" locale-gen "$working_dir" locale-gen

108
offload-build Executable file
View File

@@ -0,0 +1,108 @@
#!/bin/bash
#
# offload-build - build a PKGBUILD on a remote server using makechrootpkg.
#
# Copyright (c) 2019 by Eli Schwartz <eschwartz@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# global defaults suitable for use by Arch staff
repo=extra
arch=x86_64
server=dragon.archlinux.org
die() { printf "error: $1\n" "${@:2}"; exit 1; }
usage() {
cat <<- _EOF_
Usage: ${BASH_SOURCE[0]##*/} [--repo REPO] [--arch ARCHITECTURE] [--server SERVER] -- [ARCHBUILD_ARGS]
Build a PKGBUILD on a remote server using makechrootpkg. Requires a remote user
that can run archbuild without password auth. Options passed after a -- are
passed on to archbuild, and eventually to makechrootpkg.
OPTIONS
-r, --repo Build against a specific repository (current: $repo)
-a, --arch Build against a specific architecture (current: $arch)
-s, --server Offload to a specific build server (current: $server)
-h, --help Show this help text
_EOF_
}
# option checking
while (( $# )); do
case $1 in
-h|--help)
usage
exit 0
;;
-r|--repo)
repo=$2
shift 2
;;
-a|--arch)
arch=$2
shift 2
;;
-s|--server)
server=$2
shift 2
;;
--)
shift
break
;;
*)
die "invalid argument: %s" "$1"
;;
esac
done
# multilib must be handled specially
if [[ $repo = multilib* ]]; then
arch=
fi
archbuild_cmd=("${repo}${arch:+-$arch}-build" "$@")
trap 'rm -rf $SRCPKGDEST' EXIT
# Use a source-only tarball as an intermediate to transfer files. This
# guarantees the checksums are okay, and guarantees that all needed files are
# transferred, including local sources, install scripts, and changelogs.
export SRCPKGDEST=$(mktemp -d)
makepkg --source || die "unable to make source package"
mapfile -t files < <(
# This is sort of bash golfing but it allows running a mildly complex
# command over ssh with a single connection.
# shellcheck disable=SC2145
cat "$SRCPKGDEST"/*.src.tar.gz |
ssh $server '
temp="${XDG_CACHE_HOME:-$HOME/.cache}/offload-build" &&
mkdir -p "$temp" &&
temp=$(mktemp -d -p "$temp") &&
cd "$temp" &&
{
bsdtar --strip-components 1 -xvf - &&
script -qefc "'"${archbuild_cmd[@]@Q}"'" /dev/null &&
printf "%s\n" "" "-> build complete" &&
printf "\t%s\n" "$temp"/*
} >&2 &&
makepkg --packagelist
')
(( ${#files[@]} )) && printf '%s\n' '' '-> copying files...' && scp "${files[@]/#/$server:}" .

View File

@@ -14,8 +14,8 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
if (( $# < 1 )); then if (( $# < 1 )); then
printf 'Usage: %s <chrootdir> <packages to rebuild>\n' "$(basename "$0")" printf 'Usage: %s <chrootdir> <packages to rebuild>\n' "$(basename "${BASH_SOURCE[0]}")"
printf ' example: %s ~/chroot readline bash foo bar baz\n' "$(basename "$0")" printf ' example: %s ~/chroot readline bash foo bar baz\n' "$(basename "${BASH_SOURCE[0]}")"
exit 1 exit 1
fi fi

149
sogrep Executable file
View File

@@ -0,0 +1,149 @@
#!/bin/bash
#
# sogrep - find shared library links in an Arch Linux repository.
#
# Copyright (c) 2019 by Eli Schwartz <eschwartz@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# globals
: ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"}
: ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"}
repos=('staging' 'testing' 'core' 'extra'
'community-staging' 'community-testing' 'community'
'multilib-staging' 'multilib-testing' 'multilib'
'gnome-unstable' 'kde-unstable')
arches=('x86_64')
# options
REFRESH=0
VERBOSE=0
source /usr/share/makepkg/util/parseopts.sh
source /usr/share/makepkg/util/util.sh
recache() {
local repo arch verbosity=-s
(( VERBOSE )) && verbosity=--progress-bar
for repo in "${repos[@]}"; do
for arch in "${arches[@]}"; do
rm -rf "${SOCACHE_DIR}/${arch}/${repo}"
mkdir -p "${SOCACHE_DIR}/${arch}/${repo}"
curl "$verbosity" "${SOLINKS_MIRROR}/${repo}/os/${arch}/${repo}.links.tar.gz" | bsdtar -xf - -C "${SOCACHE_DIR}/${arch}/${repo}"
done
done
}
search() {
local repo=$1 arch lib=$2 srepos=("${repos[@]}")
if [[ $repo != all ]]; then
if ! in_array "${repo}" "${repos[@]}"; then
echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'"
echo "Try '${BASH_SOURCE[0]##*/} --help' for more information."
exit 1
fi
srepos=("${repo}")
fi
for arch in "${arches[@]}"; do
for repo in "${srepos[@]}"; do
local prefix=
(( VERBOSE && ${#srepos[@]} > 1 )) && prefix=${repo}/
db=${SOCACHE_DIR}/${arch}/${repo}/
if [[ -d ${db} ]]; then
while read -rd '' pkg; do
read -r match
pkg=${pkg#${db}}
pkg="${prefix}${pkg%-*-*/links}"
if (( VERBOSE )); then
printf '%-35s %s\n' "${pkg}" "${match}"
else
printf '%s\n' "${pkg}"
fi
done < <(grep -rZ "${lib}" "${db}") | sort -u
fi
done
done | resort
}
usage() {
cat <<- _EOF_
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] REPO LIBNAME
Check the soname links database for Arch Linux repositories containing
packages linked to a given shared library. If the repository specified
is "all", then all repositories will be searched, otherwise only the
named repository will be searched.
If the links database does not exist, it will be downloaded first.
OPTIONS
-v, --verbose Show matched links in addition to pkgname
-r, --refresh Refresh the links databases
-h, --help Show this help text
_EOF_
}
# utility function to resort with multiple repos + no-verbose
resort() { sort -u; }
if (( $# == 0 )); then
echo "error: No arguments passed."
echo "Try '${BASH_SOURCE[0]##*/} --help' for more information."
exit 1
fi
OPT_SHORT='vrh'
OPT_LONG=('verbose' 'refresh' 'help')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1
fi
set -- "${OPTRET[@]}"
while :; do
case $1 in
-v|--verbose)
resort() { cat; }
VERBOSE=1
;;
-r|--refresh)
REFRESH=1
;;
-h|--help)
usage
exit 0
;;
--)
shift; break
;;
esac
shift
done
if ! (( ( REFRESH && $# == 0 ) || $# == 2 )); then
echo "error: Incorrect number of arguments passed."
echo "Try '${BASH_SOURCE[0]##*/} --help' for more information."
exit 1
fi
if (( REFRESH )) || [[ ! -d ${SOCACHE_DIR} ]]; then
recache
(( $# == 2 )) || exit 0
fi
search "$@"

View File

@@ -1,4 +1,4 @@
#compdef archbuild archco arch-nspawn archrelease archrm commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco #compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
# License: Unspecified # License: Unspecified
m4_include(lib/valid-tags.sh) m4_include(lib/valid-tags.sh)
@@ -23,10 +23,6 @@ _archrelease_args=(
"*:arch:($_tags[*])" "*:arch:($_tags[*])"
) )
_archrm_args=(
'1:path:_files -/'
)
_commitpkg_args=( _commitpkg_args=(
"-a[Release to a specific architecture only]:arch:($_arch[*])" "-a[Release to a specific architecture only]:arch:($_arch[*])"
'-l[Set bandwidth limit]:limit' '-l[Set bandwidth limit]:limit'