File: initializer

package info (click to toggle)
zkg 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,740 kB
  • sloc: python: 5,910; sh: 268; makefile: 265; cpp: 24
file content (56 lines) | stat: -rwxr-xr-x 1,663 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/env bash
#
# This initializer runs prior to every test. It creates a fresh copy of our
# test packages and package sources. Individual tests may tweak these further as
# needed, prior to running tests with them. The initializer also creates a zkg
# config that all tests automatically run with, via the "zkg" wrapper script in
# this directory.

cp -R $PACKAGES .

for p in packages/*; do
    if [ $p = 'packages/foo' ]; then
        # Use a different default branch than 'master' for testing purposes
        ( cd $p && git init && git checkout -b main && git add * && git commit -m 'init' )
    else
        ( cd $p && git init && git add * && git commit -m 'init' )
    fi
done

cp -R $SOURCES .

find sources -name 'zkg.index' -exec sed -i -e "s#^#$(pwd)/packages/#" {} \;

for s in sources/*; do
    ( cd $s && git init && git add * && git commit -m 'init' )
done

# Create a branch drop-corge in source "one" to drop corge from index
( cd sources/one &&
  default_branch=$(git rev-parse --abbrev-ref HEAD) &&
  git checkout -b drop-corge &&
  sed -i -e '/corge/d' bob/zkg.index &&
  git add ./bob/zkg.index &&
  git commit -m 'Remove corge' &&
  git checkout ${default_branch} )

cp -R $TEMPLATES .

for t in templates/*; do
    (
        cd $t && git init && git add * && git commit -m 'init'
        git remote add origin https://example.com/zeek/package-template
    )
done

echo "\
[sources]
one = $(pwd)/sources/one
[paths]
state_dir = $(pwd)/state
script_dir = $(pwd)/scripts
plugin_dir = $(pwd)/plugins
bin_dir = $(pwd)/bin
" >> config

type zeek-config > /dev/null 2>&1 && echo "zeek_dist = $(zeek-config --zeek_dist)" >> config || true