From 59ed39ec460743e97bcce22e62d27ba0a569b82f Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Fri, 28 Jul 2023 12:48:01 -0300 Subject: build: fix shellcheck issues in mkrpm.sh/compile.sh --- platform/rpm/mkrpm.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'platform') diff --git a/platform/rpm/mkrpm.sh b/platform/rpm/mkrpm.sh index d32ccd360..de26ca8d1 100755 --- a/platform/rpm/mkrpm.sh +++ b/platform/rpm/mkrpm.sh @@ -8,18 +8,18 @@ # Builds rpms in a temporary directory then places the result in the # current working directory. -name=$1 +name="$1" # Strip any trailing prefix from the version like -rc1 etc -version=$(echo "$2" | sed 's/\-.*//g') -config_opt=$3 +version="$(printf '%s\n' "$2" | sed 's/\-.*//g')" +config_opt="$3" -if [[ ! -f platform/rpm/${name}.spec ]]; then - echo error: spec file not found for name \"${name}\" +if [[ ! -f "platform/rpm/${name}.spec" ]]; then + printf 'error: spec file not found for name %s\n' "${name}" >&2 exit 1 fi if [[ -z "${version}" ]]; then - echo error: version must be given + printf 'error: version must be given\n' >&2 exit 1 fi @@ -28,26 +28,27 @@ if [[ -z "${config_opt}" ]]; then fi # Make a temporary directory and arrange to clean up on exit -tmpdir=$(mktemp -d) -mkdir -p ${tmpdir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS} +tmpdir="$(mktemp -d)" +mkdir -p "${tmpdir}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} function cleanup { - rm -rf ${tmpdir} + rm -rf "${tmpdir}" } trap cleanup EXIT # Create the spec file -tmp_spec_file=${tmpdir}/SPECS/${name}.spec +tmp_spec_file="${tmpdir}/SPECS/${name}.spec" sed -e "s/__NAME__/${name}/g" \ -e "s/__VERSION__/${version}/g" \ -e "s/__CONFIG_OPT__/${config_opt}/g" \ - platform/rpm/${name}.spec >${tmp_spec_file} + "platform/rpm/${name}.spec" >"${tmp_spec_file}" # FIXME: We could parse RELNOTES and create a %changelog section here # Copy the source to build into a tarball -tar --exclude='./.git*' --transform "s/^./${name}-${version}/" -czf ${tmpdir}/SOURCES/${name}-${version}.tar.gz . +tar --exclude='./.git*' --transform "s/^./${name}-${version}/" \ + -czf "${tmpdir}/SOURCES/${name}-${version}.tar.gz" . # Build the files (rpm, debug rpm and source rpm) -rpmbuild --quiet --define "_topdir ${tmpdir}" -ba ${tmp_spec_file} +rpmbuild --quiet --define "_topdir ${tmpdir}" -ba "${tmp_spec_file}" # Copy the results to cwd -mv ${tmpdir}/SRPMS/*.rpm ${tmpdir}/RPMS/*/*rpm . +mv "${tmpdir}/SRPMS"/*.rpm "${tmpdir}/RPMS"/*/*rpm . -- cgit v1.2.3-54-g00ecf