2021-11-23 21:52:25 +01:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
VERSION=$(curl -s https://ftp.zammad.com/ | grep -v latest | grep tar.gz | sed "s/<a href=\".*\">zammad-//" | sort -h | tail -n 1 | awk '{print $1}' | sed 's/.tar.gz<\/a>//')
|
|
|
|
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 10:27:10 +01:00
|
|
|
nix-prefetch-github zammad zammad --rev $VERSION --json --fetch-submodules | jq 'del(.leaveDotGit) | del(.deepClone)' > $TARGET_DIR/source.json
|
2021-11-23 21:52:25 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
echo ":: Creating yarn.nix"
|
|
|
|
yarn install
|
|
|
|
cp yarn.lock $TARGET_DIR
|
|
|
|
yarn2nix > $TARGET_DIR/yarn.nix
|
|
|
|
|
2022-02-23 04:50:33 +01:00
|
|
|
# needed to avoid import from derivation
|
2022-03-21 10:27:10 +01:00
|
|
|
jq --arg VERSION "$VERSION" '. += {name: "Zammad", version: $VERSION}' package.json > $TARGET_DIR/package.json
|
2022-02-23 04:50:33 +01:00
|
|
|
|
2021-11-23 21:52:25 +01:00
|
|
|
popd
|
|
|
|
popd
|
|
|
|
popd
|