nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5if [ "$#" -gt 2 ] || [[ "$1" == -* ]]; then
6 echo "Regenerates packaging data for the zammad packages."
7 echo "Usage: $0 [package name] [zammad directory in nixpkgs]"
8 exit 1
9fi
10
11VERSION=$(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//')
12TARGET_DIR="$2"
13WORK_DIR=$(mktemp -d)
14SOURCE_DIR=$WORK_DIR/zammad-$VERSION
15
16pushd $TARGET_DIR
17
18rm -rf \
19 ./source.json \
20 ./gemset.nix \
21 ./yarn.lock \
22 ./yarn.nix
23
24
25# Check that working directory was created.
26if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
27 echo "Could not create temporary directory."
28 exit 1
29fi
30
31# Delete the working directory on exit.
32function cleanup {
33 rm -rf "$WORK_DIR"
34}
35trap cleanup EXIT
36
37
38pushd $WORK_DIR
39
40echo ":: Creating source.json"
41nix-prefetch-github zammad zammad --rev $VERSION --json --fetch-submodules | jq 'del(.leaveDotGit) | del(.deepClone)' > $TARGET_DIR/source.json
42echo >> $TARGET_DIR/source.json
43
44echo ":: Fetching source"
45curl -L https://github.com/zammad/zammad/archive/$VERSION.tar.gz --output source.tar.gz
46tar zxf source.tar.gz
47
48if [[ ! "$SOURCE_DIR" || ! -d "$SOURCE_DIR" ]]; then
49 echo "Source directory does not exists."
50 exit 1
51fi
52
53pushd $SOURCE_DIR
54
55echo ":: Creating gemset.nix"
56bundix --lockfile=./Gemfile.lock --gemfile=./Gemfile --gemset=$TARGET_DIR/gemset.nix
57
58popd
59popd
60popd