1#!/usr/bin/env bash
2# Create a new openwrt tree with symlinks pointing at the current tree
3# Usage: ./scripts/symlink-tree.sh <destination>
4
5FILES="
6	BSDmakefile
7	Config.in
8	LICENSE
9	Makefile
10	README
11	dl
12	docs
13	feeds.conf.default
14	include
15	package
16	rules.mk
17	scripts
18	target
19	toolchain
20	tools"
21
22if [ -f feeds.conf ] ; then
23	FILES="$FILES feeds.conf"
24fi
25
26if [ -z "$1" ]; then
27	echo "Syntax: $0 <destination>"
28	exit 1
29fi
30
31if [ -e "$1" ]; then
32	echo "Error: $1 already exists"
33	exit 1
34fi
35
36set -e # fail if any commands fails
37mkdir -p dl "$1"
38for file in $FILES; do
39	[ -e "$PWD/$file" ] || {
40		echo "ERROR: $file does not exist in the current tree"
41		exit 1
42	}
43	ln -s "$PWD/$file" "$1/"
44done
45exit 0
46