nixpkgs/pkgs/applications/networking/misc/zammad/update.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -gt 2 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for the zammad packages."
echo "Usage: $0 [package name] [zammad directory in nixpkgs]"
exit 1
fi
2023-05-12 17:43:48 +00:00
VERSION=$(xidel -s https://ftp.zammad.com/ --extract "//a" | grep -E "zammad-[0-9.]*.tar.gz" | sort --version-sort | tail -n 1 | sed -e 's/zammad-//' -e 's/.tar.gz//')
TARGET_DIR="$2"
WORK_DIR=$(mktemp -d)
SOURCE_DIR=$WORK_DIR/zammad-$VERSION
pushd $TARGET_DIR
rm -rf \
./source.json \
./gemset.nix \
./yarn.lock \
./yarn.nix
# Check that working directory was created.
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temporary directory."
exit 1
fi
# Delete the working directory on exit.
function cleanup {
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
pushd $WORK_DIR
echo ":: Creating source.json"
2022-03-21 09:27:10 +00:00
nix-prefetch-github zammad zammad --rev $VERSION --json --fetch-submodules | jq 'del(.leaveDotGit) | del(.deepClone)' > $TARGET_DIR/source.json
echo >> $TARGET_DIR/source.json
echo ":: Fetching source"
curl -L https://github.com/zammad/zammad/archive/$VERSION.tar.gz --output source.tar.gz
tar zxf source.tar.gz
if [[ ! "$SOURCE_DIR" || ! -d "$SOURCE_DIR" ]]; then
echo "Source directory does not exists."
exit 1
fi
pushd $SOURCE_DIR
echo ":: Creating gemset.nix"
bundix --lockfile=./Gemfile.lock --gemfile=./Gemfile --gemset=$TARGET_DIR/gemset.nix
2022-02-23 03:50:33 +00:00
# needed to avoid import from derivation
2022-03-21 09:27:10 +00:00
jq --arg VERSION "$VERSION" '. += {name: "Zammad", version: $VERSION}' package.json > $TARGET_DIR/package.json
2022-02-23 03:50:33 +00:00
popd
popd
popd