Commit graph

577 commits

Author SHA1 Message Date
linsui
7a98650ed3 Sort import
ruff check --fix --select I
2025-07-26 15:35:19 +00:00
Hans-Christoph Steiner
5049645003 make gradlew-fdroid a standalone project
https://gitlab.com/fdroid/gradlew-fdroid
2025-07-25 17:46:31 +00:00
linsui
6c054f62ca flavour -> flavor 2025-05-22 12:16:43 +02:00
Hans-Christoph Steiner
20b36f1970 SOURCE_DATE_EPOCH from app's git otherwise fdroiddata metadata file
https://reproducible-builds.org/docs/source-date-epoch
2025-05-19 16:31:40 +02:00
Hans-Christoph Steiner
4e7bda736c update: never execute VCS e.g. git
Package repos come from untrusted sources, in terms of the buildserver. They
should be handled in VMs and containers as much as possible to avoid
vulnerabilities.  As far as I could tell, `fdroid update` only has a single
place where it executes any VCS system: if there is .fdroid.yml present in
a package repo, then it will fetch the commit ID using git.

For better security properties, this implements a simple function to just
read the files to get that commit ID.  The function that executes git to do
the same thing is relabeled "unsafe".  That is used for status JSON
everywhere, but that runs on fdroiddata.git and fdroidserver.git, which are
trusted repos.

The unsafe version is also used in places where git.Repo() is needed for
other things.
2025-05-12 18:30:03 +02:00
Hans-Christoph Steiner
56814824ee new function get_src_tarball_name; deprecates getsrcname
Some places in the code that need this, like verify.py, do not have
app and build instances, but do have appid and versionCode.  And
fdroidserver/build.py is going away.
2024-12-11 11:39:02 +00:00
Jochen Sprickerhof
8ab1d53318
Read only metadata of apps given on the command line 2024-10-06 10:25:19 +02:00
g0t mi1k
19aef075b4 Drop --reset-server 2024-08-15 15:44:59 +00:00
Hans-Christoph Steiner
18f3acc32e split out options from read_config()
There is no longer any reason for these to be intertwined.

This deliberately avoids touching some files as much as possible because
they are super tangled and due to be replaced.  Those files are:

* fdroidserver/build.py
* fdroidserver/update.py

# Conflicts:
#	tests/testcommon.py

# Conflicts:
#	fdroidserver/btlog.py
#	fdroidserver/import_subcommand.py
2024-05-08 16:26:46 +02:00
Gregor Düster
df27405d8b [build] Add more docstrings 2024-05-08 15:35:28 +02:00
Hans-Christoph Steiner
9c65bed4a5 check for <application android:testOnly="true">
This adds a check for "testOnly" to the existing "debuggable" check, since
they are very similar.  We should really be refactoring all the checks into
a more reasonable setup.  Since "debuggable" and "testOnly" are both set in
the same place (`<application>` in _AndroidManifest.xml_) and are both set
by the same process (running debug builds), I thought it would be OK to
include both in the same place.  Plus it was a one-line change.
2024-04-03 13:47:04 +00:00
Hans-Christoph Steiner
04cedd1808 build: pass --refresh-scanner thru to buildserver VM 2024-02-16 11:43:42 +01:00
linsui
6fb2e07dda fdroid build: add --refresh-scanner option
Apply 1 suggestion(s) to 1 file(s)
2024-01-25 14:03:12 +01:00
Hans-Christoph Steiner
2d5770985f gitlab-ci: silence irrelevant bandit error
This SSH connection is only ever to the Vagrant VM on the same machine.

