Browse Source

add linux-libre deblob scripts

parazyd 2 years ago
parent
commit
5e62a9ea06
3 changed files with 12065 additions and 0 deletions
  1. 3174 0
      deblob-4.4
  2. 8580 0
      deblob-check
  3. 311 0
      deblob-main

File diff suppressed because it is too large
+ 3174 - 0
deblob-4.4


File diff suppressed because it is too large
+ 8580 - 0
deblob-check


+ 311 - 0
deblob-main

@@ -0,0 +1,311 @@
1
+#! /bin/sh
2
+
3
+# Copyright (C) 2008-2014 Alexandre Oliva <lxoliva@fsfla.org>
4
+
5
+# This program is part of GNU Linux-libre, a GNU project that
6
+# publishes scripts to clean up Linux so as to make it suitable for
7
+# use in the GNU Project and in Free System Distributions.
8
+
9
+# This program is free software; you can redistribute it and/or modify
10
+# it under the terms of the GNU General Public License as published by
11
+# the Free Software Foundation; either version 2 of the License, or
12
+# (at your option) any later version.
13
+
14
+# This program is distributed in the hope that it will be useful, but
15
+# WITHOUT ANY WARRANTY; without even the implied warranty of
16
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
+# General Public License for more details.
18
+
19
+# You should have received a copy of the GNU General Public License
20
+# along with this program; if not, write to the Free Software
21
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22
+# USA
23
+
24
+# deblob-main - prepare a GNU Linux-libre tarball out of a non-libre
25
+# Linux tarball.  It expects the Linux release (mver, say 3.0) as the
26
+# first argument, the gnu sub-release (extra) as the second optional
27
+# argument, and the patch release (sver, say .13) as an optional third
28
+# argument.  mver and sver are pasted together to form kver.
29
+
30
+# linux-$kver.tar.bz2 and deblob-$mver must exist in the current
31
+# directory, and the line that sets kver and extra in deblob-$mver
32
+# must match mver and extra.
33
+
34
+# The resulting tarball is put in linux-libre-$kver-gnu$extra.tar.bz2.
35
+# An uncompressed xdelta that produces linux-libre-$kver-gnu$extra.tar
36
+# out of linux-$kver.tar is put in linux-libre-$kver-gnu$extra.xdelta.
37
+# This xdelta can be distributed to enable third parties to easily
38
+# reconstruct the binary tarball starting out of sources downloaded
39
+# from kernel.org, but without distributing non-Free Software
40
+# yourself, because xdelta (unlike patches) is not reversible: the
41
+# removed bits are not present in it at all.
42
+
43
+# xdelta version 3 uses different command line syntax, and it switched
44
+# to the more standardized but less efficient vcdiff file format.
45
+# This script will also produce a vcdiff file if xdelta3 is present,
46
+# and it expects the xdelta program to use the version 1 syntax.
47
+
48
+# To enable you to check the differences between the tarballs, a patch
49
+# file is generated in linux-libre-$kver-gnu$extra.patch.  This patch
50
+# file contains the non-Free blobs, even though in reversed form, so
51
+# its distribution is discouraged.
52
+
53
+# The tar files and binary deltas are finally compressed with bzip2,
54
+# and optionally with lzip and xz too, if the compressors are
55
+# available.
56
+
57
+# At the end, the script attempts to generate a digital signature for
58
+# the newly-created tarball.  This is the last thing the script does,
59
+# so interrupting it at that point to skip the signing won't fail to
60
+# do anything else.
61
+
62
+# It is safe to interrupt the script at any other point.  When it gets
63
+# a ^C (other than during signing), it starts cleaning up all of its
64
+# temporary and output files.  If you insist, it may leave junk
65
+# behind, and then it will refuse to run again before you clean it up
66
+# by hand.  It takes extra care to avoid overwriting useful files.
67
+
68
+# If deblob-$mver finds any unexpected situation, it will error out,
69
+# and then deblob-main will quit.  Pass --force to deblob-main, before
70
+# any other argument, for deblob-main to ignore any such situations.
71
+
72
+case $1 in
73
+--force) force=--force; shift;;
74
+*) force=;;
75
+esac
76
+
77
+# We don't want e.g. diff output translations to affect us.
78
+LC_ALL=C; export LC_ALL
79
+LANGUAGE=C; export LANGUAGE
80
+
81
+mver=$1 extra=$2 sver=$3
82
+kver=$mver$sver gnu=gnu$extra
83
+deblob= dir=`echo "$0" | sed 's,[^/]*$,,;s,^$,.,;s,/*$,,'`
84
+
85
+if test -f linux-$kver.tar; then
86
+  zext=tar     zcmd=
87
+elif test -f linux-$kver.tar.bz2; then
88
+  zext=tar.bz2 zcmd=bunzip2
89
+elif test -f linux-$kver.tar.xz; then
90
+  zext=tar.xz  zcmd=unxz
91
+elif test -f linux-$kver.tar.lz; then
92
+  zext=tar.lz  zcmd="lzip -d"
93
+elif test -f linux-$kver.tar.gz; then
94
+  zext=tar.gz  zcmd=gunzip
95
+elif test -f linux-$kver.tgz; then
96
+  zext=tgz     zcmd=gunzip
97
+else
98
+  echo linux-$kver.tar not found, tried .bz2, .xz, .lz, .gz and .tgz too >&2
99
+  exit 1
100
+fi
101
+
102
+if test -f deblob-$mver; then
103
+  deblob=deblob-$mver
104
+elif test -f deblob; then
105
+  deblob=deblob
106
+elif test -f $dir/deblob-$mver; then
107
+  cp $dir/deblob-$mver deblob
108
+  deblob=deblob
109
+else
110
+  echo deblob does not exist >&2
111
+  exit 1
112
+fi
113
+
114
+x1="kver=$mver extra=$extra"
115
+x2=`grep "^kver=[^ ]* extra=" $deblob`
116
+if test "$x1" = "$x2"; then
117
+  :
118
+else
119
+  echo deblob script does not match command-line arguments >&2
120
+  echo expected: $x1 >&2
121
+  echo found   : $x2 >&2
122
+  exit 1
123
+fi
124
+
125
+cleanup=
126
+
127
+for f in \
128
+  linux-libre-$kver-$gnu.tar.bz2 \
129
+  linux-libre-$kver-$gnu.tar.bz2.asc \
130
+  linux-libre-$kver-$gnu.tar.bz2.sign \
131
+  linux-libre-$kver-$gnu.tar.xz \
132
+  linux-libre-$kver-$gnu.tar.xz.asc \
133
+  linux-libre-$kver-$gnu.tar.xz.sign \
134
+  linux-libre-$kver-$gnu.tar.lz \
135
+  linux-libre-$kver-$gnu.tar.lz.asc \
136
+  linux-libre-$kver-$gnu.tar.lz.sign \
137
+  linux-libre-$kver-$gnu.tar \
138
+  linux-libre-$kver-$gnu.tar.asc \
139
+  linux-libre-$kver-$gnu.tar.sign \
140
+  linux-libre-$kver-$gnu.patch \
141
+  linux-libre-$kver-$gnu.log \
142
+  linux-libre-$kver-$gnu.vcdiff \
143
+  linux-libre-$kver-$gnu.vcdiff.bz2 \
144
+  linux-libre-$kver-$gnu.vcdiff.bz2.asc \
145
+  linux-libre-$kver-$gnu.vcdiff.bz2.sign \
146
+  linux-libre-$kver-$gnu.vcdiff.xz \
147
+  linux-libre-$kver-$gnu.vcdiff.xz.asc \
148
+  linux-libre-$kver-$gnu.vcdiff.xz.sign \
149
+  linux-libre-$kver-$gnu.vcdiff.lz \
150
+  linux-libre-$kver-$gnu.vcdiff.lz.asc \
151
+  linux-libre-$kver-$gnu.vcdiff.lz.sign \
152
+  linux-libre-$kver-$gnu.xdelta \
153
+  linux-libre-$kver-$gnu.xdelta.bz2 \
154
+  linux-libre-$kver-$gnu.xdelta.bz2.asc \
155
+  linux-libre-$kver-$gnu.xdelta.bz2.sign \
156
+  linux-libre-$kver-$gnu.xdelta.xz \
157
+  linux-libre-$kver-$gnu.xdelta.xz.asc \
158
+  linux-libre-$kver-$gnu.xdelta.xz.sign \
159
+  linux-libre-$kver-$gnu.xdelta.lz \
160
+  linux-libre-$kver-$gnu.xdelta.lz.asc \
161
+  linux-libre-$kver-$gnu.xdelta.lz.sign \
162
+; do
163
+  if test -f $f; then
164
+    echo $f already exists >&2
165
+    exit 1
166
+  fi
167
+  cleanup="$cleanup $f"
168
+done
169
+
170
+for d in \
171
+  linux-$kver \
172
+  linux-libre-$kver-$gnu \
173
+  orig-linux-$kver \
174
+; do
175
+  if test -d $d; then
176
+    echo $d already exists >&2
177
+    exit 1
178
+  fi
179
+  cleanup="$cleanup $d"
180
+done
181
+
182
+if test -f $dir/deblob-$kver; then
183
+  if cmp $dir/deblob-$kver $deblob; then
184
+    :
185
+  else
186
+    echo $dir/deblob-$kver and $deblob are different >&2
187
+    exit 1
188
+  fi
189
+fi
190
+
191
+if test ! -f deblob-check; then
192
+  if test -f $dir/deblob-check; then
193
+    cp $dir/deblob-check deblob-check
194
+  fi
195
+else
196
+  if test -f $dir/deblob-check; then
197
+    if cmp $dir/deblob-check deblob-check; then
198
+      :
199
+    else
200
+      echo $dir/deblob-check and deblob-check are different >&2
201
+      exit 1
202
+    fi
203
+  fi
204
+fi
205
+
206
+trap 'status=$?; echo cleaning up...; rm -rf $cleanup; (exit $status); exit' 0 1 2 15
207
+
208
+set -e
209
+
210
+if test -n "$zcmd"; then
211
+  echo Uncompressing linux-$kver.$zext into linux-$kver.tar
212
+  rm -rf linux-$kver.tar
213
+  cleanup="$cleanup linux-$kver.tar"
214
+  $zcmd < linux-$kver.$zext > linux-$kver.tar
215
+fi
216
+
217
+echo Extracting linux-$kver.tar into linux-$kver
218
+rm -rf linux-$kver
219
+tar -xf linux-$kver.tar
220
+rm -rf linux-libre-$kver-$gnu linux-libre-$kver-$gnu.tar
221
+
222
+echo Copying linux-$kver to linux-libre-$kver-$gnu
223
+cp linux-$kver.tar linux-libre-$kver-$gnu.tar
224
+cp -lR linux-$kver/. linux-libre-$kver-$gnu
225
+
226
+rm -f linux-libre-$kver-$gnu.log linux-libre-$kver-$gnu.log.tmp
227
+echo Deblobbing within linux-libre-$kver-$gnu, saving output to linux-libre-$kver-$gnu.log
228
+# We can't just pipe deblob into tee, for then we fail to detect
229
+# error conditions.  Use file renaming to tell whether we succeeded.
230
+if (cd linux-libre-$kver-$gnu && /bin/sh ../$deblob $force) 2>&1; then
231
+  mv linux-libre-$kver-$gnu.log.tmp linux-libre-$kver-$gnu.log
232
+fi | tee linux-libre-$kver-$gnu.log.tmp
233
+if test ! -f linux-libre-$kver-$gnu.log; then
234
+  mv linux-libre-$kver-$gnu.log.tmp linux-libre-$kver-$gnu.log
235
+  echo $deblob failed, aborting >&2
236
+  exit 1
237
+fi
238
+rm -f linux-libre-$kver-$gnu.patch
239
+
240
+# Do not copy these scripts for now, deblob-check regards itself as a blob.
241
+# cp -p $0 $deblob deblob-check linux-libre-$kver-$gnu
242
+
243
+echo Generating linux-libre-$kver-$gnu.patch
244
+diff -druN linux-$kver linux-libre-$kver-$gnu > linux-libre-$kver-$gnu.patch || :
245
+
246
+echo Removing removed or modified files from linux-libre-$kver-$gnu.tar
247
+diff -rq linux-$kver linux-libre-$kver-$gnu |
248
+sed -n "
249
+  s,^Only in \\(linux-$kver\\(/.*\\)\\?\\): \\(.*\\),\1/\3,p;
250
+  s,^Files \\(linux-$kver\\)/\\(.*\\) and linux-libre-$kver-$gnu/\\2 differ,\\1/\\2,p;
251
+" |
252
+xargs tar --delete -f linux-libre-$kver-$gnu.tar
253
+
254
+echo Adding modified or added files to linux-libre-$kver-$gnu.tar
255
+rm -rf orig-linux-$kver
256
+mv linux-$kver orig-linux-$kver
257
+mv linux-libre-$kver-$gnu linux-$kver
258
+diff -rq orig-linux-$kver linux-$kver |
259
+sed -n "
260
+  s,^Files orig-\\(linux-$kver/.*\\) and \\1 differ,\\1,p;
261
+  s,^Only in \\(linux-$kver\\(/.*\\)\\?\\): \\(.*\\),\\1/\\3,p;
262
+" |
263
+xargs tar --append -f linux-libre-$kver-$gnu.tar
264
+
265
+echo Wiping out extracted trees
266
+rm -rf linux-$kver orig-linux-$kver
267
+
268
+echo Creating vcdiff between linux-$kver.tar and linux-libre-$kver-$gnu.tar
269
+xdelta3 -e -9 -S djw -s linux-$kver.tar linux-libre-$kver-$gnu.tar linux-libre-$kver-$gnu.vcdiff || : # don't fail if xdelta3 is not present
270
+
271
+echo Creating xdelta between linux-$kver.tar and linux-libre-$kver-$gnu.tar
272
+xdelta delta -0 linux-$kver.tar linux-libre-$kver-$gnu.tar linux-libre-$kver-$gnu.xdelta || : # xdelta returns nonzero on success
273
+
274
+cleanup="linux-libre-$kver-$gnu.tar linux-libre-$kver-$gnu.xdelta"
275
+
276
+echo Compressing binary deltas and linux-libre-$kver-$gnu.tar
277
+rm -f linux-$kver.tar
278
+if test -f linux-libre-$kver-$gnu.xdelta; then
279
+  bzip2 -k9 linux-libre-$kver-$gnu.xdelta
280
+  xz -k9 linux-libre-$kver-$gnu.xdelta || :
281
+  lzip -k9 linux-libre-$kver-$gnu.xdelta || :
282
+fi
283
+bzip2 -k9 linux-libre-$kver-$gnu.tar
284
+xz -k9 linux-libre-$kver-$gnu.tar || :
285
+lzip -k9 linux-libre-$kver-$gnu.tar || :
286
+
287
+echo Done except for signing, feel free to interrupt
288
+for f in \
289
+  linux-libre-$kver-$gnu.tar \
290
+  linux-libre-$kver-$gnu.tar.bz2 \
291
+  linux-libre-$kver-$gnu.tar.xz \
292
+  linux-libre-$kver-$gnu.tar.lz \
293
+  linux-libre-$kver-$gnu.vcdiff \
294
+  linux-libre-$kver-$gnu.xdelta \
295
+  linux-libre-$kver-$gnu.xdelta.bz2 \
296
+  linux-libre-$kver-$gnu.xdelta.xz \
297
+  linux-libre-$kver-$gnu.xdelta.lz \
298
+; do
299
+  if test -f $f; then
300
+    gpg -a --detach-sign $f
301
+    mv $f.asc $f.sign
302
+  fi
303
+done
304
+
305
+rm -f $cleanup
306
+cleanup=
307
+trap 'status=$?; (exit $status); exit' 0 1 2 15
308
+
309
+echo All set, please review linux-libre-$kver-$gnu.patch
310
+
311
+exit 0