blob: 736276b46e24d9a19475eb0d768578075f7218a0 (
plain)
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
|
#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2020,2021,2023 Leah Rowe <leah@libreboot.org>
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
. "include/err.sh"
read projectname < projectname
trees_fetch_list="coreboot u-boot seabios"
simple_fetch_list="flashrom grub memtest86plus me_cleaner uefitool"
simple_fetch_list="${simple_fetch_list} bios_extract biosutilities"
download_only_list="pico-serprog stm32-vserprog"
dirlist="config util script include util-fw"
linklist="build update handle" # symlinks in main directory, to script: lbmk
filelist="lbmk README.md COPYING version versiondate projectname checkgit"
filelist="${filelist} checkversion"
version="version-unknown"
versiondate="version-date-unknown"
eval "$(setvars "" reldir dirname srcdir)"
printf "Building source code archive, version %s\n" "${version}"
main()
{
[ -f version ] && read version < version
[ -f versiondate ] && read versiondate < versiondate
create_release_directory
download_modules
copy_files
purge_files
create_release_archive
printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}"
}
create_release_directory()
{
reldir="release/${version}"
dirname="${projectname}-${version}_src"
srcdir="${reldir}/${dirname}"
[ -d "release/" ] || x_ mkdir -p release/
[ -d "${reldir}/" ] || x_ mkdir -p "${reldir}/"
[ ! -d "${srcdir}/" ] || x_ rm -Rf "${srcdir}/"
[ ! -f "${srcdir}.tar.xz" ] || \
x_ rm -f "${srcdir}.tar.xz/"
x_ mkdir -p "${srcdir}/"
x_ printf "%s" "${version}" > "${srcdir}"/version
}
download_modules()
{
for modname in ${trees_fetch_list}; do
[ -d "${modname}" ] || x_ ./update project trees ${modname}
done
for modname in ${simple_fetch_list} ${download_only_list}; do
[ -d "${modname}/" ] || x_ ./update project repo ${modname}
done
}
copy_files()
{
for dir in ${trees_fetch_list}; do
[ -d "${dir}" ] || continue
for subdir in "${dir}"/*; do
[ -d "${subdir}" ] || continue
[ "${subdir##*/}" = "${dir}" ] && continue
x_ mkdir -p "${srcdir}/${dir}"
[ ! -d "${srcdir}/${dir}/${subdir##*/}" ] || \
x_ rm -Rf "${srcdir}/${dir}/${subdir##*/}"
x_ cp -R "${subdir}" "${srcdir}/${dir}/${subdir##*/}"
done
done
for dir in ${simple_fetch_list} ${dirlist}; do
x_ cp -R "${dir}/" "${srcdir}/"
done
for i in ${filelist}; do
if [ ! -f "${i}" ]; then
x_ rm -Rf "${srcdir}"
err "copy_files: file '${i}' does not exist"
fi
x_ cp "${i}" "${srcdir}/"
done
(
x_ cd "${srcdir}/"
for i in ${linklist}; do
x_ ln -s lbmk "${i}"
done
)
}
purge_files()
{
(
x_ cd "${srcdir}/"
[ ! -d "coreboot/default/util/kbc1126" ] || \
x_ ./handle make file -c "coreboot/default/util/kbc1126"
x_ ./handle make config -x coreboot
for p in u-boot seabios coreboot; do
x_ ./handle make config -c "${p}"
done
for p in bios_extract flashrom grub uefitool; do
x_ ./handle make file -c "${p}"
done
for p in "stm32-vserprog" "stm32-vserprog/libopencm3"; do
x_ ./handle make file -c "util-fw/${p}"
done
for p in 32 64; do
x_ ./handle make file -c "memtest86plus/build${p}"
done
for p in "nvmutil" "spkmodem_recv" "e6400-flash-unlock"; do
x_ make clean -C "util/${p}"
done
for p in ${trees_fetch_list}; do
x_ rm -Rf "${p}/${p}" "${p}"/*/.git*
done
x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
*/*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*
x_ rm -Rf cbutils elf util-fw/rp2040/pico-serprog/build
)
}
create_release_archive()
{
(
x_ cd "${reldir}/"
x_ tar -c "${dirname}/" | xz -T0 -9e >"${dirname}.tar.xz"
x_ rm -Rf "${dirname}/"
)
}
main $@
|