forked from Mirror/pmbootstrap
pmb.aportgen: convert to f-strings (MR 1924)
Finally it's readable again!
This commit is contained in:
parent
2f018c44ef
commit
2ca09cd21c
2 changed files with 48 additions and 46 deletions
|
@ -105,17 +105,17 @@ def generate_deviceinfo_fastboot_content(args, bootimg=None):
|
|||
"second_offset": "",
|
||||
"tags_offset": "",
|
||||
"pagesize": "2048"}
|
||||
return """\
|
||||
deviceinfo_kernel_cmdline=\"""" + bootimg["cmdline"] + """\"
|
||||
return f"""\
|
||||
deviceinfo_kernel_cmdline="{bootimg["cmdline"]}"
|
||||
deviceinfo_generate_bootimg="true"
|
||||
deviceinfo_bootimg_qcdt=\"""" + bootimg["qcdt"] + """\"
|
||||
deviceinfo_bootimg_dtb_second=\"""" + bootimg["dtb_second"] + """\"
|
||||
deviceinfo_flash_offset_base=\"""" + bootimg["base"] + """\"
|
||||
deviceinfo_flash_offset_kernel=\"""" + bootimg["kernel_offset"] + """\"
|
||||
deviceinfo_flash_offset_ramdisk=\"""" + bootimg["ramdisk_offset"] + """\"
|
||||
deviceinfo_flash_offset_second=\"""" + bootimg["second_offset"] + """\"
|
||||
deviceinfo_flash_offset_tags=\"""" + bootimg["tags_offset"] + """\"
|
||||
deviceinfo_flash_pagesize=\"""" + bootimg["pagesize"] + """\"
|
||||
deviceinfo_bootimg_qcdt="{bootimg["qcdt"]}"
|
||||
deviceinfo_bootimg_dtb_second="{bootimg["dtb_second"]}"
|
||||
deviceinfo_flash_offset_base="{bootimg["base"]}"
|
||||
deviceinfo_flash_offset_kernel="{bootimg["kernel_offset"]}"
|
||||
deviceinfo_flash_offset_ramdisk="{bootimg["ramdisk_offset"]}"
|
||||
deviceinfo_flash_offset_second="{bootimg["second_offset"]}"
|
||||
deviceinfo_flash_offset_tags="{bootimg["tags_offset"]}"
|
||||
deviceinfo_flash_pagesize="{bootimg["pagesize"]}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -124,27 +124,27 @@ def generate_deviceinfo(args, pkgname, name, manufacturer, year, arch,
|
|||
flash_method, bootimg=None):
|
||||
codename = "-".join(pkgname.split("-")[1:])
|
||||
# Note: New variables must be added to pmb/config/__init__.py as well
|
||||
content = """\
|
||||
content = f"""\
|
||||
# Reference: <https://postmarketos.org/deviceinfo>
|
||||
# Please use double quotes only. You can source this file in shell scripts.
|
||||
|
||||
deviceinfo_format_version="0"
|
||||
deviceinfo_name=\"""" + name + """\"
|
||||
deviceinfo_manufacturer=\"""" + manufacturer + """\"
|
||||
deviceinfo_codename=\"""" + codename + """\"
|
||||
deviceinfo_year=\"""" + year + """\"
|
||||
deviceinfo_name="{name}"
|
||||
deviceinfo_manufacturer="{manufacturer}"
|
||||
deviceinfo_codename="{codename}"
|
||||
deviceinfo_year="{year}"
|
||||
deviceinfo_dtb=""
|
||||
deviceinfo_modules_initfs=""
|
||||
deviceinfo_arch=\"""" + arch + """\"
|
||||
deviceinfo_arch="{arch}"
|
||||
|
||||
# Device related
|
||||
deviceinfo_keyboard=\"""" + ("true" if has_keyboard else "false") + """\"
|
||||
deviceinfo_external_storage=\"""" + ("true" if has_external_storage else "false") + """\"
|
||||
deviceinfo_keyboard="{"true" if has_keyboard else "false"}"
|
||||
deviceinfo_external_storage="{"true" if has_external_storage else "false"}"
|
||||
deviceinfo_screen_width="800"
|
||||
deviceinfo_screen_height="600"
|
||||
|
||||
# Bootloader related
|
||||
deviceinfo_flash_method=\"""" + flash_method + """\"
|
||||
deviceinfo_flash_method="{flash_method}"
|
||||
"""
|
||||
|
||||
content_heimdall_bootimg = """\
|
||||
|
@ -195,31 +195,31 @@ def generate_apkbuild(args, pkgname, name, arch, flash_method):
|
|||
depends += " mesa-dri-swrast"
|
||||
|
||||
# Whole APKBUILD
|
||||
content = """\
|
||||
content = f"""\
|
||||
# Contributor: Firstname Lastname <email> (CHANGEME!)
|
||||
# Maintainer: Firstname Lastname <email> (CHANGEME!)
|
||||
# Reference: <https://postmarketos.org/devicepkg>
|
||||
pkgname=\"""" + pkgname + """\"
|
||||
pkgdesc=\"""" + name + """\"
|
||||
pkgname="{pkgname}"
|
||||
pkgdesc="{name}"
|
||||
pkgver=0.1
|
||||
pkgrel=0
|
||||
url="https://postmarketos.org"
|
||||
license="MIT"
|
||||
arch=\"""" + arch + """\"
|
||||
arch="{arch}"
|
||||
options="!check !archcheck"
|
||||
depends=\"""" + depends + """\"
|
||||
depends="{depends}"
|
||||
makedepends="devicepkg-dev"
|
||||
source="deviceinfo"
|
||||
|
||||
build() {
|
||||
build() {{
|
||||
devicepkg_build $startdir $pkgname
|
||||
}
|
||||
}}
|
||||
|
||||
package() {
|
||||
package() {{
|
||||
devicepkg_package $startdir $pkgname
|
||||
}
|
||||
}}
|
||||
|
||||
sha512sums="(run 'pmbootstrap checksum """ + pkgname + """' to fill)"
|
||||
sha512sums="(run 'pmbootstrap checksum {pkgname}' to fill)"
|
||||
"""
|
||||
|
||||
# Write the file
|
||||
|
|
|
@ -23,23 +23,24 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
|
|||
dtbTool -p scripts/dtc/ -o "$_outdir/arch/$_carch/boot"/dt.img "$_outdir/arch/$_carch/boot/"
|
||||
install -Dm644 "arch/$_carch/boot"/dt.img "$pkgdir"/boot/dt.img"""
|
||||
|
||||
content = """\
|
||||
patches = ("\n" + " " * 12).join(patches)
|
||||
content = f"""\
|
||||
# Contributor: Firstname Lastname <email> (CHANGEME!)
|
||||
# Maintainer: Firstname Lastname <email> (CHANGEME!)
|
||||
# Reference: <https://postmarketos.org/vendorkernel>
|
||||
# Kernel config based on: arch/""" + carch + """/configs/(CHANGEME!)
|
||||
# Kernel config based on: arch/{carch}/configs/(CHANGEME!)
|
||||
|
||||
pkgname=\"""" + pkgname + """\"
|
||||
pkgname="{pkgname}"
|
||||
pkgver=3.x.x
|
||||
pkgrel=0
|
||||
pkgdesc=\"""" + deviceinfo["name"] + """ kernel fork\"
|
||||
arch=\"""" + deviceinfo["arch"] + """\"
|
||||
_carch=\"""" + carch + """\"
|
||||
_flavor=\"""" + device + """\"
|
||||
pkgdesc="{deviceinfo["name"]} kernel fork"
|
||||
arch="{deviceinfo["arch"]}"
|
||||
_carch="{carch}"
|
||||
_flavor="{device}"
|
||||
url="https://kernel.org"
|
||||
license="GPL-2.0-only"
|
||||
options="!strip !check !tracedeps pmb:cross-native"
|
||||
makedepends=\"""" + makedepends + """\"
|
||||
makedepends="{makedepends}"
|
||||
|
||||
# Source
|
||||
_repository="(CHANGEME!)"
|
||||
|
@ -47,26 +48,27 @@ def generate_apkbuild(args, pkgname, deviceinfo, patches):
|
|||
_config="config-$_flavor.$arch"
|
||||
source="
|
||||
$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
|
||||
$_config""" + ("\n" + " " * 12).join([""] + patches) + """
|
||||
$_config
|
||||
{patches}
|
||||
"
|
||||
builddir="$srcdir/$_repository-$_commit"
|
||||
_outdir="out"
|
||||
|
||||
prepare() {
|
||||
prepare() {{
|
||||
default_prepare
|
||||
. downstreamkernel_prepare
|
||||
}
|
||||
}}
|
||||
|
||||
build() {
|
||||
build() {{
|
||||
unset LDFLAGS
|
||||
make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \\
|
||||
make O="$_outdir" ARCH="$_carch" CC="${{CC:-gcc}}" \\
|
||||
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
|
||||
}
|
||||
}}
|
||||
|
||||
package() {""" + package + """
|
||||
}
|
||||
package() {{{package}
|
||||
}}
|
||||
|
||||
sha512sums="(run 'pmbootstrap checksum """ + pkgname + """' to fill)\""""
|
||||
sha512sums="(run 'pmbootstrap checksum {pkgname}' to fill)\""""
|
||||
|
||||
# Write the file
|
||||
with open(args.work + "/aportgen/APKBUILD", "w", encoding="utf-8") as handle:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue