# Copyright (C) 2008, 2009 Alexandre Oliva <lxoliva@fsfla.org>
# Copyright (C) 2008 Jeff Moe
+# Copyright (C) 2009 Rubén Rodríguez <ruben@gnu.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
# For each kver release, start extra with an empty string, then count
# from 1 if changes are needed that require rebuilding the tarball.
-kver=2.6.27 extra=2
-
-fatal () {
- echo "$@"
- exit 1
-}
+kver=2.6.27 extra=2++
case $1 in
---force) die () { echo ERROR: "$@": ignored >&2; }; forced=:; shift;;
-*) die () { fatal "$@"; }; forced=false;;
+--force)
+ echo "WARNING: Using the force, ignored errors will be" >&2
+ die () {
+ echo ERROR: "$@" >&2
+ errors=:
+ }
+ forced=: errors=false
+ shift
+ ;;
+*)
+ die () {
+ echo ERROR: "$@" >&2
+ echo Use --force to ignore
+ exit 1
+ }
+ forced=false errors=false
+ ;;
esac
check=`echo "$0" | sed 's,[^/]*$,,;s,^$,.,;s,/*$,,'`/deblob-check
have_check=:
fi
+filetest () {
+ [ -f $1 ]
+}
+
announce () {
- echo
- echo "$@"
+ echo
+ echo "$@"
}
clean_file () {
- #$1 = filename
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- rm $1
- echo $1: removed
+ #$1 = filename
+ filetest $1 || return
+ rm $1
+ echo $1: removed
}
check_changed () {
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif cmp $1.deblob $1 > /dev/null; then
- die $1 did not change, something is wrong
- fi
- mv $1.deblob $1
+ #$1 = filename
+ if cmp $1.deblob $1 > /dev/null; then
+ rm $1.deblob
+ die $1 did not change, something is wrong && return 1
+ fi
+ mv $1.deblob $1
}
clean_blob () {
- #$1 = filename
- if $have_check; then
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- name=$1
- set fnord "$@" -d
- shift 2
- $check "$@" -i linux-$kver $name > $name.deblob
- echo $name: removed blobs
- check_changed $name
- else
- clean_file $1
- fi
+ #$1 = filename
+ filetest $1 || return
+ if $have_check; then
+ name=$1
+ set fnord "$@" -d
+ shift 2
+ $check "$@" -i linux-$kver $name > $name.deblob
+ check_changed $name && echo $name: removed blobs
+ else
+ clean_file $1
+ fi
}
dummy_blob () {
- #$1 = filename
- if test -f $1; then
- die $1 exists, something is wrong
- elif test ! -f firmware/Makefile; then
- die firmware/Makefile does not exist, something is wrong
- fi
-
- clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
- firmware/Makefile "dropped $1"
+ #$1 = filename
+ if test -f $1; then
+ die $1 exists, something is wrong && return
+ elif test ! -f firmware/Makefile; then
+ die firmware/Makefile does not exist, something is wrong && return
+ fi
+
+ clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
+ firmware/Makefile "dropped $1"
}
clean_fw () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_blob $1 -s 4
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_blob $1 -s 4
+ dummy_blob $2
}
drop_fw_file () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_file $1
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_file $1
+ dummy_blob $2
}
clean_kconfig () {
- #$1 = filename $2 = things to remove
- case $1 in
- -f)
- shift
- ;;
- *)
- if $have_check; then
- return
- fi
- ;;
- esac
- sed "/^config \\($2\\)\$/{p;i\
+ #$1 = filename $2 = things to remove
+ case $1 in
+ -f)
+ shift
+ ;;
+ *)
+ if $have_check; then
+ return
+ fi
+ ;;
+ esac
+ filetest $1 || return
+ sed "/^config \\($2\\)\$/{p;i\
depends on NONFREE
d;}" $1 > $1.deblob
- echo $1: marked config $2 as depending on NONFREE
- check_changed $1
+ check_changed $1 && echo $1: marked config $2 as depending on NONFREE
}
clean_mk () {
- #$1 = config $2 = Makefile name
- # We don't clean up Makefiles any more --lxoliva
- # sed -i "/\\($1\\)/d" $2
- # echo $2: removed $1 support
- # check_changed $2
- if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
- :
- else
- die $2 does not contain matches for $1
- fi
+ #$1 = config $2 = Makefile name
+ # We don't clean up Makefiles any more --lxoliva
+ # sed -i "/\\($1\\)/d" $2
+ # echo $2: removed $1 support
+ # check_changed $2
+ filetest $2 || return
+ if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
+ :
+ else
+ die $2 does not contain matches for $1
+ fi
}
clean_sed () {
- #$1 = sed-script $2 = file $3 = comment
- sed -e "$1" "$2" > "$2".deblob
- echo $2: ${3-applied sed script $1}
- check_changed "$2"
+ #$1 = sed-script $2 = file $3 = comment
+ filetest $2 || return
+ sed -e "$1" "$2" > "$2".deblob
+ check_changed $2 && echo $2: ${3-applied sed script $1}
}
reject_firmware () {
- #$1 = file
- clean_sed '
+ #$1 = file
+ filetest $1 || return
+ clean_sed '
s,request\(_ihex\)\?_firmware\(_nowait\)\?,reject_firmware\2,g
' "$1" 'disabled non-Free firmware-loading machinery'
}
macro=$1 repl=$2 msg=$3; shift 3
for f in "$@"; do
clean_sed "
- s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
- s,$macro,$repl,g;
+s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
+s,$macro,$repl,g;
" "$f" "$msg"
done
}
sound/pci/cs46xx/imgs/cwcdma.asp \
; do
if test ! $f; then
- die $f is not present, something is amiss
+ die $f is not present, something is amiss && return
fi
done
# Identify the tarball.
-clean_sed "
-s,^EXTRAVERSION.*,&-libre$extra,
+grep -q 'EXTRAVERSION.*-libre' Makefile ||
+clean_sed "s,^EXTRAVERSION.*,&-libre$extra,
" Makefile 'added -libre to EXTRAVERSION'
# Add reject_firmware and maybe_reject_firmware
-clean_sed '
-$i\
+grep -q _LINUX_LIBRE_FIRMWARE_H include/linux/firmware.h ||
+clean_sed '$i\
#ifndef _LINUX_LIBRE_FIRMWARE_H\
#define _LINUX_LIBRE_FIRMWARE_H\
\
clean_sed s,usb8388,whatever,g drivers/base/Kconfig 'removed blob name'
clean_blob firmware/WHENCE
+if $errors; then
+ echo errors above were ignored because of --force >&2
+fi
+
exit 0
# Copyright (C) 2008, 2009 Alexandre Oliva <lxoliva@fsfla.org>
# Copyright (C) 2008 Jeff Moe
+# Copyright (C) 2009 Rubén Rodríguez <ruben@gnu.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
# For each kver release, start extra with an empty string, then count
# from 1 if changes are needed that require rebuilding the tarball.
-kver=2.6.28 extra=3
-
-fatal () {
- echo "$@"
- exit 1
-}
+kver=2.6.28 extra=3++
case $1 in
---force) die () { echo ERROR: "$@": ignored >&2; }; forced=:; shift;;
-*) die () { fatal "$@"; }; forced=false;;
+--force)
+ echo "WARNING: Using the force, ignored errors will be" >&2
+ die () {
+ echo ERROR: "$@" >&2
+ errors=:
+ }
+ forced=: errors=false
+ shift
+ ;;
+*)
+ die () {
+ echo ERROR: "$@" >&2
+ echo Use --force to ignore
+ exit 1
+ }
+ forced=false errors=false
+ ;;
esac
check=`echo "$0" | sed 's,[^/]*$,,;s,^$,.,;s,/*$,,'`/deblob-check
have_check=:
fi
+filetest () {
+ [ -f $1 ]
+}
+
announce () {
- echo
- echo "$@"
+ echo
+ echo "$@"
}
clean_file () {
- #$1 = filename
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- rm $1
- echo $1: removed
+ #$1 = filename
+ filetest $1 || return
+ rm $1
+ echo $1: removed
}
check_changed () {
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif cmp $1.deblob $1 > /dev/null; then
- die $1 did not change, something is wrong
- fi
- mv $1.deblob $1
+ #$1 = filename
+ if cmp $1.deblob $1 > /dev/null; then
+ rm $1.deblob
+ die $1 did not change, something is wrong && return 1
+ fi
+ mv $1.deblob $1
}
clean_blob () {
- #$1 = filename
- if $have_check; then
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- name=$1
- set fnord "$@" -d
- shift 2
- $check "$@" -i linux-$kver $name > $name.deblob
- echo $name: removed blobs
- check_changed $name
- else
- clean_file $1
- fi
+ #$1 = filename
+ filetest $1 || return
+ if $have_check; then
+ name=$1
+ set fnord "$@" -d
+ shift 2
+ $check "$@" -i linux-$kver $name > $name.deblob
+ check_changed $name && echo $name: removed blobs
+ else
+ clean_file $1
+ fi
}
dummy_blob () {
- #$1 = filename
- if test -f $1; then
- die $1 exists, something is wrong
- elif test ! -f firmware/Makefile; then
- die firmware/Makefile does not exist, something is wrong
- fi
-
- clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
- firmware/Makefile "dropped $1"
+ #$1 = filename
+ if test -f $1; then
+ die $1 exists, something is wrong && return
+ elif test ! -f firmware/Makefile; then
+ die firmware/Makefile does not exist, something is wrong && return
+ fi
+
+ clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
+ firmware/Makefile "dropped $1"
}
clean_fw () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_blob $1 -s 4
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_blob $1 -s 4
+ dummy_blob $2
}
drop_fw_file () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_file $1
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_file $1
+ dummy_blob $2
}
clean_kconfig () {
- #$1 = filename $2 = things to remove
- case $1 in
- -f)
- shift
- ;;
- *)
- if $have_check; then
- return
- fi
- ;;
- esac
- sed "/^config \\($2\\)\$/{p;i\
+ #$1 = filename $2 = things to remove
+ case $1 in
+ -f)
+ shift
+ ;;
+ *)
+ if $have_check; then
+ return
+ fi
+ ;;
+ esac
+ filetest $1 || return
+ sed "/^config \\($2\\)\$/{p;i\
depends on NONFREE
d;}" $1 > $1.deblob
- echo $1: marked config $2 as depending on NONFREE
- check_changed $1
+ check_changed $1 && echo $1: marked config $2 as depending on NONFREE
}
clean_mk () {
- #$1 = config $2 = Makefile name
- # We don't clean up Makefiles any more --lxoliva
- # sed -i "/\\($1\\)/d" $2
- # echo $2: removed $1 support
- # check_changed $2
- if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
- :
- else
- die $2 does not contain matches for $1
- fi
+ #$1 = config $2 = Makefile name
+ # We don't clean up Makefiles any more --lxoliva
+ # sed -i "/\\($1\\)/d" $2
+ # echo $2: removed $1 support
+ # check_changed $2
+ filetest $2 || return
+ if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
+ :
+ else
+ die $2 does not contain matches for $1
+ fi
}
clean_sed () {
- #$1 = sed-script $2 = file $3 = comment
- sed -e "$1" "$2" > "$2".deblob
- echo $2: ${3-applied sed script $1}
- check_changed "$2"
+ #$1 = sed-script $2 = file $3 = comment
+ filetest $2 || return
+ sed -e "$1" "$2" > "$2".deblob
+ check_changed $2 && echo $2: ${3-applied sed script $1}
}
reject_firmware () {
- #$1 = file
- clean_sed '
+ #$1 = file
+ filetest $1 || return
+ clean_sed '
s,request\(_ihex\)\?_firmware\(_nowait\)\?,reject_firmware\2,g
' "$1" 'disabled non-Free firmware-loading machinery'
}
macro=$1 repl=$2 msg=$3; shift 3
for f in "$@"; do
clean_sed "
- s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
- s,$macro,$repl,g;
+s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
+s,$macro,$repl,g;
" "$f" "$msg"
done
}
sound/pci/cs46xx/imgs/cwcdma.asp \
; do
if test ! $f; then
- die $f is not present, something is amiss
+ die $f is not present, something is amiss && return
fi
done
# Identify the tarball.
-clean_sed "
-s,^EXTRAVERSION.*,&-libre$extra,
+grep -q 'EXTRAVERSION.*-libre' Makefile ||
+clean_sed "s,^EXTRAVERSION.*,&-libre$extra,
" Makefile 'added -libre to EXTRAVERSION'
# Add reject_firmware and maybe_reject_firmware
-clean_sed '
-$i\
+grep -q _LINUX_LIBRE_FIRMWARE_H include/linux/firmware.h ||
+clean_sed '$i\
#ifndef _LINUX_LIBRE_FIRMWARE_H\
#define _LINUX_LIBRE_FIRMWARE_H\
\
clean_sed s,usb8388,whatever,g drivers/base/Kconfig 'removed blob name'
clean_blob firmware/WHENCE
+if $errors; then
+ echo errors above were ignored because of --force >&2
+fi
+
exit 0
# Copyright (C) 2008, 2009 Alexandre Oliva <lxoliva@fsfla.org>
# Copyright (C) 2008 Jeff Moe
+# Copyright (C) 2009 Rubén Rodríguez <ruben@gnu.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
# from 1 if changes are needed that require rebuilding the tarball.
kver=2.6.29 extra=1++
-fatal () {
- echo "$@"
- exit 1
-}
-
case $1 in
---force) die () { echo ERROR: "$@": ignored >&2; }; forced=:; shift;;
-*) die () { fatal "$@"; }; forced=false;;
+--force)
+ echo "WARNING: Using the force, ignored errors will be" >&2
+ die () {
+ echo ERROR: "$@" >&2
+ errors=:
+ }
+ forced=: errors=false
+ shift
+ ;;
+*)
+ die () {
+ echo ERROR: "$@" >&2
+ echo Use --force to ignore
+ exit 1
+ }
+ forced=false errors=false
+ ;;
esac
check=`echo "$0" | sed 's,[^/]*$,,;s,^$,.,;s,/*$,,'`/deblob-check
have_check=:
fi
+filetest () {
+ [ -f $1 ]
+}
+
announce () {
- echo
- echo "$@"
+ echo
+ echo "$@"
}
clean_file () {
- #$1 = filename
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- rm $1
- echo $1: removed
+ #$1 = filename
+ filetest $1 || return
+ rm $1
+ echo $1: removed
}
check_changed () {
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif cmp $1.deblob $1 > /dev/null; then
- die $1 did not change, something is wrong
- fi
- mv $1.deblob $1
+ #$1 = filename
+ if cmp $1.deblob $1 > /dev/null; then
+ rm $1.deblob
+ die $1 did not change, something is wrong && return 1
+ fi
+ mv $1.deblob $1
}
clean_blob () {
- #$1 = filename
- if $have_check; then
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- name=$1
- set fnord "$@" -d
- shift 2
- $check "$@" -i linux-$kver $name > $name.deblob
- echo $name: removed blobs
- check_changed $name
- else
- clean_file $1
- fi
+ #$1 = filename
+ filetest $1 || return
+ if $have_check; then
+ name=$1
+ set fnord "$@" -d
+ shift 2
+ $check "$@" -i linux-$kver $name > $name.deblob
+ check_changed $name && echo $name: removed blobs
+ else
+ clean_file $1
+ fi
}
dummy_blob () {
- #$1 = filename
- if test -f $1; then
- die $1 exists, something is wrong
- elif test ! -f firmware/Makefile; then
- die firmware/Makefile does not exist, something is wrong
- fi
-
- clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
- firmware/Makefile "dropped $1"
+ #$1 = filename
+ if test -f $1; then
+ die $1 exists, something is wrong && return
+ elif test ! -f firmware/Makefile; then
+ die firmware/Makefile does not exist, something is wrong && return
+ fi
+
+ clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
+ firmware/Makefile "dropped $1"
}
clean_fw () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_blob $1 -s 4
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_blob $1 -s 4
+ dummy_blob $2
}
drop_fw_file () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_file $1
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_file $1
+ dummy_blob $2
}
clean_kconfig () {
- #$1 = filename $2 = things to remove
- case $1 in
- -f)
- shift
- ;;
- *)
- if $have_check; then
- return
- fi
- ;;
- esac
- sed "/^config \\($2\\)\$/{p;i\
+ #$1 = filename $2 = things to remove
+ case $1 in
+ -f)
+ shift
+ ;;
+ *)
+ if $have_check; then
+ return
+ fi
+ ;;
+ esac
+ filetest $1 || return
+ sed "/^config \\($2\\)\$/{p;i\
depends on NONFREE
d;}" $1 > $1.deblob
- echo $1: marked config $2 as depending on NONFREE
- check_changed $1
+ check_changed $1 && echo $1: marked config $2 as depending on NONFREE
}
clean_mk () {
- #$1 = config $2 = Makefile name
- # We don't clean up Makefiles any more --lxoliva
- # sed -i "/\\($1\\)/d" $2
- # echo $2: removed $1 support
- # check_changed $2
- if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
- :
- else
- die $2 does not contain matches for $1
- fi
+ #$1 = config $2 = Makefile name
+ # We don't clean up Makefiles any more --lxoliva
+ # sed -i "/\\($1\\)/d" $2
+ # echo $2: removed $1 support
+ # check_changed $2
+ filetest $2 || return
+ if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
+ :
+ else
+ die $2 does not contain matches for $1
+ fi
}
clean_sed () {
- #$1 = sed-script $2 = file $3 = comment
- sed -e "$1" "$2" > "$2".deblob
- echo $2: ${3-applied sed script $1}
- check_changed "$2"
+ #$1 = sed-script $2 = file $3 = comment
+ filetest $2 || return
+ sed -e "$1" "$2" > "$2".deblob
+ check_changed $2 && echo $2: ${3-applied sed script $1}
}
reject_firmware () {
- #$1 = file
- clean_sed '
+ #$1 = file
+ filetest $1 || return
+ clean_sed '
s,request\(_ihex\)\?_firmware\(_nowait\)\?,reject_firmware\2,g
' "$1" 'disabled non-Free firmware-loading machinery'
}
macro=$1 repl=$2 msg=$3; shift 3
for f in "$@"; do
clean_sed "
- s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
- s,$macro,$repl,g;
+s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
+s,$macro,$repl,g;
" "$f" "$msg"
done
}
sound/pci/cs46xx/imgs/cwcdma.asp \
; do
if test ! $f; then
- die $f is not present, something is amiss
+ die $f is not present, something is amiss && return
fi
done
# Identify the tarball.
-clean_sed "
-s,^EXTRAVERSION.*,&-libre$extra,
+grep -q 'EXTRAVERSION.*-libre' Makefile ||
+clean_sed "s,^EXTRAVERSION.*,&-libre$extra,
" Makefile 'added -libre to EXTRAVERSION'
# Add reject_firmware and maybe_reject_firmware
-clean_sed '
-$i\
+grep -q _LINUX_LIBRE_FIRMWARE_H include/linux/firmware.h ||
+clean_sed '$i\
#ifndef _LINUX_LIBRE_FIRMWARE_H\
#define _LINUX_LIBRE_FIRMWARE_H\
\
clean_sed s,usb8388,whatever,g drivers/base/Kconfig 'removed blob name'
clean_blob firmware/WHENCE
+if $errors; then
+ echo errors above were ignored because of --force >&2
+fi
+
exit 0
# Copyright (C) 2008, 2009 Alexandre Oliva <lxoliva@fsfla.org>
# Copyright (C) 2008 Jeff Moe
+# Copyright (C) 2009 Rubén Rodríguez <ruben@gnu.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
# For each kver release, start extra with an empty string, then count
# from 1 if changes are needed that require rebuilding the tarball.
-kver=2.6.30 extra=
-
-fatal () {
- echo "$@"
- exit 1
-}
+kver=2.6.30 extra=++
case $1 in
---force) die () { echo ERROR: "$@": ignored >&2; }; forced=:; shift;;
-*) die () { fatal "$@"; }; forced=false;;
+--force)
+ echo "WARNING: Using the force, ignored errors will be" >&2
+ die () {
+ echo ERROR: "$@" >&2
+ errors=:
+ }
+ forced=: errors=false
+ shift
+ ;;
+*)
+ die () {
+ echo ERROR: "$@" >&2
+ echo Use --force to ignore
+ exit 1
+ }
+ forced=false errors=false
+ ;;
esac
check=`echo "$0" | sed 's,[^/]*$,,;s,^$,.,;s,/*$,,'`/deblob-check
have_check=:
fi
+filetest () {
+ [ -f $1 ]
+}
+
announce () {
- echo
- echo "$@"
+ echo
+ echo "$@"
}
clean_file () {
- #$1 = filename
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- rm $1
- echo $1: removed
+ #$1 = filename
+ filetest $1 || return
+ rm $1
+ echo $1: removed
}
check_changed () {
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif cmp $1.deblob $1 > /dev/null; then
- die $1 did not change, something is wrong
- fi
- mv $1.deblob $1
+ #$1 = filename
+ if cmp $1.deblob $1 > /dev/null; then
+ rm $1.deblob
+ die $1 did not change, something is wrong && return 1
+ fi
+ mv $1.deblob $1
}
clean_blob () {
- #$1 = filename
- if $have_check; then
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- fi
- name=$1
- set fnord "$@" -d
- shift 2
- $check "$@" -i linux-$kver $name > $name.deblob
- echo $name: removed blobs
- check_changed $name
- else
- clean_file $1
- fi
+ #$1 = filename
+ filetest $1 || return
+ if $have_check; then
+ name=$1
+ set fnord "$@" -d
+ shift 2
+ $check "$@" -i linux-$kver $name > $name.deblob
+ check_changed $name && echo $name: removed blobs
+ else
+ clean_file $1
+ fi
}
dummy_blob () {
- #$1 = filename
- if test -f $1; then
- die $1 exists, something is wrong
- elif test ! -f firmware/Makefile; then
- die firmware/Makefile does not exist, something is wrong
- fi
-
- clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
- firmware/Makefile "dropped $1"
+ #$1 = filename
+ if test -f $1; then
+ die $1 exists, something is wrong && return
+ elif test ! -f firmware/Makefile; then
+ die firmware/Makefile does not exist, something is wrong && return
+ fi
+
+ clean_sed "s,`echo $1 | sed s,^firmware/,,`,\$(DEBLOBBED),g" \
+ firmware/Makefile "dropped $1"
}
clean_fw () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_blob $1 -s 4
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_blob $1 -s 4
+ dummy_blob $2
}
drop_fw_file () {
- #$1 = firmware text input, $2 = firmware output
- if test ! -f $1; then
- die $1 does not exist, something is wrong
- elif test -f $2; then
- die $2 exists, something is wrong
- fi
- clean_file $1
- dummy_blob $2
+ #$1 = firmware text input, $2 = firmware output
+ filetest $1 || return
+ if test -f $2; then
+ die $2 exists, something is wrong && return
+ fi
+ clean_file $1
+ dummy_blob $2
}
clean_kconfig () {
- #$1 = filename $2 = things to remove
- case $1 in
- -f)
- shift
- ;;
- *)
- if $have_check; then
- return
- fi
- ;;
- esac
- sed "/^config \\($2\\)\$/{p;i\
+ #$1 = filename $2 = things to remove
+ case $1 in
+ -f)
+ shift
+ ;;
+ *)
+ if $have_check; then
+ return
+ fi
+ ;;
+ esac
+ filetest $1 || return
+ sed "/^config \\($2\\)\$/{p;i\
depends on NONFREE
d;}" $1 > $1.deblob
- echo $1: marked config $2 as depending on NONFREE
- check_changed $1
+ check_changed $1 && echo $1: marked config $2 as depending on NONFREE
}
clean_mk () {
- #$1 = config $2 = Makefile name
- # We don't clean up Makefiles any more --lxoliva
- # sed -i "/\\($1\\)/d" $2
- # echo $2: removed $1 support
- # check_changed $2
- if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
- :
- else
- die $2 does not contain matches for $1
- fi
+ #$1 = config $2 = Makefile name
+ # We don't clean up Makefiles any more --lxoliva
+ # sed -i "/\\($1\\)/d" $2
+ # echo $2: removed $1 support
+ # check_changed $2
+ filetest $2 || return
+ if sed -n "/\\($1\\)/p" $2 | grep . > /dev/null; then
+ :
+ else
+ die $2 does not contain matches for $1
+ fi
}
clean_sed () {
- #$1 = sed-script $2 = file $3 = comment
- sed -e "$1" "$2" > "$2".deblob
- echo $2: ${3-applied sed script $1}
- check_changed "$2"
+ #$1 = sed-script $2 = file $3 = comment
+ filetest $2 || return
+ sed -e "$1" "$2" > "$2".deblob
+ check_changed $2 && echo $2: ${3-applied sed script $1}
}
reject_firmware () {
- #$1 = file
- clean_sed '
+ #$1 = file
+ filetest $1 || return
+ clean_sed '
s,request\(_ihex\)\?_firmware\(_nowait\)\?,reject_firmware\2,g
' "$1" 'disabled non-Free firmware-loading machinery'
}
maybe_reject_firmware () {
- #$1 = file
- clean_sed '
+ #$1 = file
+ filetest $1 || return
+ clean_sed '
s,request_firmware\(_nowait\)\?,maybe_reject_firmware\1,g
' "$1" 'retain Free firmware-loading machinery, disabling non-Free one'
}
macro=$1 repl=$2 msg=$3; shift 3
for f in "$@"; do
clean_sed "
- s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
- s,$macro,$repl,g;
+s,^#define $macro .*\$,/*(DEBLOBBED)*/,;
+s,$macro,$repl,g;
" "$f" "$msg"
done
}
sound/pci/cs46xx/imgs/cwcdma.asp \
; do
if test ! $f; then
- die $f is not present, something is amiss
+ die $f is not present, something is amiss && return
fi
done
# Identify the tarball.
-clean_sed "
-s,^EXTRAVERSION.*,&-libre$extra,
+grep -q 'EXTRAVERSION.*-libre' Makefile ||
+clean_sed "s,^EXTRAVERSION.*,&-libre$extra,
" Makefile 'added -libre to EXTRAVERSION'
# Add reject_firmware and maybe_reject_firmware
-clean_sed '
-$i\
+grep -q _LINUX_LIBRE_FIRMWARE_H include/linux/firmware.h ||
+clean_sed '$i\
#ifndef _LINUX_LIBRE_FIRMWARE_H\
#define _LINUX_LIBRE_FIRMWARE_H\
\
clean_blob firmware/README.AddingFirmware
clean_blob firmware/WHENCE
+if $errors; then
+ echo errors above were ignored because of --force >&2
+fi
+
exit 0