/[sudobot]/trunk/scripts/build-extensions.sh
ViewVC logotype

Annotation of /trunk/scripts/build-extensions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 624 - (hide annotations)
Fri Aug 30 10:10:33 2024 UTC (7 months ago) by rakinar2
File MIME type: application/x-sh
File size: 4246 byte(s)
chore(extensions): fixup build process
1 rakinar2 575 #!/bin/bash
2    
3 rakinar2 624 dir="."
4    
5     if [ ! -z "$1" ]; then
6     dir="$1"
7     fi
8    
9     extensions=$(find $dir -maxdepth 1 -type d -not -wholename $dir -not -name . -not -name .git -not -name .extbuild -not -name .extbuilds)
10 rakinar2 575 failed_builds=()
11     extbuilds_final_dir=$(pwd)/.extbuilds
12    
13     for extension in $extensions; do
14     name=$(basename $extension)
15 rakinar2 624 echo "PROCESS $name"
16 rakinar2 575
17     cd $extension
18     echo "PWD $(pwd)"
19    
20     if [ ! -f extension.json ]; then
21     echo "No metadata found for extension: $name"
22     failed_builds+=($name)
23     continue
24     fi
25    
26     metadata=$(cat extension.json)
27     main_directory=$(echo $metadata | jq -r '.main_directory')
28     build_command=$(echo $metadata | jq -r '.build_command')
29     resources=$(echo $metadata | jq -r '.resources')
30     version=$(cat package.json | jq -r '.version')
31    
32     npm install -D
33    
34 rakinar2 624 if [ -z "$BUN" ] || [ "$BUN" != "1" ]; then
35     echo "PREPARE $name"
36     rm -f "tsconfig.json"
37     ln -s "tsconfig.node.json" "tsconfig.json"
38     else
39     echo "Bun extension build with this script is not supported yet"
40     continue
41     fi
42    
43 rakinar2 575 if [ $? -eq 0 ]; then
44     if [ -z "$build_command" ] || test "$build_command" = "null"; then
45     echo "NOBUILD $name"
46     else
47 rakinar2 624 echo "BUILD $name"
48 rakinar2 575 eval $build_command
49    
50     if [ $? -ne 0 ]; then
51     echo "FAIL $name"
52     failed_builds+=($name)
53     continue
54     fi
55     fi
56     fi
57    
58     if [ $? -ne 0 ]; then
59     echo "FAIL $name"
60     failed_builds+=($name)
61     else
62     echo "PACKAGE $name"
63     root="${name}-${version}"
64     extbuild_dir=".extbuild/$root"
65    
66     echo "MKDIR $extbuild_dir"
67     mkdir -p $extbuild_dir/$main_directory
68     echo "COPY $main_directory/* $extbuild_dir/$main_directory"
69     cp -r $main_directory/* $extbuild_dir/$main_directory
70     echo "COPY package.json $extbuild_dir"
71     cp package.json $extbuild_dir
72     echo "COPY extension.json $extbuild_dir"
73     cp extension.json $extbuild_dir
74     echo "COPY $resources/ $extbuild_dir"
75     cp -r $resources/ $extbuild_dir
76    
77     if [ -f README.md ]; then
78     echo "COPY README.md $extbuild_dir"
79     cp README.md $extbuild_dir
80     fi
81    
82     if [ -f README ]; then
83     echo "COPY README $extbuild_dir"
84     cp README $extbuild_dir
85     fi
86    
87     if [ -f LICENSE ]; then
88     echo "COPY LICENSE $extbuild_dir"
89     cp LICENSE $extbuild_dir
90     fi
91    
92     echo "TAR $root.tar.gz"
93     cd .extbuild
94     tar -czvf $root.tar.gz $root
95     mv $root.tar.gz ..
96     cd ..
97    
98     if [ $? -ne 0 ]; then
99     echo "FAIL $name"
100     failed_builds+=($name)
101     else
102     echo "SUCCESS $name"
103     mkdir -p "$extbuilds_final_dir/$name"
104     count=1
105    
106     if [ -e "$extbuilds_final_dir/$name/$root.tar.gz" ]; then
107     while [ -e "$extbuilds_final_dir/$name/$root-$count.tar.gz" ]; do
108     ((count++))
109     done
110    
111     prevcount=$((count - 1))
112    
113     sum1=$(tarsum "$root.tar.gz")
114     sum2=$(tarsum "$extbuilds_final_dir/$name/$root-$prevcount.tar.gz")
115    
116     if [ -e "$extbuilds_final_dir/$name/$root-$prevcount.tar.gz" ] && test "$sum1" = "$sum2"; then
117     ((count--))
118     fi
119    
120     sum2=$(tarsum "$extbuilds_final_dir/$name/$root.tar.gz")
121    
122     if [ $count -eq 1 ] && test "$sum1" = "$sum2"; then
123     count=""
124     else
125     count="-$count"
126     fi
127     else
128     count=""
129     fi
130    
131     if [ ! -e "$extbuilds_final_dir/$name/$root$count.tar.gz" ]; then
132     mv "$root.tar.gz" "$extbuilds_final_dir/$name/$root$count.tar.gz"
133     echo "SAVE $root$count.tar.gz"
134     else
135     echo "SKIP $root$count.tar.gz"
136     rm "$root.tar.gz"
137     fi
138     fi
139     fi
140    
141     cd ..
142     done
143    
144     if [ ${#failed_builds[@]} -eq 0 ]; then
145     echo "All extensions built successfully"
146     else
147     echo "Failed to build extensions: ${failed_builds[@]}"
148     exit 1
149     fi

Properties

Name Value
svn:executable *

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26