diff --git a/build.sh b/build.sh index 687308e..b841701 100755 --- a/build.sh +++ b/build.sh @@ -13,14 +13,15 @@ done < <(printenv | cut -d '=' -f 1 | grep -vE '^(PWD|PATH|HOME|BUILD_DIR)$') printenv && # Build -if [ -n "$NO_CLEAN_UP" ]; then - find '.flatpak-builder/build' '.flatpak-builder/cache' -delete || - rm -rf ".flatpak-builder/build/*" ".flatpak-builder/build/.*" '.flatpak-builder/cache' -fi&& -flatpak-builder $3 --arch "$2" --install-deps-from=winebarrels --install-deps-only "$BUILD_DIR" "$1" && if [ -z "$4" ]; then BUILD_DIR= exec flatpak-builder $3 --arch "$2" --sandbox --rebuild-on-sdk-change --bundle-sources "$BUILD_DIR" "$1" else - HASH="$("$(dirname "$0")/hash_modules.py" --installed "$1" "$2" | sed -n '1p')" || exit 0 && - BUILD_DIR= exec flatpak-builder $3 --arch "$2" --sandbox --rebuild-on-sdk-change --bundle-sources --repo "$4" -s "WB_HASH='${HASH}'" "$BUILD_DIR" "$1" + HASH="$("$(dirname "$0")/hash_modules.py" --installed "$1" "$2" | sed -n '1p')" && + ID="$("$(dirname "$0")/hash_modules.py" --get-id "$1" "$2").Builds" && + ( + find '.flatpak-builder/build' '.flatpak-builder/cache' -delete || + rm -rf ".flatpak-builder/build" '.flatpak-builder/cache' + ) && + BUILD_DIR= flatpak-builder $3 --arch "$2" --keep-build-dirs --sandbox --rebuild-on-sdk-change --bundle-sources --repo "$4" -s "WB_HASH='${HASH}'" "$BUILD_DIR" "$1" && + ostree commit --repo "$4" --owner-uid=0 --owner-gid=0 --no-xattrs --generate-sizes --skip-if-unchanged --tree=dir=.flatpak-builder/build --branch "$ID" fi diff --git a/hash_modules.py b/hash_modules.py index e6f2025..f1a2973 100755 --- a/hash_modules.py +++ b/hash_modules.py @@ -213,6 +213,17 @@ class ModuleLoader(): own_hash = set(self.version_hashes(arch, use_local=use_local, verbose=verbose)) old_hashes = set(self.old_wb_hashes(arch, verbose=verbose)) return len(own_hash.intersection(old_hashes)) == 0 + + def get_id(self, arch): + id = self.content["id"] + branch = str(self.content["branch"]) + assert "/" not in id + assert "/" not in arch + assert "/" not in branch + if bool(self.content.get("build-runtime", False)) or bool(): + return "runtime/%s/%s/%s" % (id, arch, branch) + else: + return "app/%s/%s/%s" % (id, arch, branch) def relative(self, file): return os.path.abspath(os.path.join(os.path.split(self.path)[0], file)) @@ -231,6 +242,10 @@ def get_own_hash(source, arch, use_local=False, verbose=False): raise ValueError("Result have to be an string.") return tmp[0] +def get_id(source, arch): + mod = ModuleLoader(source) + return mod.get_id(arch) + if __name__ == '__main__': import argparse @@ -247,9 +262,13 @@ if __name__ == '__main__': const=True, default=False, help="Use installed then remote.") parser.add_argument("-v", "--verbose", dest="verbose", action="store_const", const=True, default=False, help="Verbose information to stderr.") + parser.add_argument("--get-id", dest="get_id", action="store_const", + const=True, default=False, help="Get the id.") args = parser.parse_args() - if args.rebuild: + if args.get_id: + print(get_id(args.file[0], args.arch[0])) + elif args.rebuild: if get_need_update(args.file[0], args.arch[0], use_local=args.installed, verbose=args.verbose): exit(0) else: