-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-provide-bndtools-release-jars.sh
executable file
·56 lines (41 loc) · 1.58 KB
/
02-provide-bndtools-release-jars.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# File containing the list of URLs
tag_list=".tags.list"
# Directory to store the downloaded files
download_dir=".download"
# Base directory to store the extracted files
base_dir="site"
base_url="https://bndtools.jfrog.io/artifactory/update-latest/org/bndtools/org.bndtools.p2/"
# Create the directories if they don't exist
mkdir -p "$download_dir"
mkdir -p "$base_dir"
# Read the file line by line
while IFS= read -r tag; do
version=${tag/.REL/}
# Extract the file name from the URL
filename=org.bndtools.p2-${version}.jar
# Create a subfolder for the version
version_dir="$base_dir/$version"
# Check if the version folder already exists
if [ -d "$version_dir" ]; then
echo "Version $version already exists, skipping download."
else
# Download the file into the download directory
curl -o "$download_dir/$filename" "$base_url/$version/$filename"
# Create the version directory
mkdir -p "$version_dir"
# Extract the JAR file into the version directory
unzip "$download_dir/$filename" -d "$version_dir"
fi
done < "$tag_list"
# Create the index.html file
index_file="$base_dir/p2.html"
echo "<html><body><h1>Release Directories</h1><ul>" > "$index_file"
# List each version directory and its size
for dir in "$base_dir"/*/; do
version=$(basename "$dir")
size=$(du -sh "$dir" | cut -f1)
echo "<li><a href="$version">$version</a> - $size</li>" >> "$index_file"
done
echo "</ul></body></html>" >> "$index_file"
echo "Download and extraction complete. Index file created at $index_file."