summaryrefslogtreecommitdiffstats
path: root/resources/scripts/helpers/build/release/util
blob: 5f25de56f2a87e78904c0c54ed7dbb4024e4c0de (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
#!/bin/bash

#
#  helper script: generate the release archives
#
#	Copyright (C) 2014, 2015, 2016 Leah Rowe <info@minifree.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script assumes that the current working directory when running
# it is the root directory of the libreboot git repository clone.

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

arch="unknown"
if [ "$(uname -i)" = "i686" ] || [ "$(uname -m)" = "i686" ]
	then
		arch="i686"
		echo "Running on i686. ok."
		sleep 2
elif [ "$(uname -i)" = "x86_64" ] || [ "$(uname -m)" = "x86_64" ]
	then
		arch="x86_64"
		echo "Running on x86_64. ok."
		sleep 2
else
	echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
	exit 1
fi

if [ -f "version" ]; then
	# _src release archive is being used
	version="$(cat version)"
	versiondate="$(cat versiondate)"
else
	# git repo is being used
	version="$(git describe --tags HEAD)"
	versiondate="$(git show -s --format=%ct)"
fi
versiondir="release/${version}"
distname="libreboot_${version}_util"
distdir="${versiondir}/${distname}"

printf "Creating utility archive (source code of commonly needed utilities)\n"

# delete the old data
rm -Rf "${distdir:?}/"
rm -f "${distdir}.tar.xz"

# this is where they will go
mkdir -p "${distdir}/"

# this has to be done before generating
# the "version" file
if [ ! -f "version" ]; then
	# generate ChangeLog and NEWS files
	rm -f "ChangeLog" "NEWS"
	git log > "${distdir}/ChangeLog"
	cp "${distdir}/ChangeLog" "${distdir}/NEWS"
else
	# building from release archive
	cp "ChangeLog" "${distdir}/"
	cp "NEWS" "${distdir}/"
fi

# include version information
printf '%s\n' "${version}" >"${distdir}/version"
# include version date information
printf '%s\n' "${versiondate}" >"${distdir}/versiondate"

# --------------
# BUC.TS related
# --------------
cp -R "bucts" "bucts_/"
mkdir -p "${distdir}/bucts/"
./build clean bucts
cp -R "bucts/" "${distdir}/"
rm -Rf "bucts/"
mv "bucts_/" "bucts/"

# ----------------
# Flashrom related
# ----------------
# Flashrom is used to install libreboot on supported targets
# Include it statically compiled
cp -R "flashrom/" "flashrom_/"
./build clean flashrom
cp -R "flashrom/" "${distdir}/"
rm -Rf "flashrom/"
mv "flashrom_/" "flashrom/"

# -------------
# Miscellaneous
# -------------

cp -R "resources/" "${distdir}/"

# Flashing script
cp "flash" "${distdir}/"

# Build script
cp "build" "${distdir}/"

# powertop script
cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"

printf "\n\n"

# ### Create the release tarballs
# ----------------------------------------------------------------------------------------------------------------------------

printf "Compressing %s/ into %s.tar.xz\n" "${distdir}" "${distdir}.tar.xz"
# create lzma compressed util archive
(cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")

printf "done\n\n"

# ### Delete the uncompressed release directories
# ----------------------------------------------------------------------------------------------------------------------------

# The uncompressed archives are no longer needed
rm -Rf "${distdir:?}/"