Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Docker Build Images
scripts
Commits
d3d1251f
Commit
d3d1251f
authored
Sep 09, 2019
by
Markus Frosch
Browse files
release: Add RPM implementation
parent
c89b1958
Pipeline
#5280
passed with stage
in 25 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
icinga-build-release
View file @
d3d1251f
#!/bin/bash
set
-e
set
-e
o
pipefail
:
"
${
GIT_REMOTE
:
=origin
}
"
:
"
${
DCH_DIST
:
=icinga
}
"
RPM_VERSION_RE
=
'^(Version:\s+).*'
RPM_VERSION_REPLACE
=
'\1'
RPM_REVISION_RE
=
'^(Release:\s+).*'
RPM_REVISION_SUFFIX
=
'%{?dist}'
error
()
{
if
[
-t
2
]
;
then
{
...
...
@@ -25,6 +30,14 @@ fail() {
help
()
{
echo
"Usage:
$0
<version> [message]"
echo
echo
"Examples:"
echo
" Only bump upstream version: icinga-build-release 1.7.0"
echo
" Full release with tag and push: icinga-build-release 1.7.0-1"
echo
}
rpm_date
()
{
LANG
=
C
echo
"
$(
date
+%A |
sed
-r
's~([a-z]{3}).*~\1~i'
)
"
"
$(
date
+
'%b %d %Y'
)
"
}
if
[
$#
-ge
1
]
;
then
...
...
@@ -106,7 +119,71 @@ if [ "$variant" = deb ]; then
# Staging the change
git add debian/changelog
else
# rpm
fail
"RPM not yet implemented!"
>
&2
spec_file
=
"
$(
ls
./
*
.spec
)
"
if
!
current_version
=
"
$(
grep
-P
"
$RPM_VERSION_RE
"
"
$spec_file
"
|
cut
-d
:
-f2-
|
awk
'{$1=$1};1'
)
"
;
then
fail
"Could not find Version: in
${
spec_file
}
"
fi
# special cases for version
case
"
$current_version
"
in
'%{module_version}'
)
echo
"Found %{module_version} as version and will replace this!"
RPM_VERSION_RE
=
'^(%(global|define)\s+module_version\s+).*'
current_version
=
"
$(
grep
-P
"
$RPM_VERSION_RE
"
"
$spec_file
"
|
awk
'{print $3}'
)
"
;;
esac
if
!
current_revision
=
"
$(
grep
-P
"
$RPM_REVISION_RE
"
"
$spec_file
"
|
cut
-d
:
-f2-
|
awk
'{$1=$1};1'
)
"
;
then
fail
"Could not find Revision: in
${
spec_file
}
"
fi
# remove dist suffix
current_revision
=
"
$(
echo
"
$current_revision
"
|
sed
-r
's~%\{\?dist\}~~'
)
"
# special cases for revision
case
"
$current_revision
"
in
'%{revision}'
)
echo
"Found %{revision} as version and will replace this!"
RPM_REVISION_RE
=
'^(%(global|define)\s+revision\s+).*'
RPM_REVISION_SUFFIX
=
''
current_revision
=
"
$(
grep
-P
"
$RPM_REVISION_RE
"
"
$spec_file
"
|
awk
'{print $3}'
)
"
;;
esac
echo
"Found current version as
${
current_version
}
with revision
${
current_revision
}
"
new_version
=
"
$(
echo
"
${
version
}
"
|
cut
-d-
-f1
)
"
if
[[
"
${
version
}
"
!=
*
-
*
]]
;
then
new_revision
=
1
else
new_revision
=
"
$(
echo
"
${
version
}
"
|
cut
-d-
-f2-
)
"
fi
# Replace data in spec file
sed
-ri
\
-e
"s~
${
RPM_VERSION_RE
}
~
${
RPM_VERSION_REPLACE
}${
new_version
}
~"
\
-e
"s~
${
RPM_REVISION_RE
}
~
${
RPM_VERSION_REPLACE
}${
new_revision
}${
RPM_REVISION_SUFFIX
}
~"
\
"
$spec_file
"
# Check last changelog entry?
#last_changelog="$(grep -A1 %changelog "${spec_file}" | tail -n1)"
#if [[ "${last_changelog}" = *" - ${new_version}-${new_revision}" ]]; then
# Add to changelog
new_changelog
=
"
$(
printf
'* %s %s <%s> - %s'
\
"
$(
rpm_date
)
"
\
"
$(
git config user.name
)
"
\
"
$(
git config user.email
)
"
\
"
${
new_version
}
-
${
new_revision
}
"
)
"
# Insert after %changelog
sed
-i
"/^%changelog/a
${
new_changelog
}
\\
n-
${
message
}
\\
n"
"
${
spec_file
}
"
# Stage the changes
git add
"
${
spec_file
}
"
fi
# Show the user what changed
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment