Commit graph

577 commits

Author SHA1 Message Date
Hans-Christoph Steiner
3e1d313b7c mark manually sanitized input so bandit doesn't complain 2018-08-29 17:44:54 +02:00
Hans-Christoph Steiner
2edc68d6cd mark all required permissions so bandit doesn't complain 2018-08-29 17:44:54 +02:00
Hans-Christoph Steiner
5d77fd97ee use posixpath.join() for paths on the buildserver
This fixes bandit misdetection of hardcoded /tmp dir.  posixpath.join() is
good to use anyway, it highlights what is on the remote server, vs what is
local.  Local paths should use os.path.join() to support Windows, etc.
posixpath is built in since Python 3.4, maybe earlier
2018-08-29 17:24:04 +02:00
Areeb Jamal
7bdffde804 build: replace exclude with filter during source tar creation
Replace the deprecated exclude argument with filter in build.py
allowing users of Python 3.7 to use the fdroid CLI

Closes #531
2018-07-25 19:05:30 +05:30
Hans-Christoph Steiner
68fb3d2bd9 fix typos 2018-07-12 23:53:05 +02:00
Michael Pöhn
cdc2147de9 put .binary.apk files into sub-directory 2018-07-12 23:52:46 +02:00
Marcus Hoffmann
9889a98dea
build: improve gradle experience
This expands the gradle wrapper shell script used by the buildserver for
usage outside the buildserver environment. It also allows downloading
whitelisted versions of gradle if they are not yet deployed to the
buildserver by simply upsating the copy of fdroidserver (in contrast to
having to reprovision the whole buildserver).

We first move the buildserver/gradle shell script to the repo root
as gradlew-fdroid, as it's an fdroid specific gradle wrapper.
We also now sync it inside the build VM before each build.

We then add a list of whitelisted gradle distributions taken from the
makebuildserver script.

The script additionally now reads two env vars which tell it where to
expect installed versions of gradle and where it might store downloaded
gradle .zip files. Both of those are configurable from config.py. As the
first should normally just be a subdir of the second it's not exposed in
the example config.py but only used by the buildserver config.py.

Default config now uses this internal gradle wrapper but a path to a
custom wrapper or specific gradle distribution can still be set from
config.py.

Closes fdroid/fdroidserver#98
Ref: fdroid/fdroidserver#370
2018-07-11 11:49:46 +02:00
Marcus Hoffmann
a728582077
build: propagate --no-tarball option to buildserver
Closes #510
2018-07-09 14:48:59 +02:00
Hans-Christoph Steiner
d20e8613fe build: only test for all Android SDK paths where it is needed
Now that androguard can be used, the android-sdk is no longer required for
most operations.
2018-06-25 10:52:12 +02:00
Michael Pöhn
12af173821 fix left out refactoring in build.py 2018-06-23 23:26:42 +02:00
Michael Pöhn
88e64df3ef deploying build logs to server after each individual build run 2018-06-19 12:24:52 +02:00
Hans-Christoph Steiner
e6d5260c3c fix PEP8: W504 line break after binary operator 2018-05-29 12:31:56 +02:00
Torsten Grote
c6f3aed003
Fix reproducible builds
This commit fixes two bugs with reproducible builds:
* Files added by the buildserver to META-INF (fdroidserverid and buildserverid)
  were causing signature verification to always fail when --on-server was used.
  Since they are not needed anymore, they are no longer added to APKs.
* When showing a diff between both APK files, `jar xf` did not extract
  the full APK properly which was causing useless diffs.
  Instead of using jar, python's zipfile library is used instead.
2018-05-24 16:09:10 -03:00
Hans-Christoph Steiner
4ca77a4faf update: strip all whitespace from buildserverid 2018-03-22 23:19:54 +01:00
Hans-Christoph Steiner
70d9633555 build/checkupdates/update: log current fdroiddata commit to wiki 2018-03-05 21:49:09 +01:00
Hans-Christoph Steiner
52b3436ff6 make is_apk_and_debuggable() default to using androguard before aapt 2018-02-22 15:08:53 +01:00
Hans-Christoph Steiner
62db94d96e Merge branch 'build-36h' into 'master'
build: set overall timeout to 36 hours