>> Issue: [B507:ssh_no_host_key_verification] Paramiko call with policy set to automatically trust the unknown host key.
   Severity: High   Confidence: Medium
   CWE: CWE-295 (https://cwe.mitre.org/data/definitions/295.html)
   More Info: https://bandit.readthedocs.io/en/1.7.6/plugins/b507_ssh_no_host_key_verification.html
   Location: ./fdroidserver/build.py:104:8
103	        sshs = paramiko.SSHClient()
104	        sshs.set_missing_host_key_policy(paramiko.AutoAddPolicy())
105	        sshs.connect(sshinfo['hostname'], username=sshinfo['user'],
2023-12-15 08:40:27 +01:00
cvzi
af1c5d4e5d Fix typo in build.py
encoutered -> encountered
2023-10-10 12:14:20 +00:00
Jochen Sprickerhof
49c415424d
Ignore encoding errors in logs
Found while compiling io.privatestorage.privatestoragemobile_9:

Traceback (most recent call last):
  File "/home/fdroid/fdroidserver/fdroidserver/build.py", line 1053, in main
    if trybuild(app, build, build_dir, output_dir, log_dir,
  File "/home/fdroid/fdroidserver/fdroidserver/build.py", line 813, in trybuild
    build_server(app, build, vcs, build_dir, output_dir, log_dir, force)
  File "/home/fdroid/fdroidserver/fdroidserver/build.py", line 253, in build_server
    logging.debug("buildserver > " + str(line, 'utf-8').rstrip())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 8: invalid start byte
2023-09-27 17:41:26 +02:00
Hans-Christoph Steiner
1e4e2489aa
add keep_when_not_allowed config/option 2023-05-05 09:49:32 +02:00
Jason A. Donenfeld
26472c22ce build: check AllowedAPKSigningKeys in reproducible build scenario
The builder should check the `AllowedAPKSigningKeys` at build time, so
that the CI can check if somebody gives a wrong value that doesn't match
a compared RB binary.  In the event it fails, it gives useful
information, and in the event it succeeds, it makes it clear that this
build has verification back to the developer's original key.

Also, add tests for this to the test suite.
2023-05-05 06:14:31 +00:00
Hans-Christoph Steiner
b92e280eab fix code format for new black rule 2023-03-20 14:47:48 +01:00
FestplattenSchnitzel
2dda9db1f1
Remove support for Buildozer 2023-03-09 12:03:57 +01:00
Jochen Sprickerhof
fef42dbc87
build: support PosixPath in log message (Closes: #1096) 2023-02-16 14:29:31 +01:00
linsui
58f167b7e5 Add build.binary 2023-02-16 20:16:52 +08:00
linsui
33def096f5 Add postbuild 2023-02-16 12:11:26 +00:00
Jochen Sprickerhof
a6700e65ed build: close ssh_channel upon timeout
The build can get stuck when running into the timeout and paramiko not
noticing it. This can be reproduced by setting a small build timeout for
an app. I tried setting set_keepalive() but it did not help. This
forcefully closes the ssh channel to the VM so the fdroid build will
continue. As we destroy the VM in the next step anyhow I think this is
fine.
2023-02-04 10:14:03 +00:00
Jochen Sprickerhof
5e08187567 build: Rename chan to ssh_channel 2023-02-04 10:14:03 +00:00
Jochen Sprickerhof
f8e3356365
Distroy VM when running into timeout (Closes: #1094)
halt results in an Traceback.
2023-02-02 10:03:34 +01:00
Jochen Sprickerhof
3eea5f7c09 Don't get_android_tools_version_log for non builds 2022-11-16 10:56:27 +00:00
Jochen Sprickerhof
2cbb5576c7 Drop VCS version check on every build
This was introduced in
https://gitlab.com/fdroid/fdroidserver/-/merge_requests/391

I don't think it is needed anymore.

Also log appid:versionCode
2022-11-16 10:56:27 +00:00
Jochen Sprickerhof
e0fa38bab3 status.json: drop logs of failed builds
Those are uploaded separately.
2022-11-15 08:12:51 +00:00
Hans-Christoph Steiner
bd51b2e99f build: read VM CPUs/RAM from builder/Vagrantfile
makebuildserver.config.py is no more, builder/Vagrantfile is now where the
CPU and memory is configured for the buildserver VM.  In fact, that was
always the actual place, the makebuildserver.config.py thing was just
confused.

This should have been part of !1222
2022-11-15 08:57:41 +01:00
Jochen Sprickerhof
b73c4b9214 Drop successfulBuilds from build.json
This should reduce the file size from 34MB to 1MB and it is not used by
the monitor.
2022-11-07 07:30:45 +00:00
Jochen Sprickerhof
557fe87d44 Run shell scripts with -e (Closes: #1035)
Make sudo, init prebuild, build and Prepare fields lists and only
concatenate them with '; ' before execution. This allows arbitrary
commands inside the fileds (even && and ';') as we don't need to split
the commands again for rewritemeta.
2022-11-03 12:25:31 +00:00
linsui
5a28f20301 make versionCode/build.timeout an integer
Co-authored-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
2022-10-14 08:42:26 +00:00
Jochen Sprickerhof
9c0d50a9b2 Sync status json after every build
dfdd2913 the logic to only write the status json upon build but before
the build happens. This makes sure that it is written after a
successful build or exception.
2022-10-13 11:20:15 +00:00
Jochen Sprickerhof
dfdd29131f
Write build/running.json only on build
This should reduce the runtime.

Also test if it was written.
2022-10-12 15:25:17 +02:00
Michael Pöhn
a8bcaa3d70 scanner: implement caching rules for suss 2022-10-06 12:09:06 +02:00
proletarius101
8267fb2caf stop checking existence for build-tools, platform-tools, tools 2022-08-17 07:59:36 +00:00
Jochen Sprickerhof
edc9390628 Pass --scan-binary to build server 2022-06-03 14:27:58 +00:00
Jochen Sprickerhof
4ce79a7eaa explicitly re-raising exceptions
To fix pylint.
2022-06-01 22:52:22 +02:00
Jochen Sprickerhof
a872d8688d Fix pylint warnings 2022-03-29 15:53:45 +02:00
Jochen Sprickerhof
36a7847525 Suppress --wiki in fdroid build
This was already done for fdroid update in 00c2cc969.
2021-11-24 18:16:07 +01:00
Jochen Sprickerhof
32d2330bb5 Always write VM status
Before this the status.json only contained VM information with
fdroid build --wiki --server, after this a fdroid build --server is
enough.
2021-11-24 18:16:07 +01:00
Jochen Sprickerhof
b6f1f4231a Drop code for the old wiki 2021-11-24 18:16:07 +01:00
Felix C. Stegerman
53ff7de445 build: run vcs.initsubmodules() on host as well
otherwise, e.g. triple-t metadata in a submodule will not be available
on the host and thus not be used at all
2021-09-11 15:31:27 +00:00
Jochen Sprickerhof
2b41dffcb2 Provide verbose output with --verbose
23b0b6bc added logging in case of an FDroidException on the build
server. This broke the log of apps that fail to build.

Prior to 23b0b6bc a failing build in the VM triggered a BuildException
on the server side but the build output was written to the log in the
finally part of build_server(). After 23b0b6bc the finally part writs
the build as well but the BuildException is caught in main() and the
build log is overwritten with the empty exception content. This patch
always adds the build log to the exception so it is written to the log.

Closes: #882
2021-09-10 14:10:46 +02:00
Jochen Sprickerhof
72df2639a2 Log traceback with exception 2021-08-27 13:29:07 +02:00
Jochen Sprickerhof
23b0b6bcaf Deploy build error log in case of an exception
This happened with us.spotco.fennec_dos_2912000 where no build log was
saved in the repo but the wiki has an error text. The error text was:

"Command '['rsync', '--recursive', '--perms', '--links', '--quiet', '--rsh=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=FATAL -o IdentitiesOnly=yes -o PasswordAuthentication=no -p 2222 -i /home/fbuild/.vagrant.d/boxes/buildserver/0/virtualbox/vagrant_private_key', 'build/srclib/MozFennec', 'vagrant@127.0.0.1:/home/vagrant/build/srclib']' returned non-zero exit status 255."

Which is generated by the rsync subprocess call in build_server(). I
assume that it threw an Exception (not an FdroidException, because the
string "Build completed at" is not in the wiki site) that was caught in
main().
2021-08-27 08:05:28 +02:00
Benedikt Brückmann
01b9fb1549 Fix pep8 whitespace errors 2021-06-25 06:28:47 +02:00
Benedikt Brückmann
1e943a22df rewrite docstrings to match numpy style guide 2021-06-25 06:28:47 +02:00
Benedikt Brückmann
d168b9c05b rewrite docstrings to match numpy style guide 2021-06-25 06:28:43 +02:00