Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: rewrite build.sh without guzuta #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 96 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,105 @@
#!/bin/bash

# TODO: set -e and trap exit cleanup
shopt -s extglob
shopt -s nullglob

DB_EXT=".tar.gz"

err() {
echo "$@"
exit 1
}

add_all_pkgs() {
repo-add "$REPO_DB" "$PKG_REPO_DIR"/*.pkg.tar.*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It would be nice with support for signing (-s).
  • Rather than fully nuking the db each time, an option would be to do repo-add -R

}

rebuild_database() {
rm "$PKG_REPO_DIR/$PKG_REPO."{db,files}*
add_all_pkgs
}

for ((i = 1; i < ($#+1); i++)); do
case "${!i}" in
--arch)
((++i))
PKG_ARCH="${!i}"
;;
--repo)
((++i))
PKG_REPO="${!i}"
;;
--pkg)
((++i))
PKG_NAME="${!i}"
;;
esac
case "${!i}" in
--arch)
((++i))
PKG_ARCH="${!i}"
;;
--repo)
((++i))
PKG_REPO="${!i}"
;;
--pkg)
((++i))
PKG_NAME="${!i}"
;;
--unclean)
((++i))
UNCLEAN="1"
;;
esac
done


#
# Interenal variables
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Interenal variables
# Internal variables

#

# Assume this script is always in the root folder of the repo
# TODO: repo is used to mean both the source repository,
# and the package repository
REPO_DIR=${REPO_DIR:-$(dirname "$(realpath -s "$0")")}
PKG_REPO_DIR="${PKG_REPO_DIR:-$REPO_DIR/repo/$PKG_REPO/$PKG_ARCH}"
REPO_DB="$PKG_REPO_DIR/$PKG_REPO.db$DB_EXT"

# rebuild_database
# exit 0

# TODO: detect corssbuild for arm
if [ "$PKG_ARCH" = "aarch64" ]; then
MAEKCHROOTPKG=${MAEKCHROOTPKG:-makearmpkg}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%s/MAEKCHROOTPKG/MAKECHROOTPKG/g

else
MAEKCHROOTPKG=${MAEKCHROOTPKG:-makechrootpkg}
fi

CHROOT="${CHROOT:-$REPO_DIR/chroot-$PKG_ARCH}"
ARGS="-n"
[ -z "$UNCLEAN" ] && ARGS="$ARGS -cu"

remove_package() {
:
}

# remove_package "$PKG_NAME"
# exit 0

#
# Makepkg settigns
#
export SRCDEST="${SRCDEST:-$REPO_DIR/sources}"
export PKGDEST="$(mktemp -d)"
# export PKGDEST="/tmp/tmp.pjrlw1LoJU"
export LOGDEST="${LOGDEST:-$REPO_DIR/logs}"
# REPO_DIR="${PKGDEST:-$REPO_DIR/repo/$PKG_REPO}"

echo "PKGDEST: $PKGDEST"

if [[ $PKG_REPO && $PKG_ARCH && $PKG_NAME ]]; then
guzuta build --arch $PKG_ARCH --chroot-dir ./chroot-$PKG_ARCH --repo-name $PKG_REPO --repo-dir ./repo/$PKG_REPO/$PKG_ARCH --srcdest ./sources --logdest ./logs PKGBUILDS/$PKG_REPO/$PKG_NAME
mkdir -p "$PKG_REPO_DIR"
# Build package
pushd "PKGBUILDS/$PKG_REPO/$PKG_NAME" || err "failed to pushd"
$MAEKCHROOTPKG $ARGS -r "$CHROOT"
popd || err "failed to popd"

# Move built files, and update database
for package in "$PKGDEST"/*; do
cp "$package" "$PKG_REPO_DIR"
repo-add "$REPO_DB" "$PKG_REPO_DIR/$(basename "$package")"
Copy link

@3nprob 3nprob Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
repo-add "$REPO_DB" "$PKG_REPO_DIR/$(basename "$package")"
gpg --detach-sign --batch --no "$PKG_REPO_DIR/$(basename "$package")"
repo-add -v -s -R "$REPO_DB" "$PKG_REPO_DIR/$(basename "$package")"

echo "built package: $package"
done

rm -rf "$PKGDEST"
else
echo "Invalid Command!"
fi