You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
deltachat-desktop/repo-main.sh

75 lines
2.0 KiB

#!/bin/sh
set -e
if [ $# -eq 0 ]; then
echo "No arguments provided. Aborting..."
exit 1
fi
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "usage: ./repo-main.sh [-h] [MAIN_DIR INCOMING_DIR READY_SUFFIX]
Wrapper script for the repository.
Possible values for the arguments:
MAIN_DIR path of the directory inside the repository where the packages will be storaged
INCOMING_DIR local path of the 'incoming' directory
READY_SUFFIX suffix used to flag a complete transfer of a file
Dependencies: -
"
exit 0
fi
if [ $# -lt 3 ]; then
echo "Mandatory arguments: 'MAIN_DIR', 'INCOMING_DIR', 'INCOMING_DIR'. Aborting..."
exit 1
fi
MAIN_DIR="${1}"
INCOMING_DIR="${2}"
READY_SUFFIX="${3}"
echo "Checking if there are packages to add..."
for f in "${INCOMING_DIR}"/*"${READY_SUFFIX}"; do
## From: https://stackoverflow.com/a/6364244
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
if [ -e "$f" ]; then
echo "Found packages to add."
else
echo "Not found packages to add. Exiting..."
echo exit 0
fi
## This is all we needed to know, so we can break after the first iteration
break
done
echo "Moving package(s) to the repo..."
mkdir -p "${MAIN_DIR}"
./movedebs.sh "${MAIN_DIR}" "${INCOMING_DIR}" "${READY_SUFFIX}"
echo "Installing repository build dependencies (apt)..."
apt-get -qq -y --no-install-recommends install apt-utils > /dev/null
echo "Updating the repo..."
REPO_PATH="repo"
TEMP_DIR="$(mktemp -d)"
./repo-update.sh "${REPO_PATH}" "${TEMP_DIR}"
apt-get -qq -y --no-install-recommends install gpg gpg-agent
echo "Checking if is possible to sign the repo..."
mkdir -p keys
chmod 600 keys
export GNUPGHOME="${PWD}/keys"
./repo-sign.sh "${TEMP_DIR}"
echo "Committing changes..."
mv "${TEMP_DIR}"/* "${REPO_PATH}"/
echo "Done."
#echo "deb file:/repo /" > /etc/apt/sources.list.d/custom-repo.list