Compare commits

...

5 commits
0.0.1 ... main

3 changed files with 20 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ keys/
repo/
build/
*.list
config_test.json

6
config.json Normal file
View file

@ -0,0 +1,6 @@
{
"remote_user": "",
"remote_server": "",
"remote_path": "",
"ssh_priv_key_path": ""
}

View file

@ -4,6 +4,7 @@ readonly PODMAN_IMAGE="noveria:alpine-repo"
readonly ROOT_DIR="$(dirname $(readlink -f $(which ${0})))"
readonly PODMAN_IMAGE_DIR="${ROOT_DIR}/image"
readonly CONFIG="/etc/repo-mgmt/config.json"
readonly KEYS_DIR="${ROOT_DIR}/keys"
readonly REPO_DIR="${ROOT_DIR}/repo"
readonly BUILD_DIR="${ROOT_DIR}/build"
@ -177,8 +178,16 @@ function delete_pkg_from_repo() {
}
function publish_repo() {
message_blue_double_colon "Publishing files to remote webserver"
message_error "Not yet implemented"
if [[ -z $(jq -r '.remote_user' $CONFIG) || -z $(jq -r '.remote_server' $CONFIG) || -z $(jq -r '.remote_path' $CONFIG) || -z $(jq -r '.ssh_priv_key_path' $CONFIG) ]]; then
message_error "Config is incomplete. Please fill out first!"
fi
local remote_user="$(jq -r '.remote_user' $CONFIG)"
local remote_server="$(jq -r '.remote_server' $CONFIG)"
local remote_path="$(jq -r '.remote_path' $CONFIG)"
local ssh_priv_key_path="$(jq -r '.ssh_priv_key_path' $CONFIG)"
message_blue_double_colon "Publishing files to remote webserver: ${remote_user}@${remote_server}:${remote_path}/"
rsync -a --delete -e "ssh -i ${ssh_priv_key_path}" --progress --rsync-path="mkdir -p ${remote_path} && rsync" "${REPO_DIR}/" "${remote_user}@${remote_server}:${remote_path}"
}
##
@ -220,7 +229,8 @@ function build_pkgs() {
container_run "sudo apk update && sudo apk upgrade && cd /build/$pkg && abuild checksum && abuild -r && find /home/apkbuild/packages/build -name $1*.apk -exec mv {} /build/$1 \;"
message_blue_single_arrow "Copying package to repo"
local VERSION_ID=$(container_run "grep VERSION_ID= /etc/os-release")
rsync -a --delete-before --progress "${BUILD_DIR}/$pkg"/*.apk "${REPO_DIR}/v$(echo $VERSION_ID | cut -d= -f2 | rev | cut -d. -f2- | rev)/noveria/x86_64"
find $REPO_DIR/v$(echo $VERSION_ID | cut -d= -f2 | rev | cut -d. -f2- | rev)/noveria/x86_64 -name $1*.apk -exec rm -f {} \;
rsync -a --delete --progress "${BUILD_DIR}/$pkg"/*.apk "${REPO_DIR}/v$(echo $VERSION_ID | cut -d= -f2 | rev | cut -d. -f2- | rev)/noveria/x86_64"
rm -f "${BUILD_DIR}/$pkg"/*.apk
refresh_repo
sign_repo