#!/bin/sh
# test we are root
if [ "$(id -u)" != "0" ]; then
   echo "run as root now exitting"
   exit 1
fi
# created licences come from WHENCE
# upon updates manual licences may need updating too

VERSION=20200619
DOC=usr/local/share/doc
F1=firmware-
# F2 is defined in a list command
G2=GPL-2
G3=GPL-3
LF=linux-firmware
LIC=LICENCE
LIS=LICENSE
SD=https://git.kernel.org/pub/scm/linux/kernel/git/firmware/$LF.git/snapshot
SRC=$LF-$VERSION
TCI=usr/local/tce.installed
ULLF=usr/local/lib/firmware
USER=`cat /etc/sysconfig/tcuser`
##########################################
# DOWNLOAD AND UNPACK SECTION
##########################################
cd /tmp
su -c "tce-load -i submitqc " $USER
su -c "/usr/local/bin/wget -nc --no-check-certificate \
$SD/$LF-$VERSION.tar.gz  "  $USER

tar xvf $LF*
# due to the need to copy some files multiple times
cp $SRC/$G2 $SRC/$G3 .
cp $SRC/$LIS.QualcommAtheros_ath10k .
cp $SRC/$LIC.rtlwifi_firmware.txt .
cp $SRC/$LIC.iwlwifi_firmware .
cp $SRC/$LIC.ralink_a_mediatek_company_firmware .
cp $SRC/WHENCE .
#################################################
# Create all existing TCEs EXCEPT firmware.tcz
# add  very large makers no longer to be in firmware.tcz
#################################################
A=amdgpu 
B=amd-ucode 
C=atheros 
D=broadcom_bcm43xx 
E=broadcom_bnx2 
F=broadcom_bnx2x 
G=cavium_nic 
H=chelsio 
I=i915 
J=intel_e100 
K=intel 
L=iwimax 
M=iwl8000
N=iwl9000
O=iwlax20x
P=iwlwifi 
Q=marvel 
R=moxa 
S=myri10ge 
T=netxen 
U=nvidia 
V=qca 
W=radeon 
X=ralinkwifi 
Y=rtl_bt 
Z=rtl_nic 
AA=rtlwifi 
AB=ti-connectivity 
AC=tigon 
AD=ueagle-atm 
AE=vxge  
AF=dpaa2 
AG=mediatek 
AH=mellanox
AI=netronome
AJ=qcom
AK=qed
#####################################
LIST="$A $B $C $D $E $F $G $H $I $J $K $L $M $N $O $P $Q $R $S $T $U $V $W $X $Y $Z \
$AA $AB $AC $AD $AE $AF $AG $AH $AI $AJ $AK"
for b in $LIST
    do 
     F2=$F1$b
# create TCE dirs
    mkdir -p $F2/$TCI
    mkdir -p $F2/$DOC/$F2
    mkdir -p $F2/$ULLF
# move FW dir to its TCEs - where applicable
   mv $SRC/$b  $F2/$ULLF/
# create tce install script
    echo '#!/bin/sh
/sbin/udevadm trigger ' > $F2/$TCI/$F2
    chown -R root:staff $F2/$TCI
    chmod -R 775 $F2/$TCI
# licences will require more fixs but automate where possible
# shorter script without if-then will produce some errors we can ignore
   mv $SRC/$LIC.$b* $F2/$DOC/$F2 
   mv $SRC/$LIS.$b* $F2/$DOC/$F2
