-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfossilize
executable file
·201 lines (184 loc) · 7.36 KB
/
fossilize
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# Script file to automate initiialisation of a FOSSIL repository.
# Requires the name of the new checkout directory and optionally a path to a
# repository. Exit code 0 if the repository does not already exist
# and the checkout directory is either already present or is created.
#
# Will generate the checkout directory in the current directory and the new
# repository in /Users/Shared/FOSSIL. Will automatically add all the files from the
# checkout directory to the repository and perform an initial checkout.
#
# The script names the project after the repository name.
#
# The script was developed to facilitate standardised structures for KiCad projects.
# Invoking the -k option generates a series of basic folders and files for
# KiCad EDA prjects (Gerbers, Simulation Libraries etc). Invoking the -i option with
# the -k option adds a 'KiCad' folder badge.
#
# Also appends information about the repository to the user's .bugwarriorrc file
# to allow bugwarrior to scrape bug entries into Taskwarrior.
#
# NB Needs unsuported umonkey version of Bugwarrior.
# https://github.com/FvD/bugwarrior/commit/ac985163c4c699059897aa0fc98f372fea768fcf
#
# Incorporates a folder 'badge' using SetFileIcon
# (from http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html)
# The baseline icon needs to be stored in the DEFAULT_REPO directory. Use 'File2Icon'
# to make this badged folder.
#
# NB This script dumps a 'setup' file into the checkout with the repository detail
# and password. This is a major security risk but simplifies setting up in the single
# user scenario.
#
# Changes 05.07.2021
# SetFileIcon no longer seems supported and is non-functional. Equivilent functionality is available from
# 'fileicon' which can be installed using 'brew' (brew install fileicon). This requires an xxx.icns file in the
# root repository.
#
# Usage:
# fossilize [-h] [-v] [-f] [-k] [-i] checkout_dir
#
# TODO Add option for alternative repository location.
# Add option of alternative checkout directory) i.e not in current directory.
# Default is to add all files in checkout directory and make an initial commit
# change to fossilize [-h][-v][-k][-i][-c] checkout_dir [-r] alternative_repository_path?
#
#
OPTIND=1
# Default repository path and version number
VERSION=0.3
DEFAULT_REPO=/Users/Shared/FOSSIL/
# Initialize our local variables:
checkout_dir=""
repopath=$DEFAULT_REPO
defaulticon=$DEFAULT_REPO/FOSSIL.icns
kicadicon=$DEFAULT_REPO/KICAD.icns
#kicadicon=$DEFAULT_REPO/kicad2.png
icon=0
function usage () {
cat << EOF
Usage: fossilize [OPTION] [FILE...]
-h displays basic help
-v displays version
-i adds fossil icon to checkout folder (requires FileIconSet)
-r path to alternative repository (defaults if omitted to /Users/Shared/FOSSIL)
-k Initialize baseline folders for Kicad project.
EOF
exit 0
}
while getopts ":hvik" opt; do
case "$opt" in
h) usage
;;
v) version=$VERSION
echo "fossilize3 version : $version"
exit 0
;;
i) if hash fileicon 2>/dev/null; then
icon=yes
else
echo "Setting an icon requires fileicon in your path (brew install fileicon)" 1>&2
exit 1
fi
;;
k) kicad=yes
echo "Kicad format repo : $kicad"
;;
\?) echo "fossilize : illegal option: $1" 1>&2
echo "usage: fossilize [-hvi] checkout directory [-r] repository directory"
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ ! $1 ]; then
echo "Must specify a checkout directory. Aborting" 1>&2
exit 1
fi
checkout_dir=$1
# echo "Looking for $DEFAULT_REPO$checkout_dir.fossil"
if [ -e "$repopath$checkout_dir.fossil" ]; then
echo "A repository named $checkout_dir.fossil already exists" 1>&2
exit 1
else
# Check if proposed checkout directory already exists. Mkdir if necessary and cd into it.
if [[ ! -d $checkout_dir ]]; then
mkdir $checkout_dir
fi
if [ "$icon" = "yes" ]; then
if [ "$kicad" = "yes" ]; then
fileicon set $checkout_dir $kicadicon
else
fileicon set $checkout_dir $defaulticon
fi
fi
cd $checkout_dir
fossil new $repopath$checkout_dir.fossil >> setup
#Pass the output of this to 'setup' - to record username:password combos within repo. Suitable for 'no security' setup ONLY!
cat setup
username=$(grep -o 'admin-user.*' setup | cut -d ' ' -f 2)
password=$(grep -o '".*"' setup | sed 's/"//g')
#Edits your .bugwarriorrc file to add a further service to enable issue tracking by Bugwarrior/Taskwarrior"
gsed -i.bkp '/targets = */ s/$/, fossil_'$checkout_dir'/' ~/.bugwarriorrc
echo "" >> ~/.bugwarriorrc
echo "[fossil_$checkout_dir]" >> ~/.bugwarriorrc
echo "service = fossil" >> ~/.bugwarriorrc
echo "url = http://127.0.0.1:8888/$checkout_dir/" >> ~/.bugwarriorrc
echo "username = $username" >> ~/.bugwarriorrc
echo "password = $password" >> ~/.bugwarriorrc
echo "report_id = 1" >> ~/.bugwarriorrc
echo "project_name = $checkout_dir" >> ~/.bugwarriorrc
echo "default_priority = M" >> ~/.bugwarriorrc
if [ "$kicad" = "yes" ]; then
mkdir .fossil-settings
cp ~/.config/fossil/kicad-ignore-glob .fossil-settings/ignore-glob
touch .fossil-settings/ignore-glob.no-warn
mkdir BOM
touch BOM/BOM_Notes.txt
mkdir Rule_Checks
touch Rule_Checks/Notes.txt
mkdir Rule_Checks/ERC
touch Rule_Checks/ERC/ERC_Notes.txt
mkdir Rule_Checks/DRC
touch Rule_Checks/DRC/DRC_Notes.txt
mkdir Code
touch Code/Code_Notes.txt
mkdir Datasheets
touch Datasheets/Datasheets_Notes.txt
mkdir Documentation
touch Documentation/Documentation_Notes.txt
mkdir Mechanical_3D
touch Mechanical_3D/Notes.txt
mkdir Fabrication
touch Fabrication/Notes.txt
mkdir lib
touch lib/Library_Notes.txt
mkdir Plots
touch Plots/Plot_Notes.txt
mkdir Renders
touch Renders/Render_Notes.txt
mkdir Simulation
touch Simulation/Simulation_Notes.txt
mkdir Fabrication/Gerbers
touch Fabrication/Gerbers/Gerber_Notes.txt
mkdir lib/symbols
touch lib/symbols/Library_symbols_Notes.txt
mkdir lib/footprints
touch lib/footprints/Library_footprints_Notes.txt
mkdir lib/packages3D
touch lib/packages3D/Library_3D_Notes.txt
cp $DEFAULT_REPO/bom.ini bom.ini
touch ReadMe.md
printf > ReadMe.md "<H1> Project: $checkout_dir </H1>\n<H2>Wiki Home Page</H2> \n <p>See [the wiki formatting rules](https://www.fossil-scm.org/xfer/wiki_rules)<p>"
fossil sqlite "insert or replace into config values ('index-page', '/doc/tip/ReadMe.md', 'now');" -R "$repopath$checkout_dir.fossil" >/dev/null
fi
fossil sqlite "insert or replace into config values ('project-name', '$checkout_dir', 'now' );" -R "$repopath$checkout_dir.fossil" >/dev/null
fossil open $repopath$checkout_dir.fossil --force
fossil add * --dotfiles
fossil commit -m "$checkout_dir.fossil repository initialised by Fossilize"
fossil branch new development trunk
fossil update development
read -p "A web page will now open in the default browser. Check permissions required. Press return to continue" $9
fossil ui &
exit 0
fi