See merge request fdroid/fdroidserver!460
2018-02-12 11:06:34 +00:00
relan
c0f323e343 build: set overall timeout to 36 hours
Currently f-droid.org has a lot of pending builds and big delays
between "fdroid build --all" runs. Bump overall build time limit from
12 hours to 36 hours to increase buildserver throughput.
2018-02-12 13:45:53 +03:00
Marcus Hoffmann
39a5637df2
build: clear timeout flag before every build
This fixes the weird logging behaviour where after a build that timed
out all subsequent failed builds would also show up as timed out.
2018-02-07 20:47:50 +01:00
csagan5
427427481e Change --resetserver to --reset-server for consistency 2018-01-30 20:45:03 +01:00
csagan5
cf54c9514c Option --resetserver does nothing; have it used instead 2018-01-30 14:50:35 +01:00
relan
86f34ee70a build: make per-build hard time limit customizable
Add "timeout=n" metadata field that overrides build timeout (in seconds).
The default is 7200, i.e. 2 hours.
2018-01-30 11:14:50 +03:00
Hans-Christoph Steiner
b851d49d24 shell=True is too dangerous to allow; there are unfiltered user inputs
There are all sorts of unfiltered user inputs like tag and branch names in
source repos.  If those names are fed into popen calls that use shell=True,
that opens up a wide range of exploits.  All core operations should never
use shell=True.
2018-01-26 10:18:41 +01:00
Hans-Christoph Steiner
513c95894c build: remove unused, unmaintained Kivy build method
This code has never been used and contains some insecure uses of shell=True
Building Kivy apps should be done with the buildozer=yes method.  The
buildozer method should probably be moved to a provisioner once that is in
place.
2018-01-23 23:16:05 +01:00
Marcus Hoffmann
fa43066f8d
build: add global soft timeout of 12 hours
Only start new builds for 12 hours. This ensures we publish new builds
often enough even on long backlogs.

This could be made configurable at a later point.
2018-01-22 16:02:49 +01:00
Marcus Hoffmann
80e121d182
build: log timeouts to the wiki 2018-01-22 16:02:49 +01:00
Marcus Hoffmann
85985074d4
build: enable watchdog timer for each build that kills in 2 hours
This introduces locking for the commonly used vagrant functions in
vmtools because vagrant fails when another vagrant command is
already running.
2018-01-22 16:01:20 +01:00
Marcus Hoffmann
9a4f3ac019
Revert "build: bump max_apps_per_run to 50"
This reverts commit 56a53055be.

Revert "build: limit --all to 10 apps at a time"

This reverts commit afc5cc6b6a.
2018-01-22 15:53:45 +01:00
Hans-Christoph Steiner
486ee25708 wiki: log build start/stop time, command line, RAM, and processor count 2018-01-22 14:00:16 +01:00
Hans-Christoph Steiner
e163c09e26 move get_android_tools_versions functions to common 2018-01-22 13:49:10 +01:00
Hans-Christoph Steiner
df51a6e999 common.get_wiki_timestamp() for posting timestamps to wiki log pages 2018-01-22 13:49:10 +01:00
Hans-Christoph Steiner
56a53055be build: bump max_apps_per_run to 50
With this at 10, it seems that there are often runs that produce no builds
at all.  That's bad.
2018-01-11 23:25:31 +01:00
Hans-Christoph Steiner
c4dbc58d10 build: buildserverid must always be str not bytes 2018-01-11 14:09:12 +01:00
Hans-Christoph Steiner
87524622ea build: fix str vs. bytes error in buildserverid
ERROR: Could not build app org.fdroid.fdroid due to unknown error: Traceback (most recent call last):
  File "/var/lib/jenkins/userContent/reproducible/reproducible_setup_fdroid_build_environment/fdroidserver/build.py", line 1202, in main
    options.onserver, options.refresh):
  File "/var/lib/jenkins/userContent/reproducible/reproducible_setup_fdroid_build_environment/fdroidserver/build.py", line 972, in trybuild
    build_server(app, build, vcs, build_dir, output_dir, log_dir, force)
  File "/var/lib/jenkins/userContent/reproducible/reproducible_setup_fdroid_build_environment/fdroidserver/build.py", line 82, in build_server
    logging.debug(_('Fetched buildserverid from VM: ') + buildserverid)
