From 106fb7f8c48b004344509196d995e4d9cda0d44c Mon Sep 17 00:00:00 2001 From: Miguel Bernal Marin Date: Tue, 27 Oct 2020 22:42:33 -0600 Subject: [PATCH] add to-spec script --- scripts/to-spec.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/to-spec.sh diff --git a/scripts/to-spec.sh b/scripts/to-spec.sh new file mode 100644 index 00000000..ca343a1f --- /dev/null +++ b/scripts/to-spec.sh @@ -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}