blob: 6ed91dfb5a2943c5df975d49fb93ac2f42c8fd23 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh
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
8 Config.in
9 LICENSE
10 Makefile
11 README
12 dl
13 feeds.conf.default
14 include
15 package
16 rules.mk
17 scripts
18 target
19 toolchain
20 tools"
21
22OPTIONAL_FILES="
23 .git"
24
25if [ -f feeds.conf ] ; then
26 FILES="$FILES feeds.conf"
27fi
28
29if [ -z "$1" ]; then
30 echo "Syntax: $0 <destination>" >&2
31 exit 1
32fi
33
34if [ -e "$1" ]; then
35 echo "Error: $1 already exists" >&2
36 exit 1
37fi
38
39set -e # fail if any commands fails
40mkdir -p dl "$1"
41for file in $FILES; do
42 [ -e "$PWD/$file" ] || {
43 echo "ERROR: $file does not exist in the current tree" >&2
44 exit 1
45 }
46 ln -s "$PWD/$file" "$1/"
47done
48for file in $OPTIONAL_FILES; do
49 [ -e "$PWD/$file" ] && ln -s "$PWD/$file" "$1/"
50done
51exit 0