done
###########################################
# Add MISSING  firmware 
######################
mv $SRC/ar3k  $F1$C/$ULLF/
mv $SRC/ath10k  $F1$C/$ULLF/
mv $SRC/ath6k  $F1$C/$ULLF/
mv $SRC/ath9k_htc  $F1$C/$ULLF/
mv $SRC/ar*  $F1$C/$ULLF/
mv $SRC/ath*  $F1$C/$ULLF/
mv $SRC/carl9170*  $F1$C/$ULLF/
mv $SRC/wil*  $F1$C/$ULLF/
# add firmware.tcz atheros...lic covered by open-ath9k-htc
mv $SRC/htc*  $F1$C/$ULLF/
mv $SRC/brcm  $F1$D/$ULLF/
mv $SRC/bnx2  $F1$E/$ULLF/
mv $SRC/bnx2x*  $F1$F/$ULLF/
mv $SRC/cavium  $F1$G/$ULLF/
mv $SRC/liquidio  $F1$G/$ULLF/
mv $SRC/cxg*  $F1$H/$ULLF/
mv $SRC/e100  $F1$J/$ULLF/
mv $SRC/i2400*  $F1$L/$ULLF/
mv $SRC/i60*  $F1$L/$ULLF/
mv $SRC/*8000C* $F1$M/$ULLF/
mv $SRC/*8265* $F1$M/$ULLF/
mv $SRC/*9000* $F1$N/$ULLF/
mv $SRC/*9260* $F1$N/$ULLF/
mv $SRC/iwlwifi-Qu* $F1$O/$ULLF/
mv $SRC/iwlwifi-cc* $F1$O/$ULLF/
# now we can move the balance into iwlwifi
mv $SRC/iwlwifi-* $F1$P/$ULLF/
mv $SRC/libertas $F1$Q/$ULLF/
# add fw from firmware.tcz lbtf covered by OLPC lic   imx covered by sdma lic 
mv $SRC/lbtf_usb* $F1$Q/$ULLF/
mv $SRC/imx $F1$Q/$ULLF/
mv $SRC/mrvl $F1$Q/$ULLF/
mv $SRC/mw* $F1$Q/$ULLF/
mv $SRC/myri10*  $F1$S/$ULLF/
mv $SRC/phan*  $F1$T/$ULLF/
mv $SRC/rt2*  $F1$X/$ULLF/
mv $SRC/rt3*  $F1$X/$ULLF/
mv $SRC/rt7*  $F1$X/$ULLF/
mv $SRC/RTL* $F1$AA/$ULLF/
mv $SRC/rtw88 $F1$AA/$ULLF/
mv $SRC/ti_* $F1$AB/$ULLF/
mv $SRC/mt7*  $F1$AG/$ULLF/
###########################
#  fix missing LICENSES non-firmware.tcz
###########################
# notice_ath10k_firmware-4.txt no longer exists 
mv $SRC/$LIS.Qual* $F1$C/$DOC/$F1$C
mv $SRC/$LIC.open* $F1$C/$DOC/$F1$C

# missing lic for cypress add eg BCM-0bb4-0306
mv $SRC/$LIC.cypress $F1$D/$DOC/$F1$D

# broadcom_bnx2.txt no longer exists create new lic
echo 'Driver: bnx2 - Broadcom NetXtremeII
File: bnx2/bnx2-mips-06-4.6.16.fw
File: bnx2/bnx2-mips-06-5.0.0.j3.fw
File: bnx2/bnx2-mips-06-5.0.0.j6.fw
File: bnx2/bnx2-mips-06-6.0.15.fw
File: bnx2/bnx2-mips-06-6.2.1.fw
File: bnx2/bnx2-mips-06-6.2.3.fw
File: bnx2/bnx2-mips-09-4.6.17.fw
File: bnx2/bnx2-mips-09-5.0.0.j3.fw
File: bnx2/bnx2-mips-09-5.0.0.j9.fw
File: bnx2/bnx2-mips-09-5.0.0.j15.fw
File: bnx2/bnx2-mips-09-6.0.17.fw
File: bnx2/bnx2-mips-09-6.2.1.fw
File: bnx2/bnx2-mips-09-6.2.1a.fw
File: bnx2/bnx2-mips-09-6.2.1b.fw
File: bnx2/bnx2-rv2p-06-4.6.16.fw
File: bnx2/bnx2-rv2p-06-5.0.0.j3.fw
File: bnx2/bnx2-rv2p-06-6.0.15.fw
File: bnx2/bnx2-rv2p-09-4.6.15.fw
File: bnx2/bnx2-rv2p-09-5.0.0.j3.fw
File: bnx2/bnx2-rv2p-09-5.0.0.j10.fw
File: bnx2/bnx2-rv2p-09-6.0.17.fw
File: bnx2/bnx2-rv2p-09ax-5.0.0.j3.fw
File: bnx2/bnx2-rv2p-09ax-5.0.0.j10.fw
File: bnx2/bnx2-rv2p-09ax-6.0.17.fw
Licence:
This file contains firmware data derived from proprietary unpublished
source code, Copyright (c) 2004 - 2010 Broadcom Corporation.
Permission is hereby granted for the distribution of this firmware data
in hexadecimal or equivalent format, provided this copyright notice is
accompanying it. ' > $F1$E/$DOC/$F1$E/$LIC

# broadcom_bnx2x.txt missing create new lic
echo 'Driver: bnx2x: Broadcom Everest
File: bnx2x-e1-4.8.53.0.fw
File: bnx2x-e1h-4.8.53.0.fw
File: bnx2x-e1-5.2.7.0.fw
File: bnx2x-e1h-5.2.7.0.fw
File: bnx2x-e1-5.2.13.0.fw
File: bnx2x-e1h-5.2.13.0.fw
File: bnx2x/bnx2x-e1-6.0.34.0.fw
File: bnx2x/bnx2x-e1h-6.0.34.0.fw
File: bnx2x/bnx2x-e2-6.0.34.0.fw
File: bnx2x/bnx2x-e1-6.2.5.0.fw
File: bnx2x/bnx2x-e1h-6.2.5.0.fw
File: bnx2x/bnx2x-e2-6.2.5.0.fw
File: bnx2x/bnx2x-e1-6.2.9.0.fw
File: bnx2x/bnx2x-e1h-6.2.9.0.fw
File: bnx2x/bnx2x-e2-6.2.9.0.fw
File: bnx2x/bnx2x-e2-7.0.20.0.fw
File: bnx2x/bnx2x-e1-7.0.20.0.fw
File: bnx2x/bnx2x-e1h-7.0.20.0.fw
File: bnx2x/bnx2x-e2-7.0.23.0.fw
File: bnx2x/bnx2x-e1-7.0.23.0.fw
File: bnx2x/bnx2x-e1h-7.0.23.0.fw
File: bnx2x/bnx2x-e2-7.0.29.0.fw
File: bnx2x/bnx2x-e1-7.0.29.0.fw
File: bnx2x/bnx2x-e1h-7.0.29.0.fw
File: bnx2x/bnx2x-e2-7.2.16.0.fw
File: bnx2x/bnx2x-e1-7.2.16.0.fw
File: bnx2x/bnx2x-e1h-7.2.16.0.fw
File: bnx2x/bnx2x-e2-7.2.51.0.fw
File: bnx2x/bnx2x-e1-7.2.51.0.fw
File: bnx2x/bnx2x-e1h-7.2.51.0.fw
File: bnx2x/bnx2x-e1-7.8.2.0.fw
File: bnx2x/bnx2x-e1h-7.8.2.0.fw
File: bnx2x/bnx2x-e2-7.8.2.0.fw
File: bnx2x/bnx2x-e1-7.8.17.0.fw
File: bnx2x/bnx2x-e1h-7.8.17.0.fw
File: bnx2x/bnx2x-e2-7.8.17.0.fw
File: bnx2x/bnx2x-e1-7.8.19.0.fw
File: bnx2x/bnx2x-e1h-7.8.19.0.fw
File: bnx2x/bnx2x-e2-7.8.19.0.fw
File: bnx2x/bnx2x-e1-7.10.51.0.fw
File: bnx2x/bnx2x-e1h-7.10.51.0.fw
File: bnx2x/bnx2x-e2-7.10.51.0.fw
File: bnx2x/bnx2x-e1-7.12.30.0.fw
File: bnx2x/bnx2x-e1h-7.12.30.0.fw
File: bnx2x/bnx2x-e2-7.12.30.0.fw
File: bnx2x/bnx2x-e1-7.13.1.0.fw
File: bnx2x/bnx2x-e1h-7.13.1.0.fw
File: bnx2x/bnx2x-e2-7.13.1.0.fw
File: bnx2x/bnx2x-e1-7.13.11.0.fw
File: bnx2x/bnx2x-e1h-7.13.11.0.fw
File: bnx2x/bnx2x-e2-7.13.11.0.fw
File: bnx2x/bnx2x-e1-7.13.15.0.fw
File: bnx2x/bnx2x-e1h-7.13.15.0.fw
File: bnx2x/bnx2x-e2-7.13.15.0.fw
License:
Copyright (c) 2007-2011 Broadcom Corporation
This file contains firmware data derived from proprietary unpublished
source code, Copyright (c) 2007-2011 Broadcom Corporation.
Permission is hereby granted for the distribution of this firmware data
in hexadecimal or equivalent format, provided this copyright notice is
accompanying it.' > $F1$F/$DOC/$F1$F/$LIC

mv $SRC/$LIC.cav* $F1$G/$DOC/$F1$G/
cp $G2 $F1$H/$DOC/$F1$H

# Intel-e100.txt no longer exists
mv $SRC/$LIC.e100 $F1$J/$DOC/$F1$J

# extra lics found for intel
mv $SRC/$LIC.adsp* $F1$K/$DOC/$F1$K
mv $SRC/$LIC.ibt* $F1$K/$DOC/$F1$K
mv $SRC/$LIC.IntcSST2 $F1$K/$DOC/$F1$K
mv $SRC/$LIC.fw_sst_0f28 $F1$K/$DOC/$F1$K
mv $SRC/$LIS.ipu* $F1$K/$DOC/$F1$K
mv $SRC/$LIS.ice $F1$K/$DOC/$F1$K

mv $SRC/$LIC.i2400m $F1$L/$DOC/$F1$L
cp $LIC.iwlwifi* $F1$M/$DOC/$F1$M
cp $LIC.iwlwifi* $F1$N/$DOC/$F1$N
cp $LIC.iwlwifi* $F1$O/$DOC/$F1$O

# extra lics found for marvell
mv $SRC/$LIC.Marvell $F1$Q/$DOC/$F1$Q
mv $SRC/$LIC.OLPC $F1$Q/$DOC/$F1$Q
mv $SRC/$LIC.NXP $F1$Q/$DOC/$F1$Q
mv $SRC/$LIS.sdma_firmware $F1$Q/$DOC/$F1$Q

mv $SRC/$LIC.phanfw $F1$T/$DOC/$F1$T

# wrong lic is old TCE?
cp $LIS.Qual*  $F1$V/$DOC/$F1$V
mv $F1$V/$ULLF/qca/NOTICE.txt $F1$V/$DOC/$F1$V

# other lic now missing create it
echo 'Driver: radeon - ATI Radeon
File: radeon/R100_cp.bin
File: radeon/R200_cp.bin
File: radeon/R300_cp.bin
File: radeon/R420_cp.bin
File: radeon/RS600_cp.bin
File: radeon/RS690_cp.bin
File: radeon/R520_cp.bin
File: radeon/R600_pfp.bin
File: radeon/R600_me.bin
File: radeon/RV610_pfp.bin
File: radeon/RV610_me.bin
File: radeon/RV630_pfp.bin
File: radeon/RV630_me.bin
File: radeon/RV620_pfp.bin
File: radeon/RV620_me.bin
File: radeon/RV635_pfp.bin
File: radeon/RV635_me.bin
File: radeon/RV670_pfp.bin
File: radeon/RV670_me.bin
File: radeon/RS780_pfp.bin
File: radeon/RS780_me.bin
File: radeon/RV770_pfp.bin
File: radeon/RV770_me.bin
File: radeon/RV730_pfp.bin
File: radeon/RV730_me.bin
File: radeon/RV710_pfp.bin
File: radeon/RV710_me.bin
Licence:
Copyright 2007-2009 Advanced Micro Devices, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
 paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
' > $F1$W/$DOC/$F1$W/$LIC

# whence says only 2 lic applies
mv $SRC/$LIC.ralink-firmware.txt $F1$X/$DOC/$F1$X
mv $SRC/$LIC.ralink_a_mediatek_company_firmware $F1$X/$DOC/$F1$X

# LICENCE.rtl_firmware.txt no longer exists, it looks like a name change only
cp $LIC.rtlwifi* $F1$Y/$DOC/$F1$Y
cp $LIC.rtlwifi* $F1$Z/$DOC/$F1$Z

# Realtek-Firmware-License.txt no longer exists--------------rtlwifi ok with one lic

# LICENCE.ti-connectivity now missing whence says now gpl2
cp $G2 $F1$AB/$DOC/$F1$AB/
mv $SRC/$LIC.wl1251 $F1$AB/$DOC/$F1$AB

# lic was missing from old TCE create it
echo 'Driver: tg3 -- Broadcom Tigon3 based gigabit Ethernet cards
File: tigon/tg3.bin        File: tigon/tg3_tso.bin
File: tigon/tg3_tso5.bin   File: tigon/tg357766.bin
Licence:
Firmware is:
Derived from proprietary unpublished source code,
Copyright (C) 2000-2013 Broadcom Corporation.
Permission is hereby granted for the distribution of this firmware
data in hexadecimal or equivalent format, provided this copyright
notice is accompanying it. ' >  $F1$AC/$DOC/$F1$AC/$LIC

# lic was missing from old TCE
echo 'Driver: vxge - Exar X3100 Series 10GbE PCIe I/O Virtualized Server Adapter
File: vxge/X3fw.ncf File: vxge/X3fw-pxe.ncf Version: 1.8.1
Licence:
This file contains firmware data derived from proprietary unpublished
source code, Copyright (c) 2010 Exar Corporation.
Permission is hereby granted for the distribution of this firmware data
in hexadecimal or equivalent format, provided this copyright notice is
accompanying it. ' > $F1$AE/$DOC/$F1$AE/$LIC

cp LIC.ralink_a_mediatek_company_firmware $F1$AG/$DOC/$F1$AG/$LIC

mv $SRC/$LIS.nxp_mc_firmware $F1$AF/$DOC/$F1$AF/$LIC
cp $G2 $F1$AH/$DOC/$F1$AH/
mv $SRC/$LIC.Netronome $F1$AI/$DOC/$F1$AI/

# create it 
echo 'Driver: qed - QLogic 4xxxx Ethernet Driver Core Module.
File: qed/qed_init_values_zipped-8.4.2.0.bin File: qed/qed_init_values_zipped-8.7.3.0.bin
File: qed/qed_init_values_zipped-8.10.5.0.bin File: qed/qed_init_values-8.10.9.0.bin
File: qed/qed_init_values_zipped-8.10.10.0.bin File: qed/qed_init_values-8.14.6.0.bin
File: qed/qed_init_values_zipped-8.15.3.0.bin File: qed/qed_init_values-8.18.9.0.bin
File: qed/qed_init_values_zipped-8.20.0.0.bin File: qed/qed_init_values-8.20.0.0.bin
File: qed/qed_init_values-8.30.12.0.bin File: qed/qed_init_values_zipped-8.33.1.0.bin
File: qed/qed_init_values_zipped-8.33.11.0.bin File: qed/qed_init_values-8.33.12.0.bin
File: qed/qed_init_values_zipped-8.37.2.0.bin File: qed/qed_init_values_zipped-8.37.7.0.bin
File: qed/qed_init_values-8.37.7.0.bin File: qed/qed_init_values-8.40.33.0.bin
File: qed/qed_init_values_zipped-8.42.2.0.bin
Licence:
This file contains firmware data derived from proprietary unpublished source code.
Copyright (c) 2015-2018 QLogic Corporation.
Permission is hereby granted for the distribution of this firmware data
in hexadecimal or equivalent format, provided this copyright notice is
accompanying it.'  > $F1$AK/$DOC/$F1$AK/$LIC
##################################################################################################
# this section completes splits up old  firmware.tcz
#####################################################################################################
FA=audio
FL=lan
FM=misc
FV=video
FW=wlan
LIST="$FA $FL $FM $FV $FW"
for c in $LIST
    do 
     F2=$F1$c
# create TCE dirs
    mkdir -p $F2/$TCI
    mkdir -p $F2/$DOC/$F2
    mkdir -p $F2/$ULLF
# create tce install script
    echo '#!/bin/sh
/sbin/udevadm trigger ' > $F2/$TCI/$F2
    chown -R root:staff $F2/$TCI
    chmod -R 775 $F2/$TCI
done

# audio
LIST="emi26 emi62 ess go7007 korg \
sb16 ti-keystone yam yamaha"
for d in $LIST
     do
    mv $SRC/$d $F1$FA/$ULLF
done

# LAN (2 lics can be automated)
LIST="acenic adaptec kaweth microchip slicoss tehuti"
for e in $LIST
     do
    mv $SRC/$e $F1$FL/$ULLF
    mv $SRC/$LIS.$e $F1$FL/$DOC/$F1$FL
done

# MISCanellos 
LIST="3com advansys amd av7110 cadence cis cpia2 \
dabusb dsp56k edgeport ene-ub6250 inside-secure \
isci keyspan keyspan_pda matrox ositech r128 sun "
for f in $LIST
     do
    mv $SRC/$f $F1$FM/$ULLF
done

# video
mv $SRC/meson $F1$FV/$ULLF
mv $SRC/s5p* $F1$FV/$ULLF
mv $SRC/v4l* $F1$FV/$ULLF
mv $SRC/tlg* $F1$FV/$ULLF

# WLAN
mv $SRC/atmel $F1$FW/$ULLF
mv $SRC/atusb $F1$FW/$ULLF
mv $SRC/vicam $F1$FW/$ULLF
mv $SRC/$LIS.atmel $F1$FW/$DOC/$F1$FW

############
# additions
############
# Audio
######
# WHENCE covers emi26/62 korg yam
cp WHENCE $F1$FA/$DOC/$F1$FA
mv $SRC/$LIC.go7007 $F1$FA/$DOC/$F1$FA
mv $SRC/$LIC.ti-keystone $F1$FA/$DOC/$F1$FA
cp $G2 $F1$FA/$DOC/$F1$FA
mv $SRC/TDA* $F1$FA/$ULLF
mv $SRC/$LIC.tda* $F1$FA/$DOC/$F1$FA
mv $SRC/cte* $F1$FA/$ULLF
mv $SRC/cts* $F1$FA/$ULLF
mv $SRC/$LIC.ca0* $F1$FA/$DOC/$F1$FA

# LAN 
######
# WHENCE covers acenic adaptec slicoss tehuti cbfw ct2fw ctfw myricom sxg 
cp WHENCE $F1$FL/$DOC/$F1$FL
mv $SRC/$LIC.kaweth $F1$FL/$DOC/$F1$FL
mv $SRC/$LIC.microchip $F1$FL/$DOC/$F1$FL
mv $SRC/atmsar* $F1$FL/$ULLF/
cp $G2 $F1$FL/$DOC/$F1$FL
mv $SRC/cbfw* $F1$FL/$ULLF/
mv $SRC/ct2fw* $F1$FL/$ULLF/
mv $SRC/ctfw* $F1$FL/$ULLF/
mv $SRC/ql2* $F1$FL/$ULLF/
mv $SRC/$LIC.qla2xxx $F1$FL/$DOC/$F1$FL
mv $SRC/myricom $F1$FL/$ULLF/
mv $SRC/sxg $F1$FL/$ULLF/
mv $SRC/hfi1* $F1$FL/$ULLF/
mv $SRC/$LIS.hfi1* $F1$FL/$DOC/$F1$FL

# misc  
######
# WHENCE covers 3com advansys dabusb f2255 intelliport2 lgs8g75  \
###  qat* mts_ rp2  ttusb* s5p tlg2300 whiteheat 
cp WHENCE $F1$FM/$DOC/$F1$FM
cp $G2 $F1$FM/$DOC/$F1$FM
mv $SRC/$LIS.amd-sev $F1$FM/$DOC/$F1$FM/
mv $SRC/$LIC.cadence $F1$FM/$DOC/$F1$FM/
mv $SRC/$LIC.ene* $F1$FM/$DOC/$F1$FM/
mv $SRC/as102* $F1$FM/$ULLF/
mv $SRC/$LIC.Abilis* $F1$FM/$DOC/$F1$FM/
mv $SRC/cmmb* $F1$FM/$ULLF/
mv $SRC/dvb_nova* $F1$FM/$ULLF/
mv $SRC/isd* $F1$FM/$ULLF/
mv $SRC/sms* $F1$FM/$ULLF/
mv $SRC/tdmb* $F1$FM/$ULLF/
mv $SRC/$LIC.siano $F1$FM/$DOC/$F1$FM/
mv $SRC/dvb-fe* $F1$FM/$ULLF/
mv $SRC/$LIC.xc*  $F1$FM/$DOC/$F1$FM/
mv $SRC/dvb-usb* $F1$FM/$ULLF/
mv $SRC/$LIS.dib*  $F1$FM/$DOC/$F1$FM/
mv $SRC/f2255* $F1$FM/$ULLF/
mv $SRC/intelliport2* $F1$FM/$ULLF/
mv $SRC/lgs8g75* $F1$FM/$ULLF/
mv $SRC/qat* $F1$FM/$ULLF/
mv $SRC/$LIC.qat*  $F1$FM/$DOC/$F1$FM/
mv $SRC/mts_* $F1$FM/$ULLF/
mv $SRC/r8a* $F1$FM/$ULLF/
mv $SRC/$LIC.r8a*  $F1$FM/$DOC/$F1$FM/
mv $SRC/qlogic $F1$FM/$ULLF/
mv $SRC/$LIC.qla1280  $F1$FM/$DOC/$F1$FM/
mv $SRC/rockchip $F1$FM/$ULLF/
mv $SRC/rp2* $F1$FM/$ULLF/
mv $SRC/$LIC.rockchip  $F1$FM/$DOC/$F1$FM/
mv $SRC/ttusb* $F1$FM/$ULLF/
mv $SRC/usbdux* $F1$FM/$ULLF/
#################################mv $SRC/s5p* $F1$FM/$ULLF/
#################################mv $SRC/v4l* $F1$FM/$ULLF/
##################################mv $SRC/tlg2300* $F1$FM/$ULLF/
mv $SRC/tr_smctr* $F1$FM/$ULLF/
mv $SRC/white* $F1$FM/$ULLF/
mv $SRC/$LIC.it913*  $F1$FM/$DOC/$F1$FM/

# Video
######
mv $SRC/$LIS.amlogic* $F1$FV/$DOC/$F1$FV/

echo 'Driver: tlg2300 - Telgent 2300 V4L/DVB driver.
File: tlg2300_firmware.bin
Licence: Redistributable.
Telegent System grants permission to use and redistribute these
firmware files for use with devices containing the chip tlg2300, but
not as a part of the Linux kernel or in any other form which would
require these files themselves to be covered by the terms of the GNU
General Public License. These firmware files are distributed in the
hope that they will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.' > $F1$FV/$DOC/$F1$FV/$LIC.Telgent

echo 'Driver: s5p-mfc - Samsung MFC video encoder/decoder driver
File: s5p-mfc.fw        File: s5p-mfc-v6.fw
File: s5p-mfc-v6-v2.fw  File: s5p-mfc-v7.fw
File: s5p-mfc-v8.fw
Licence: Redistributable.
Samsung grants permission to use and redistribute aforementioned firmware
files for the use with Exynos series devices, but not as part of the Linux
kernel, or in any other form which would require these files themselves
to be covered by the terms of the GNU General Public License.
These firmware files are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
' > $F1$FV/$DOC/$F1$FV/$LIC.Samsung

echo 'Driver: cx23418 - Conexant PCI Broadcast A/V with MPEG encoder
File: v4l-cx23418-apu.fw File: v4l-cx23418-cpu.fw File: v4l-cx23418-dig.fw
Licence: Redistributable.
Conexant grants permission to use and redistribute these firmware
files for use with Conexant devices, but not as a part of the Linux
kernel or in any other form which would require these files themselves
to be covered by the terms of the GNU General Public License.
These firmware files are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--------------------------------------------------------------------------------------------
Driver: cx23885 - Conexant PCI Express Broadcast A/V decoder
File: v4l-cx23885-avcore-01.fw
Licence: Redistributable.
Conexant grants permission to use and redistribute these firmware
files for use with Conexant devices, but not as a part of the Linux
kernel or in any other form which would require these files themselves
to be covered by the terms of the GNU General Public License.
These firmware files are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-------------------------------------------------------------------------------------------
Driver: cx23840 - Conexant sideport Broadcast A/V decoder
File: v4l-cx25840.fw
Licence: Redistributable.
Conexant grants permission to use and redistribute these firmware
files for use with Conexant devices, but not as a part of the Linux
kernel or in any other form which would require these files themselves
to be covered by the terms of the GNU General Public License.
These firmware files are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--------------------------------------------------------------------------------------------
Driver: cx231xx - Conexant Cx23100/101/102 USB broadcast A/V decoder
File: v4l-cx231xx-avcore-01.fw
Licence: Redistributable.
Conexant grants permission to use and redistribute these firmware
files for use with Conexant devices, but not as a part of the Linux
kernel or in any other form which would require these files themselves
to be covered by the terms of the GNU General Public License.
These firmware files are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
' > $F1$FV/$DOC/$F1$FV/$LIC.Conexant

# WLAN
########
echo 'Driver: vicam -- USB 3com HomeConnect (aka vicam)
File: vicam/firmware.fw
Licence: Unknown
Found in hex form in kernel source.' > $F1$FW/$DOC/$F1$FW/$LIC.vicam
cp $G2 $F1$FW/$DOC/$F1$FW
mv $SRC/agere* $F1$FW/$ULLF/
mv $SRC/$LIC.agere* $F1$FW/$DOC/$F1$FW
mv $SRC/rsi* $F1$FW/$ULLF/
echo 'Driver: rsi -- Redpine Signals Inc 91x driver
File: rsi_91x.fw
File: rsi/rs9113_wlan_qspi.rps Version: 1.6.1
File: rsi/rs9113_wlan_bt_dual_mode.rps Version: 1.6.1
File: rsi/rs9113_ap_bt_dual_mode.rps Version: 1.6.1
File: rsi/rs9116_wlan.rps Version: 1.0.5b
File: rsi/rs9116_wlan_bt_classic.rps Version: 1.0.5b
Licence:
Firmware is:
Derived from proprietary unpublished source code,
 Copyright (C) 2019 Redpine Signals Inc.
 Permission is hereby granted for the distribution of this firmware
 as part of Linux or other Open Source operating system kernel
 provided this copyright notice is accompanying it.' > $F1$FW/$DOC/$F1$FW/$LIC.redpine-signals
mv $SRC/sdd_sagrad* $F1$FW/$ULLF/
mv $SRC/wsm* $F1$FW/$ULLF/
mv $SRC/$LIC.cw1200 $F1$FW/$DOC/$F1$FW
# whence says cw12oo is sagrads  and wsm
mv $SRC/vnt* $F1$FW/$ULLF/
mv $SRC/$LIC.via* $F1$FW/$DOC/$F1$FW

# above leaves unpack with no firmwares
# there will be copies of gpl 2/3 and whence 
# create TCEs
#########################################################################################
LIST="$A $B $C $D $E $F $G $H $I $J $K $L $M $N $O $P $Q $R $S $T $U $V $W $X $Y $Z \
$AA $AB $AC $AD $AE $AF $AG $AH $AI $AJ $AK \
$FA $FL $FM $FV $FW"
for z in $LIST
    do 
        mksquashfs $F1$z $F1$z.tcz
	md5sum $F1$z.tcz > $F1$z.tcz.md5.txt
	cd $F1$z
	find usr -not -type d > /tmp/$F1$z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$F1$z.tcz.list
	cd /tmp
done

ls -hal

# below are info creations
