diff --git a/.github/workflows/anchor-build-and-release.yml b/.github/workflows/anchor-build-and-release.yml new file mode 100644 index 0000000..78e77a7 --- /dev/null +++ b/.github/workflows/anchor-build-and-release.yml @@ -0,0 +1,90 @@ +name: Build and Release +on: + schedule: [{cron: "1 1 1 * *"}] + push: + branches: + - anchor + +jobs: + BuildRaw: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: docker/setup-qemu-action@v2 + + - name: Setup Dependencies + run: sudo apt-get update; sudo apt-get install git build-essential binfmt-support qemu-user-static debootstrap -y + + - name: checkout submoudles + run: | + git submodule init + git submodule update + - name: Build tarballs + run: | + sudo bash build.sh -s jammy -v raw -a arm64 + sudo bash build.sh -s lunar -v raw -a arm64 + + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: raw-tarballs + path: fs-cook/out/*.tar.gz + + Create-Release: + runs-on: ubuntu-latest + needs: + - BuildRaw + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v3 + with: + name: raw-tarballs + - name: Compute release tag + run: | + udroid_version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' \ + https://github.com/RandomCoderOrg/ubuntu-on-android \ + | tail -n1 | cut -d / -f 3 | cut -d v -f 2- ) + udroid_download=$( + git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' \ + https://github.com/RandomCoderOrg/udroid-download \ + | tail -n1 | cut -d / -f 3 + ) + echo "VERSIONTAG=V${udroid_version}${BUILD_TYPE}PR$((${udroid_download: -2} + 1))" >> $GITHUB_ENV + - name: Generate release notes + run: sudo bash /home/runner/work/udroid-download/udroid-download/.github/scripts/generate-release-notes.sh + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSIONTAG }} + release_name: ${{ env.VERSIONTAG }} + body_path: release.md + draft: false + prerelease: true + - name: Sleep for sometime + run: sleep 60 + - name: Upload assets + run: | + set -x + assets=() + for asset in ./*.tar.gz; do + assets+=("-a" "$asset") + done + tag_name="${VERSIONTAG}" + hub release edit -F release.md "${assets[@]}" -m "$tag_name" "$tag_name" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: update json + run: | + sudo apt-get install python3 -y + sudo python3 gen_data/gen-update-json.py --release-tag ${{ env.VERSIONTAG }} + set +e + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git add distro-data.json + git commit -m "AUTO: update distro-data.json" + git push + set -e diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1a0f7da..044daf6 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - anchor jobs: BuildRaw: diff --git a/distro-data.json b/distro-data.json index f8440bf..1fb4347 100644 --- a/distro-data.json +++ b/distro-data.json @@ -1,24 +1,46 @@ { - "suites": ["jammy", "impish", "focal"], + "suites": [ + "jammy", + "impish", + "focal", + "lunar" + ], "jammy": { - "varients": ["raw"], + "varients": [ + "raw" + ], "raw": { - "arch": ["aarch64", "armv7l", "armhf", "amd64", "x86_64"], + "arch": [ + "aarch64", + "armv7l", + "armhf", + "amd64", + "x86_64" + ], "Name": "udroid-jammy-raw", "FirendlyName": "Ubuntu Jammy (raw)", - "aarch64url": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3R3/jammy-raw-arm64.tar.gz", - "aarch64sha": "5e041e094eaf175a8a76ebf30f911aad043da53c9e54012eb8c4a69e27550518", + "aarch64url": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3PR19/jammy-raw-arm64.tar.gz", + "aarch64sha": "e2a42eaf7af74b8ba019001b9628578ee9ac503668691ef9c28434b1044ba87d", "armhfurl": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3R3/jammy-raw-armhf.tar.gz", "armhfsha": "df811e5010cbb07e05db78aa1dc1deecd3139deae8704be31a4db7d23d3efccf", "amd64url": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3R3/jammy-raw-amd64.tar.gz", "amd64sha": "2102530b19b69b0c70c26e09915c58b58486e5df53c4c8706084b11744d010d1" } }, - "impish": { - "varients": ["xfce4", "mate", "raw"], + "varients": [ + "xfce4", + "mate", + "raw" + ], "raw": { - "arch": ["aarch64", "armv7l", "armhf", "amd64", "x86_64"], + "arch": [ + "aarch64", + "armv7l", + "armhf", + "amd64", + "x86_64" + ], "Name": "udroid-impish-raw", "FirendlyName": "Ubuntu Impish (raw)", "aarch64url": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3R3/impish-raw-arm64.tar.gz", @@ -29,7 +51,11 @@ "amd64sha": "c5ce02ed7be92537bb1e2bcc5eb2ab588afc50c147972e1336a2a9c290813245" }, "xfce4": { - "arch": ["aarch64", "amd64", "x86_64"], + "arch": [ + "aarch64", + "amd64", + "x86_64" + ], "Name": "udroid-impish-xfce4", "FirendlyName": "Ubuntu Impish (xfce4)", "aarch64url": "https://github.com/RandomCoderOrg/ubuntu-on-android/releases/download/v3/udroid-arm64-xfce4-V3MBB2.tar.gz", @@ -38,7 +64,9 @@ "amd64sha": "88a5f5f079aef994b6d5b2e3df773aa875ed2157d1f00c8fda504bda9f01e680" }, "mate": { - "arch": ["aarch64"], + "arch": [ + "aarch64" + ], "Name": "udroid-impish-mate", "FirendlyName": "Ubuntu Impish (mate)", "aarch64url": "https://github.com/RandomCoderOrg/ubuntu-on-android/releases/download/v3/udroid-mate-arm64-betav2.tar.gz", @@ -46,9 +74,16 @@ } }, "focal": { - "varients": ["xfce4"], - "xfce4":{ - "arch": ["aarch64", "armv7l", "armv8l", "armhf"], + "varients": [ + "xfce4" + ], + "xfce4": { + "arch": [ + "aarch64", + "armv7l", + "armv8l", + "armhf" + ], "Name": "udroid-focal-xfce4", "FirendlyName": "Ubuntu Focal (xfce4)", "aarch64url": "https://github.com/RandomCoderOrg/ubuntu-on-android/releases/download/v02-xfce4/hippo-arm64-v02-xfce4.tar.gz", @@ -58,9 +93,16 @@ } }, "kinetic": { - "varients": ["raw"], + "varients": [ + "raw" + ], "raw": { - "arch": ["aarch64", "armv7l", "armv8l", "armhf"], + "arch": [ + "aarch64", + "armv7l", + "armv8l", + "armhf" + ], "Name": "udroid-kinetic-raw", "FirendlyName": "Ubuntu Kinetic (raw)", "aarch64url": "", @@ -70,5 +112,20 @@ "x86_64url": "", "x86_64sha": "" } + }, + "lunar": { + "varients": [ + "raw" + ], + "raw": { + "arch": [ + "arm64", + "aarch64" + ], + "Name": "lunar-raw", + "FirendlyName": "lunar raw", + "aarch64url": "https://github.com/RandomCoderOrg/udroid-download/releases/download/V3PR19/lunar-raw-arm64.tar.gz", + "aarch64sha": "d4332a358308e180949d9c25a29e78204440d4d0c9c3bff6eed4bcd93d1dca34" + } } -} +} \ No newline at end of file diff --git a/gen_data/arch.py b/gen_data/arch.py new file mode 100644 index 0000000..e3f5ac6 --- /dev/null +++ b/gen_data/arch.py @@ -0,0 +1,34 @@ + +def translated_arch() -> dict: + """System architectures translated to deb package architecture names + + Returns: + dict: dictionary of arch names + """ + # TODO Need improve above docstring + + # SystemArchitecture:PackageArchitecture + return dict( + { + "armhf": "armhf", + "arm": "armhf", + "arm64": "aarch64", + "aarch64": "aarch64", + "amd64": "amd64", + "x86_64": "amd64" + } + ) + + + +def ReverseTranslate() -> dict: + StoPdict = translated_arch(); + PtoSdict = {} + + for SysArch,PakArch in zip(StoPdict.keys(),StoPdict.values()): + if PakArch in PtoSdict: + PtoSdict[PakArch].append(SysArch) + else: + PtoSdict[PakArch] = [SysArch] + + return PtoSdict diff --git a/gen_data/gen-update-json.py b/gen_data/gen-update-json.py index 675b5a6..ca786bc 100644 --- a/gen_data/gen-update-json.py +++ b/gen_data/gen-update-json.py @@ -2,9 +2,10 @@ import json import optparse import utils +import arch GIT_ROOT = os.popen("git rev-parse --show-toplevel").read().strip() -DIR = "fs-cook/out" +DIR = "." VERBOSE = False JSON_CONF = f"{GIT_ROOT}/distro-data.json" @@ -12,13 +13,18 @@ def update_json_conf(file) -> None: data = strip_info(file) jdata = json.load(open(JSON_CONF, 'r')) + # resolv data + jdata = utils.resolv_data(jdata, data[0], data[1], [data[2]]) + # update url - jdata[data[0]][data[1]][f"{data[2]}Url"] = get_release_url( - RELEASE_TAG, data[3]) + jdata[data[0]] \ + [data[1]] \ + [f"{data[2]}url"] = get_release_url(RELEASE_TAG, data[3]) # update sha - jdata[data[0]][data[1]][f"{data[2]}sha"] = os.popen( - f"sha256sum {DIR}/{data[3]}").read().split()[0] + jdata[data[0]] \ + [data[1]] \ + [f"{data[2]}sha"] = os.popen(f"sha256sum {file}").read().split()[0] # update JSON_CONF file = open(JSON_CONF, 'w') @@ -29,25 +35,18 @@ def strip_info(file): name = os.path.splitext(basename)[0] name = os.path.splitext(name)[0] - sp = name.split("-") - ar = { - "armhf": "armhf", - "arm": "armhf", - "arm64": "aarch64", - "aarch64": "aarch64", - "amd64": "amd64", - "x86_64": "amd64" - } + sp = name.split("-") + StoPdict = arch.translated_arch() suite = sp[0] variant = sp[1] - arch = ar[sp[2]] - - return [suite, variant, arch, basename] + packageArchitecture = StoPdict[sp[2]] + + return [suite, variant, packageArchitecture, basename] def get_release_url(release_tag, file) -> str: - repo="https://github.com/RandomCoderOrg/udroid-download" - url="{}/releases/download/{}/{}".format(repo, release_tag, file) + repo ="https://github.com/RandomCoderOrg/udroid-download" + url ="{}/releases/download/{}/{}".format(repo, release_tag, file) return url if __name__ == '__main__': @@ -60,8 +59,10 @@ def get_release_url(release_tag, file) -> str: options, args = parser.parse_args() # get release tag + from utils import getfilesR + RELEASE_TAG = options.release_tag - for file in os.listdir(DIR): + for file in getfilesR(DIR): if file.endswith(".tar.gz"): update_json_conf(file) diff --git a/gen_data/utils.py b/gen_data/utils.py index 1ee84a9..a89a8d0 100644 --- a/gen_data/utils.py +++ b/gen_data/utils.py @@ -1,31 +1,84 @@ -import json - -def resolv_data(file, - suite: str, - varients: list, - Name: str, - FriendlyName: str, - arch: list = ["aarch64", "armv7l", "armhf", "amd64", "x86_64"] - ): - file = json.load(open(file, 'r')) - - # update suites list - file["suites"].append(suite) - - # [WIP] create new suite - new_suite = { - f"{suite}" : { - "variants" : varients, - } +import os + +def add_suite(JsonFile: dict, suite: str) -> None: + """ Add suite to the JsonFile + + Args: + JsonFile (dict): The JsonFile + suite (str): The suite to add + """ + + JsonFile["suites"].append(suite) + JsonFile[suite] = { + "varients": [] } + + +def add_varient(JsonFile: dict, suite: str, varient: str, Name: str, FirendlyName: str) -> None: + """ Add varient to the JsonFile""" + + JsonFile[suite]["varients"].append(varient) + JsonFile[suite][varient] = { + # adding default arch to the varients + "arch": [], + "Name": Name, + "FirendlyName": FirendlyName + } + +def add_arch(JsonFile: dict, suite: str, varient: str, arch:list[str]) -> None: + """ Add arch to the JsonFile + + Args: + JsonFile (dict): The JsonFile + suite (str): The suite to add archs + varient (str): The varient to archs + arch (list[str]): The arch to add + """ - # register varients - for variant in varients: - new_suite[f"{suite}"][f"{variant}"] = { - "arch" : arch, - } + import arch as archAlt + archAltName = archAlt.ReverseTranslate() + + #revArchLst = {'armhf': ['armhf', 'arm'], 'aarch64': ['arm64', 'aarch64'], 'amd64': ['amd64', 'x86_64']} + revArchLst = archAltName[arch] + for revArch in revArchLst: + JsonFile[suite][varient]["arch"].append(revArch) + JsonFile[suite][varient][f"{arch}url"] = "" + JsonFile[suite][varient][f"{arch}sha"] = "" + + +def resolv_data( + json_data: dict, + suite: str, + variant: str, + arch: list[str], + Name: str = ..., + FriendlyName: str = ..., + ) -> dict: + + if Name is ...: + Name = f"{suite}-{variant}" + + if FriendlyName is ...: + FriendlyName = f"{suite} {variant}" - # exp1 - # create new data(">/file", "sai", ["raw"], ) + if suite not in json_data["suites"]: + add_suite(json_data,suite) + + if variant not in json_data[suite]["varients"]: + add_varient(json_data, suite, variant, Name, FriendlyName) + for arc in arch: + if arc not in json_data[suite][variant]["arch"]: + add_arch(json_data, suite, variant, arc) + + return json_data + +def getfilesR(path: str) -> list: + + files = [] + # include depth + for r, d, f in os.walk(path): + for file in f: + files.append(os.path.join(r, file)) + return files diff --git a/suites/lunar/raw.sh b/suites/lunar/raw.sh new file mode 100644 index 0000000..bb258f1 --- /dev/null +++ b/suites/lunar/raw.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +#shellcheck disable=SC1091 + +# this is an example file to BUILD raw file system +# export variable SUITE to set debootstrap suite name (default: hirsute) + +source plugins/envsetup + +export OVERRIDER_COMPRESSION_TYPE +export SUITE +export ENABLE_EXIT +export ENABLE_USER_SETUP + +SUITE="lunar" +frn="out/$SUITE-raw" +OVERRIDER_COMPRESSION_TYPE="gzip" +ENABLE_EXIT=true +ENABLE_USER_SETUP=false + + +additional_setup() { + +# update sources.list [Only for ubuntu suites] +cat <<-EOF >$chroot_dir/etc/apt/sources.list +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. +deb $MIRROR $SUITE main restricted +# deb-src $MIRROR $SUITE main restricted +## Major bug fix updates produced after the final release of the +## distribution. +deb $MIRROR $SUITE-updates main restricted +# deb-src $MIRROR $SUITE-updates main restricted +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team. Also, please note that software in universe WILL NOT receive any +## review or updates from the Ubuntu security team. +deb $MIRROR $SUITE universe +# deb-src $MIRROR $SUITE universe +deb $MIRROR $SUITE-updates universe +# deb-src $MIRROR $SUITE-updates universe +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb $MIRROR $SUITE multiverse +# deb-src $MIRROR $SUITE multiverse +deb $MIRROR $SUITE-updates multiverse +# deb-src $MIRROR $SUITE-updates multiverse +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +deb $MIRROR $SUITE-backports main restricted universe multiverse +# deb-src $MIRROR $SUITE-backports main restricted universe multiverse +EOF + +# set up pv +lshout "Setting up pv..." +cp $ROOT_DIR/core/pv/pv-${t_arch}.deb $chroot_dir +run_cmd "dpkg -i /pv-${t_arch}.deb" +run_cmd "rm /pv-${t_arch}.deb" + +# clean any archive if exits +apt-get clean + +} + +# Option to build specific arch +# arch name as $1 + +case $1 in +arm64 | armhf | amd64) _arch="$1" ;; +all | -a) _arch="armhf arm64 amd64" ;; +*) die "Unknown arch option [ Allowed: arm64, armhf, amd64, all(for all 3) ]" ;; +esac + +for arch in ${_arch}; do + shout "Bootstrapping $SUITE [${arch}] ...." + do_build "${frn}-${arch}" "${arch}" + shout "packing up the raw file systems..." + do_compress "${frn}-${arch}" + shout "unmounting the raw file systems from host..." + do_unmount "${frn}-${arch}" +done + +shout "Build Complete.." +ls ${frn}*tar*