From 7df29661c362aa64a047143bfc52929275b06ebf Mon Sep 17 00:00:00 2001 From: EnumDev Date: Sat, 26 Oct 2024 18:04:04 +0300 Subject: [PATCH] Moved over to new BPM file format --- bpm-convert | 9 ++++++--- bpm-package | 2 +- create-repository-data | 12 +++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bpm-convert b/bpm-convert index 49438d1..557ee64 100755 --- a/bpm-convert +++ b/bpm-convert @@ -27,7 +27,7 @@ if ! [ -f "$PACKAGE" ]; then echo "$PACKAGE is not a path to a file" exit 1 fi -if ! file "$PACKAGE" | grep -q 'gzip compressed data'; then +if ! file "$PACKAGE" | grep -q 'POSIX tar archive'; then echo "$PACKAGE is not a BPM package" exit 1 fi @@ -126,6 +126,8 @@ function SetVariables() { export BPM_PKG_NAME="${PKGINFO[name]}" export BPM_PKG_DESC="${PKGINFO[description]}" export BPM_PKG_VERSION="${PKGINFO[version]}" + export BPM_PKG_REVISION="${PKGINFO[revision]}" + [ -z "$BPM_PKG_REVISION" ] && export BPM_PKG_REVISION=1 export BPM_PKG_URL="${PKGINFO[url]}" export BPM_PKG_ARCH="${PKGINFO[architecture]}" IFS=',' read -r -a BPM_PKG_DEPENDS <<< "${PKGINFO[depends]}" @@ -200,8 +202,9 @@ for func in $(typeset -F | awk '{print $3}' | grep '^package'); do echo "${PKGINFO_FILE}" > pkg.info sed -i "s/architecture:.*/architecture: ${ARCH}/g" pkg.info sed -i 's/type:.*/type: binary/g' pkg.info - fakeroot -i "$TEMPDIR"/fakeroot_file_"$pkgname" tar -czpf "$pkgname".tar.gz pkg.info ${PACKAGE_SCRIPTS[@]} output --transform 's/output/files/' - mv "$pkgname".tar.gz "$DIR"/"$pkgname"-"$BPM_PKG_VERSION"-"$ARCH".bpm + fakeroot -i "$TEMPDIR"/fakeroot_file_"$pkgname" find "$TEMPDIR"/output -mindepth 1 -printf "%P %#m %U %G %s\n" > "$TEMPDIR"/pkg.files + find output -printf "%P\n" | fakeroot -i "$TEMPDIR"/fakeroot_file_"$pkgname" tar -czf files.tar.gz --no-recursion -C output -T - + tar -cf "$DIR"/"$pkgname"-"$BPM_PKG_VERSION"-"$BPM_PKG_REVISION"-"$ARCH".bpm --owner=0 --group=0 -C "$TEMPDIR" pkg.info pkg.files ${PACKAGE_SCRIPTS[@]} files.tar.gz echo "Packaged ${pkgname} successfully!" rm "$TEMPDIR"/fakeroot_file_"$pkgname" rm -r output/ diff --git a/bpm-package b/bpm-package index 8213e13..eeae4b5 100755 --- a/bpm-package +++ b/bpm-package @@ -88,7 +88,7 @@ for pkginfo in ./pkg.inf*; do done echo "Creating $type package as $output" -tar -c --owner=0 --group=0 --no-same-owner -zf "$output" "${toCompress[@]}" +tar -c --owner=0 --group=0 --no-same-owner -f "$output" "${toCompress[@]}" if [ ! -z "$CONVERT" ] && "$CONVERT" && [[ "$type" == "source" ]]; then args=() diff --git a/create-repository-data b/create-repository-data index 08629ac..056165d 100755 --- a/create-repository-data +++ b/create-repository-data @@ -17,7 +17,7 @@ while getopts "d" flag; do case "$flag" in d) DEEP=true shopt -s globstar;; - *) echo "Unknown flag ${flag}" + *) >&2 echo "Unknown flag ${flag}" exit 2;; esac done @@ -27,7 +27,7 @@ if [ -z "${@:$OPTIND:1}" ]; then exit 1 fi if ! [ -d "${@:$OPTIND:1}" ]; then - echo "The given path is not a directory" + >&2 echo "The given path is not a directory" exit 1 fi @@ -48,13 +48,19 @@ create_entry() { info="info:"$'\n' info+=$(tar -xf "$pkg" pkg.info -O | sed 's/^/ /g') package=$(echo "$info" | grep 'name: ' | xargs | awk '{print $2}') + if ! echo "$info" | grep -q '^ type: binary'; then + >&2 echo "The following package is not a binary package: ${package}" + exit 1 + fi if containsElement "$package" "${PKGS[@]}"; then - echo "The following package was found in more than 1 package archives: ${package}" + >&2 echo "The following package was found in more than 1 package archives: ${package}" exit 1 fi PKGS+=("$package") file="$(realpath -s --relative-to="$REPO" "$pkg")" info+=$'\n'"download: ${file}" + info+=$'\n'"download_size: "$(cat "$pkg" | wc -c) + info+=$'\n'"installed_size: "$(tar -xf "$pkg" files.tar.gz -O | zcat | wc -c) info+=$'\n---' echo "$info" }