add to-spec script

This commit is contained in:
Miguel Bernal Marin 2020-10-27 22:42:33 -06:00
parent b15cdc2497
commit 106fb7f8c4
1 changed files with 25 additions and 0 deletions

25
scripts/to-spec.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# SPDX-License-Identifier: GPL-3.0-or-later
KLR_SPEC_FILE=$1
repo_path=.
tmpd=$(mktemp -d /tmp/spec.XXX)
sed -i '/PK XXXX/,/#END/{//!d}' ${KLR_SPEC_FILE}
sed -i '/patchXXXX/,/End XXXX/{//!d}' ${KLR_SPEC_FILE}
for patch in ${repo_path}/[01234]*.patch
do
P=${patch##*/}
N=$(echo ${P} | cut -c 1-4)
echo "Patch${N}: ${P}" >> ${tmpd}/PatchXXXX
echo "%patch${N} -p1" >> ${tmpd}/patchYYYY
done
sed -i "/PK XXXX/r ${tmpd}/PatchXXXX" ${KLR_SPEC_FILE}
sed -i "/patchXXXX/r ${tmpd}/patchYYYY" ${KLR_SPEC_FILE}
rm -rf ${tmpd}