Skip to content

Commit e003ef1

Browse files
committed
chore: substitute jq with python entirely
1 parent c2fae13 commit e003ef1

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ USER root
1616
# Create dirs and copy scripts
1717
RUN mkdir --parents "${SCRIPT_DIR}"
1818
COPY scripts/ "${SCRIPT_DIR}"/
19+
COPY py-utils/ "${BIN_DIR}"/
1920

2021
# Set up user and work directories
2122
RUN chown --recursive "${userid}":"${groupid}" "${ROOT_DIR}" && chmod --recursive ug+srw "${ROOT_DIR}"

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## ToDo
22
- multi-line remotes/repos in local manifests do not work for more than one manifest
33
- automatic repo pulling for officially supported lineage devices
4-
- move json and xml handling to python
4+
- move xml handling to python

base/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninte
5555
libreadline-dev \
5656
# Automation
5757
file \
58-
jq \
5958
unzip
6059

6160
RUN rm --recursive /var/lib/apt/lists /var/cache/apt/archives

py-utils/json_arg_parser.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/python3
2+
3+
import json
4+
import sys
5+
6+
7+
def main():
8+
try:
9+
json_target = json.loads(str(sys.stdin.read()))
10+
search_target = str(sys.argv[1])
11+
except TypeError:
12+
print("Invalid arguments")
13+
sys.exit(1)
14+
15+
try:
16+
print(json_target[search_target])
17+
except KeyError:
18+
print("Argument not found")
19+
sys.exit(1)
20+
21+
22+
if __name__ == '__main__':
23+
main()

scripts/compat.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _setup_jdk8() {
2525
--header 'Accept: application/vnd.github+json' \
2626
--header 'X-GitHub-Api-Version: 2022-11-28' \
2727
https://api.github.com/repos/adoptium/temurin8-binaries/releases/latest \
28-
| jq .tag_name)
28+
| tr -d '\n' | json_arg_parser.py "tag_name")
2929
jdk_name=OpenJDK8U-jdk_x64_linux_hotspot_$(tr -d '-' <<< "${jdk_tag//jdk/}").tar.gz
3030
mkdir --parents "${jdk_dir}"
3131
curl_cmd --remote-name https://github.com/adoptium/temurin8-binaries/releases/download/"${jdk_tag}"/"${jdk_name}" --output-dir "${jdk_dir}"

scripts/upload.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _upload_gh() {
3636
--header 'content-type: application/json' \
3737
https://api.github.com/repos/"${release_repo}"/releases \
3838
--data "{ \"tag_name\": \"${tag}\", \"body\": \"${desc}\" }" \
39-
| jq -r .upload_url \
39+
| tr -d '\n' | json_arg_parser.py "upload_url" \
4040
| cut -d'{' -f1)
4141

4242
# Upload ROM
@@ -47,7 +47,7 @@ _upload_gh() {
4747
--header "Content-Type: $(file -b --mime-type "${OUT}"/"${PACKAGE_NAME}")" \
4848
--upload-file "${OUT}"/"${PACKAGE_NAME}" \
4949
"${upload_url}"?name="${PACKAGE_NAME}" \
50-
| jq -r .browser_download_url)
50+
| tr -d '\n' | json_arg_parser.py "browser_download_url")
5151

5252
# Upload Recovery
5353
curl_cmd \

0 commit comments

Comments
 (0)