File: make-firmware-image

package info (click to toggle)
debian-cd 3.1.13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,244 kB
  • sloc: sh: 4,925; perl: 3,730; makefile: 387
file content (42 lines) | stat: -rwxr-xr-x 1,078 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

# Work out which firmware files to include in the image
# Several steps:
#
# 1. Look for packages which contain "firmware" or "microcode" in their package names
# 2. Check each of those packages to see if they contain files in /lib/firmware
# 3. For those that do, add them into the firmware temp tree
# 4. Make images (tar.gz, zip) of that tree

set -e

MIRROR=$1
SUITE=$2
TMPDIR=$3
export LC_ALL=C

if [ "$MIRROR"x = ""x ] || \
	[ "$SUITE"x = ""x ] || \
	[ "$TMPDIR"x = ""x ] ; then
	echo "$0: Need parameters"
	exit 1
fi

rm -rf $TMPDIR/firmware
mkdir -p $TMPDIR/firmware

FILES=`zcat ${MIRROR}/dists/${SUITE}/*/binary-*/Packages.gz | \
    grep-dctrl -Pe '.*(firmware|microcode).*' -s Filename -n | sort -u`

for FILE in $FILES; do
    # Don't use "grep -q" here, it causes errors from tar
    if (dpkg --contents ${MIRROR}/${FILE} | grep " ./lib/firmware/" >/dev/null) ; then
        cp ${MIRROR}/${FILE} $TMPDIR/firmware
    fi
done

cd $TMPDIR/firmware
tar czf ../firmware.tar.gz .
zip -9rq ../firmware.zip .
cd ..
ls -l $PWD/firmware.tar.gz $PWD/firmware.zip