1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-15 19:30:31 +01:00
Commit Graph

8641 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
0393e46af9 metadata: handle TYPE_STRINGMAP when writing out YAML 2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
e8ab84b583 metadata: simplify _app_to_yaml()
There are some redundant checks and odd construct:
* cm.update({a: b}) --> cm[a] = b
* getattr(app, field) --> app.get(field)
2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
2cb12f9594 metadata: break out write_yaml to standalone function and add unit tests 2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
784bebfee9 metadata: keep manually added NoSourceSince in AntiFeatures
If the metadata file contains NoSourceSince:, it is added to the collection
of Anti-Features.  When rewriting the .yml file, NoSourceSince should only
be written into the AntiFeatures: collection if there are manual changes,
e.g. the user had provided translations.
2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
7c1d7fb4b3 metadata: check error messages are printed for more cases 2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
b2fc59ef9a gitlab-ci: bump version to compare in metadata_v0 job
The previous commit changes the internal representation of
antiFeatures from a list to dict.
https://gitlab.com/eighthave/fdroidserver/-/jobs/4260622978
2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
061ca38afd define "string map" type for new Anti-Features explanations
closes #683
2023-05-23 10:47:03 +02:00
Hans-Christoph Steiner
6e62ea3614 Merge branch 'scanner-allow-non-zero-exit' into 'master'
feat(scanner): Allow non-zero-exit code if problems were found

See merge request fdroid/fdroidserver!1342
2023-05-23 08:35:18 +00:00
Georg krause
9af2efda2e feat(scanner): Allow non-zero-exit code if problems were found 2023-05-23 09:54:24 +02:00
Hans-Christoph Steiner
44513c23fd Merge branch 'readme-and-contributing' into 'master'
update README and add CONTRIBUTING.md

See merge request fdroid/fdroidserver!1353
2023-05-22 14:16:43 +00:00
Hans-Christoph Steiner
a08d4a74e8 update CONTRIBUTING.md 2023-05-22 14:16:31 +00:00
Hans-Christoph Steiner
a02ed98c7e update README to fix out of date things 2023-05-22 14:16:31 +00:00
Hans-Christoph Steiner
84b45abb03 Merge branch 'last-prop' into 'master'
gradlew-fdroid: use last duplicate key like java.util.Properties

Closes #1131

See merge request fdroid/fdroidserver!1356
2023-05-22 11:35:54 +00:00
FC Stegerman
f160ae55cb
gradlew-fdroid: use last duplicate key like java.util.Properties 2023-05-19 18:12:23 +02:00
Michael Pöhn
a9b2f624e5 Merge branch 'scanner_dataclass' into 'master'
scanner: replace global dict by dataclass

See merge request fdroid/fdroidserver!1208
2023-05-12 17:58:26 +00:00
Jochen Sprickerhof
2488cb5710 scanner: replace global dict by dataclass 2023-05-12 17:58:04 +00:00
Jochen Sprickerhof
52e798575b Merge branch 'fix_mkdir' into 'master'
Create repo/icons without failure

See merge request fdroid/fdroidserver!1355
2023-05-12 07:25:53 +00:00
Jochen Sprickerhof
5723a1dafe
Create repo/icons without failure
Fixes fdroid lint CI.
2023-05-12 09:12:28 +02:00
Michael Pöhn
1b765d11e7 Merge branch 'lint-AntiFeatures-from-config' into 'master'
lint: Anti-Features validator uses names from config / plus tests, cleanups, and minor bugfixes

