49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
#
|
|
# No patents, no problems
|
|
#
|
|
|
|
# Indicate the problems
|
|
PROBLEMS=(
|
|
'gr-dtv'
|
|
'gr-atsc'
|
|
)
|
|
|
|
# Indicate the source (including workaround for rhbz#1926687)
|
|
URL=$(spectool -S -l ./gnuradio.spec | sed -nE '/^\s*Source/ s/Source0:\s+//g p')
|
|
|
|
# Meta variables
|
|
SOURCE=$(basename $URL)
|
|
COMPRESSION=${SOURCE##*.}
|
|
TAR=${SOURCE%.*}
|
|
|
|
# check if $SOURCE exists
|
|
if [ ! -f $SOURCE ]; then
|
|
# It does not, so we download it
|
|
echo "DOWNLOADING \"$SOURCE\" FROM \"$URL\""
|
|
curl -L -O "$URL"
|
|
fi
|
|
|
|
echo "UNCOMPRESS \"$SOURCE\" TO \"$TAR\""
|
|
if [ "gz" = "$COMPRESSION" ]; then
|
|
COMPRESSION="gzip"
|
|
fi
|
|
$COMPRESSION -d $SOURCE
|
|
|
|
# Getting the base DIR inside the tar
|
|
TAR_BASE=$(tar tf $TAR | head -n1 | sed 's/\/$//')
|
|
for PROBLEM in ${PROBLEMS[@]};
|
|
do
|
|
echo "REMOVING \"$PROBLEM\" FROM \"$TAR\""
|
|
tar -vf $TAR --delete "${TAR_BASE}/${PROBLEM}"
|
|
tar -vf $TAR --strip=1 -x "${TAR_BASE}/CMakeLists.txt"
|
|
tar -vf $TAR --delete "${TAR_BASE}/CMakeLists.txt"
|
|
sed -i "/^add_subdirectory(${PROBLEM})$/ d" CMakeLists.txt
|
|
tar -vf $TAR --append CMakeLists.txt --transform="s|CMakeLists.txt|${TAR_BASE}/CMakeLists.txt|"
|
|
done
|
|
rm -f CMakeLists.txt
|
|
|
|
echo "RECOMPRESS \"$TAR\" TO \"$SOURCE\""
|
|
$COMPRESSION $TAR
|