TypeError: Can't convert 'bytes' object to str implicitly
2018-01-11 12:50:18 +01:00
relan
e29be52da0 build: clean up only known subdirectories in build/*
We remove the whole "build" directory while cleaning source code tree
because Gradle can leave there files even after "gradle clean". But some
projects (Mozilla Fennec) actually have useful stuff checked into VCS
under the "build" directory.

Remove only those subdirectories that we known for sure are leftovers
from Gradle.

Fixes fdroid/fdroidserver#438.
2018-01-10 21:45:26 +03:00
Hans-Christoph Steiner
54965455b1 build: include buildserverid on wiki build logs, if it exists
When `fdroid build` is run using the buildserver, it should fetch the
buildserverid on the first build.

Seems this was really a silly bug in 837fc99d74
2018-01-03 13:58:06 +01:00
Hans-Christoph Steiner
444ae95380 build: log the start time of the current build session
Since `fdroid build --all` can run a long time, knowing when that command
was started will be very useful information for figuring out what the build
server is doing.
2018-01-03 12:29:29 +01:00
Marcus Hoffmann
e775d330c2
build: fix --no-refresh
This was broken by the in-source-tree .fdroid.yml file support.
Also support this for building on the buildserver.
2017-12-26 00:20:17 +01:00
Hans-Christoph Steiner
afc5cc6b6a build: limit --all to 10 apps at a time
This needed now because the buildserver is hanging so often, that we are
often going a week or more without any builds published.  Perhaps this is
only temporary, or maybe we will want to flush this feature out more as a
standard thing.  But we really need it for now to at least get some builds
out on a daily basis.

Since the website deploy is also triggered by this cycle, making the build
finish more often means the website will be published more often.
2017-12-21 23:15:34 +01:00
Hans-Christoph Steiner
9087ec76f3 build: use dpkg to purge sudo, for less spammy debug logs
apt is quite verbose:
DEBUG: buildserver > DEBUG: > sudo SUDO_FORCE_REMOVE=yes apt-get -y purge sudo
DEBUG: buildserver > Reading package lists...

DEBUG: buildserver > Building dependency tree...
DEBUG: buildserver > Reading state information...
DEBUG: buildserver > The following package was automatically installed and is no longer required:
DEBUG: buildserver >   libasprintf0c2
DEBUG: buildserver > Use 'apt-get autoremove' to remove it.
DEBUG: buildserver > The following packages will be REMOVED:
DEBUG: buildserver >   sudo*

DEBUG: buildserver > 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
DEBUG: buildserver > After this operation, 2,391 kB disk space will be freed.
DEBUG: buildserver > (Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 73055 files and directories currently installed.)
DEBUG: buildserver > Removing sudo (1.8.10p3-1+deb8u5) ...
DEBUG: buildserver > Purging configuration files for sudo (1.8.10p3-1+deb8u5) ...
DEBUG: buildserver > Processing triggers for man-db (2.7.0.2-5) ...
2017-12-20 23:46:37 +01:00
Hans-Christoph Steiner
2e531af58f build: force purging of sudo, ignore error message
Fixes bb758d3f, spotted by @bubu:
DEBUG: buildserver > DEBUG: > sudo apt-get -y purge sudo
DEBUG: buildserver > Reading package lists...
DEBUG: buildserver > Building dependency tree...
DEBUG: buildserver > Reading state information...
DEBUG: buildserver > The following packages will be REMOVED:
DEBUG: buildserver >   sudo*
DEBUG: buildserver > 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
DEBUG: buildserver > After this operation, 2,391 kB disk space will be freed.
(Reading database ... 68491 files and directories currently installed.)
DEBUG: buildserver > Removing sudo (1.8.10p3-1+deb8u4) ...
DEBUG: buildserver > You have asked that the sudo package be removed,
DEBUG: buildserver > but no root password has been set.
DEBUG: buildserver > Without sudo, you may not be able to gain administrative privileges.
DEBUG: buildserver >
DEBUG: buildserver > If you would prefer to access the root account with su(1)
DEBUG: buildserver > or by logging in directly,
DEBUG: buildserver > you must set a root password with "sudo passwd".
DEBUG: buildserver >
DEBUG: buildserver > If you have arranged other means to access the root account,
DEBUG: buildserver > and you are sure this is what you want,
DEBUG: buildserver > you may bypass this check by setting an environment variable
DEBUG: buildserver > (export SUDO_FORCE_REMOVE=yes).
DEBUG: buildserver >
DEBUG: buildserver > Refusing to remove sudo.
DEBUG: buildserver > dpkg: error processing package sudo (--purge):
DEBUG: buildserver >  subprocess installed pre-removal script returned error exit status 1
DEBUG: buildserver > Errors were encountered while processing:
DEBUG: buildserver >  sudo
DEBUG: buildserver > E: Sub-process /usr/bin/dpkg returned an error code (1)
2017-12-14 16:57:22 +01:00
Hans-Christoph Steiner
bb758d3f00 build: apt-get purge sudo after using it for sudo= build field
Once `sudo` has been used to execute the commands in sudo=, then it should
be removed from the build VM.  That prevents any other part of the build
from using sudo.  That means that all commands run with `sudo` must be
committed to fdroiddata.git, making them very visible.

closes #424
2017-12-11 22:11:16 +01:00
Hans-Christoph Steiner
964ef996a0 makebuildserver: make copy_caches_from_host do rsync like fdroid build
This rsync hung because of an SSH unknown key prompt.  Since this is just
the vm host sshing to the vm guest, it is not essential to check the host
keys.
2017-12-06 20:20:17 +01:00
Marcus Hoffmann
1bfba12124 build: write out full rsync options
Also put target host:dir on one line to make it more readable
2017-12-05 21:52:22 +01:00
Marcus Hoffmann
e12e1b6a5c build: better logging output on rsync failures
Save rsync error output and combine that with the command invocation
into an FDroidException which can be logged to the wiki.

This additionally sets -q for rsync to only print errors.
2017-12-05 21:52:11 +01:00
relan
24e1da1e91 Merge branch 'log_git' into 'master'
build: log vcs tools version on every build attempt

See merge request fdroid/fdroidserver!391
2017-12-03 06:03:03 +00:00
Marcus Hoffmann
bb591e236d build: log vcs tools version on every build attempt 2017-12-02 22:41:08 +01:00
Hans-Christoph Steiner
b8ed892ad9 build: hard exit on success to avoid hanging
Something is preventing `fdroid build --all` from exiting after a long
run.  @bubu, @uniqx and I think it is because of the use of
AsynchronousFileReader, somehow it's thread does not exit. So the
workaround for now is to just try a hard exit instead of waiting for
things to finish cleanly with `sys.exit(0)`.

https://jenkins.debian.net/job/reproducible_fdroid_build_apps/94/console
2017-12-02 13:48:47 +01:00
Hans-Christoph Steiner
30b2f5a48a build: sort fdroid build --all by most recently changed first 2017-11-30 17:32:53 +01:00
Hans-Christoph Steiner
2b6825ccfd build: set open file limit based on how many apps are being processed
When running `fdroid build --all` on a buildserver with thousands of apps,
it was frequently hitting the open file limit.  This increases the open
file limit based on how many apps are being process.  It is doubled to
provide a margin of safety.

There are probably open file leaks which ideally would be fixed, but this
is also useful to make things more resilient to all the random stuff apps
include in their build systems.
2017-11-29 21:06:02 +01:00