See merge request fdroid/fdroidserver!1352
2023-05-11 14:20:15 +00:00
Hans-Christoph Steiner
af5b067396 gitlab-ci: bump version to compare in metadata_v0 job
The relevant change comes from !1332
2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
024d309262 index: rename app var to app_dict, its not an App instance
Throughout the code, variables named "app" are instances of the App class.
In this case, this is related, but it is a dict not an App instance, since
it is being prepared for including in the index-v1.json.
2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
8bc9a3da73 test_parse_yaml_metadata_continue_on_warning checks logging calls 2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
86b643f87b metadata: test to check that metadata/*.yml overrides .fdroid.yml
This actually uncovered that .fdroid.yml isn't really working. But that is
a problem for another day.
2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
bb99986630 metadata: fix crash if .fdroid.yml but its not a git repo 2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
c2bc52dd85 use constant for default locale 2023-05-11 10:37:45 +02:00
Hans-Christoph Steiner
d5a1439457 lint: Anti-Features validator uses names from config 2023-05-11 10:29:04 +02:00
Hans-Christoph Steiner
d6dba05ec3 test load_localized_locale() and translated Anti-Features 2023-05-10 13:34:09 +02:00
Hans-Christoph Steiner
b04c7ff539 load_localized_config() returns a dict in a stable order
I renamed the variables while I was at it, to make it clearer.
2023-05-10 13:17:40 +02:00
Hans-Christoph Steiner
74a23284e1 common: load_localized_config() should make repo/ if not present
For 1,000,000 checks, this adds:
* ~4 seconds of runtime on a server with very slow disks.
* ~0.7 seconds of runtime on my laptop with a fast SSD.
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
49362b5fd1 move load_locale() and file_entry() to be accessible by all modules
* load_locale -> common.load_localized_config() since common handles config
* file_entry -> metadata.file_entry() since metadata handles data format
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
f9864dc3a2 rewritemeta: split into remove_blank_flags_from_builds()
This takes this key bit of functionality, splits it out as its own
function, and adds some unit tests.
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
8ccc89ad4e index: fix requestsdict check order of operations
If requestsdict is None, the old logic would still check
requestsdict["uninstall"]) and crash there.
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
3efe797bf8 gitlab-ci: CI_BUILD_* vars were renamed to other things
https://web.archive.org/web/20190110134948/https://docs.gitlab.com/ee/ci/variables/#gitlab-90-renaming

Looks like GitLab v16 is finally removing the old names.

sed -i \
  -e s,CI_BUILD_TOKEN,CI_JOB_TOKEN,g \
  -e s,CI_BUILD_REF_SLUG,CI_COMMIT_REF_SLUG,g \
  -e s,CI_BUILD_REF_NAME,CI_COMMIT_REF_NAME,g \
  -e s,CI_BUILD_REPO,CI_REPOSITORY_URL,g \
  .gitlab-ci.yml
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
f7830a41f1 deploy: ensure mirrors and binary transparency always create 'master'
If there was a global default on a machine that was something other than
'master', these things would crash with:

Traceback (most recent call last):
  File "/home/hans/code/fdroid/server/fdroid", line 22, in <module>
    fdroidserver.__main__.main()
  File "/home/hans/code/fdroid/server/fdroidserver/__main__.py", line 230, in main
    raise e
  File "/home/hans/code/fdroid/server/fdroidserver/__main__.py", line 211, in main
    mod.main()
  File "/home/hans/code/fdroid/server/fdroidserver/deploy.py", line 833, in main
    push_binary_transparency(BINARY_TRANSPARENCY_DIR,
  File "/home/hans/code/fdroid/server/fdroidserver/deploy.py", line 705, in push_binary_transparency
    local.pull('master')
  File "/usr/lib/python3/dist-packages/git/remote.py", line 1045, in pull
    res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/git/remote.py", line 848, in _get_fetch_info_from_stderr
    proc.wait(stderr=stderr_text)
  File "/usr/lib/python3/dist-packages/git/cmd.py", line 604, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git pull -v -- local master
  stderr: 'fatal: couldn't find remote ref master'
2023-05-10 09:21:14 +02:00
Hans-Christoph Steiner
0735bfa7e5 remove obsolete test case 2023-05-09 20:45:16 +02:00
Hans-Christoph Steiner
0124b9dde9 Merge branch 'cert-pin' into 'master'
`AllowedAPKSigningKeys` cleanups

See merge request fdroid/fdroidserver!1343
2023-05-05 08:47:02 +00:00
Hans-Christoph Steiner
43b278b9d6
build: fix loading config files in tests
The new test case works with the default config.
2023-05-05 09:49:34 +02:00
Hans-Christoph Steiner
1e4e2489aa
add keep_when_not_allowed config/option 2023-05-05 09:49:32 +02:00
Hans-Christoph Steiner
386fb55b99
keep old test case intact 2023-05-05 09:49:27 +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
Jason A. Donenfeld
8a0b7e5b1b lint: binary or Binaries requires AllowedAPKSigningKeys
Per fdroiddata!12911 the linter should error out if somebody uses `binary` or
`Binaries` without supplying an `AllowedAPKSigningKeys`.

There are two reasons for this:

- Security: this allows full verification that the binaries built match
  the developers, not just what happened to get uploaded onto github at
  some later point in time.

- Reliable updates: if the signing key changes, users won't be able to
  update, so this is something we should learn about when upstreams send
  in commits changing their signing key, rather than just leaving it to
  chance.
2023-05-05 06:14:31 +00:00
Hans-Christoph Steiner
41104e217b Merge branch 'consistent-linting-formatting' into 'master'
make linting and formatting rules consistent

See merge request fdroid/fdroidserver!1160
2023-05-04 14:12:09 +00:00
proletarius101
4b898287e9 make linting and formatting rules consistent 2023-05-04 14:12:08 +00:00
Michael Pöhn
acc774f91e Merge branch 'clean-up-metadata' into 'master'
collection of cleanups, tests and minor refactoring related to metadata

See merge request fdroid/fdroidserver!1351
2023-05-04 12:55:38 +00:00
Hans-Christoph Steiner
f871df502d metadata: minor optimization: call fieldtype() once per loop
I profiled this with timeit and a dict with 1000000000 items, and this is
the time difference:

with_equals:		0.8466835720173549
with_is:		0.8536969239939936
with_old:		1.4458542719949037

I also compared using `==` and `is`, and `==` was slightly faster.
2023-05-02 13:53:53 +02:00
Hans-Christoph Steiner
9a9705a667 update test_read_metadata to use ruamel.yaml and YAML 1.2
I tried to get this to indent the .yaml files properly so yamllint defaults
work with tests/metadata/dump/*.yaml, but it didn't take for some reason:

    yaml.indent(mapping=4, sequence=4, offset=2)
2023-05-02 13:52:38 +02:00
Hans-Christoph Steiner
28ea6cea7f add tests of TYPE_LIST parsing 2023-05-02 13:52:06 +02:00
Hans-Christoph Steiner
0b3fd725c3 metadata.TestCase: metadata.warnings_action = 'error' as default
The default state for the tests should be to fail on errors.
2023-05-02 13:51:44 +02:00
Hans-Christoph Steiner
822439dff5 remove exception for ruamel.yaml on Debian/stretch
stretch is no more, and this code base specifies Python 3.9 as minimum.
2023-05-02 13:50:54 +02:00
Hans-Christoph Steiner
74dddfd9fb refactor App.get_last_build() to checkupdates
This function is only used in checkupdates, and removing it from the App
class moves the App class one step closer to being a plain dict, which is a
more Pythonic style.
2023-05-02 13:50:31 +02:00