-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_footprints_list.sh
33 lines (26 loc) · 1.15 KB
/
gen_footprints_list.sh
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
#!/bin/bash
# Retrieve the script path
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
# Define the source and destination paths
clone_path="$SCRIPTPATH/footprints"
output_path="$SCRIPTPATH/footprints.txt"
# Clone the latest KiCAD footprints from repository if not already present
if [ ! -d "$clone_path" ]; then
git clone --depth 1 https://gitlab.com/kicad/libraries/kicad-footprints.git "$clone_path"
else
cd "$clone_path"
git pull
cd "$SCRIPTPATH"
fi
# Empty the output file
> "$output_path"
# Put a header in the output file
echo "# This file contains all the KiCad footprints available in the official library" >> "$output_path"
echo "# Generated by footprints.sh" >> "$output_path"
echo "# on $(date)" >> "$output_path"
# Generate the text file with all footprints, we only want the path relative to the clone path
# Also we want to remove the .kicad_mod and .pretty extensions
# And replace the slash with a : to follow the KiCad convention
find "$clone_path" -type f -name "*.kicad_mod" | sed "s|$clone_path/||" | sed "s|.kicad_mod||" | sed "s|.pretty||" | sed "s|/|:|" >> "$output_path"
echo "Found $(wc -l < "$output_path") footprints"