From: Pat Riehecky riehecky@fnal.gov
This should pull out what I think %{dist} looks like based on the previous commits to git.c.o . At least in theory.
Pat Riehecky (1): Added script for extracting what I think is the dist tag
return_disttag.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100755 return_disttag.sh
From: Pat Riehecky riehecky@fnal.gov
--- return_disttag.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100755 return_disttag.sh
diff --git a/return_disttag.sh b/return_disttag.sh new file mode 100755 index 0000000..cc4829c --- /dev/null +++ b/return_disttag.sh @@ -0,0 +1,71 @@ +#!/bin/bash -u +# +# Extracts what appears to be the value of %{dist} from the commit message +# +# Might want to drop this in ~/bin/ and chmod u+x it + +##################################################################### +usage() { + echo '' >&2 + echo "$0 [-hr]" >&2 + echo '' >&2 + echo ' -h: This help message' >&2 + echo ' -r: Use the Redhat tag rather than centos tag' >&2 + echo '' >&2 + echo ' Attempt to extract what appears to be the value of %{dist}' >&2 + echo ' from the git.centos.org commit message' >&2 + exit 1 +} + + +##################################################################### +# setup args in the right order for making getopt evaluation +# nice and easy. You'll need to read the manpages for more info +args=$(getopt -o hr -- "$@") +if [[ $? -ne 0 ]]; then + usage +fi +eval set -- "$args" + +RHELTAG=0 +for arg in $@; do + case $1 in + -- ) + # end of getopt args, shift off the -- and get out of the loop + shift + break 2 + ;; + -r ) + # skip any package with 'centos' in the dist area + RHELTAG=1 + ;; + -h ) + # get help + usage + ;; + esac +done + +packagename=$(basename `pwd`) +metadata=.${packagename}.metadata + +if [[ ! -e ${metadata} ]] || [[ ! -d .git ]] || [[ ! -d SOURCES ]]; then + echo 'You need to run this from inside a sources git repo' + exit 1 +fi + +msg=$(git log --pretty=format:"%s") +pkg=$(echo ${msg} | cut -d' ' -f2) + +if [[ ${RHELTAG} -eq 0 ]]; then + thispkg=(echo ${pkg} | head -1) +elif [[ ${RHELTAG} -eq 1 ]]; then + thispkg=(echo ${pkg} grep -v centos | head -1) +else + echo 'Something went terribly wrong' + exit 1 +fi + +tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]]) + +echo ${tag}
Applied, pushed, thanks https://git.centos.org/summary/centos-git-common
On 06/10/2014 03:08 PM, Pat Riehecky wrote:
From: Pat Riehecky riehecky@fnal.gov
return_disttag.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) create mode 100755 return_disttag.sh
diff --git a/return_disttag.sh b/return_disttag.sh new file mode 100755 index 0000000..cc4829c --- /dev/null +++ b/return_disttag.sh @@ -0,0 +1,71 @@ +#!/bin/bash -u +# +# Extracts what appears to be the value of %{dist} from the commit message +# +# Might want to drop this in ~/bin/ and chmod u+x it
+##################################################################### +usage() {
- echo '' >&2
- echo "$0 [-hr]" >&2
- echo '' >&2
- echo ' -h: This help message' >&2
- echo ' -r: Use the Redhat tag rather than centos tag' >&2
- echo '' >&2
- echo ' Attempt to extract what appears to be the value of %{dist}' >&2
- echo ' from the git.centos.org commit message' >&2
- exit 1
+}
+##################################################################### +# setup args in the right order for making getopt evaluation +# nice and easy. You'll need to read the manpages for more info +args=$(getopt -o hr -- "$@") +if [[ $? -ne 0 ]]; then
- usage
+fi +eval set -- "$args"
+RHELTAG=0 +for arg in $@; do
- case $1 in
-- )
# end of getopt args, shift off the -- and get out of the loop
shift
break 2
;;
-r )
# skip any package with 'centos' in the dist area
RHELTAG=1
;;
-h )
# get help
usage
;;
- esac
+done
+packagename=$(basename `pwd`) +metadata=.${packagename}.metadata
+if [[ ! -e ${metadata} ]] || [[ ! -d .git ]] || [[ ! -d SOURCES ]]; then
- echo 'You need to run this from inside a sources git repo'
- exit 1
+fi
+msg=$(git log --pretty=format:"%s") +pkg=$(echo ${msg} | cut -d' ' -f2)
+if [[ ${RHELTAG} -eq 0 ]]; then
- thispkg=(echo ${pkg} | head -1)
+elif [[ ${RHELTAG} -eq 1 ]]; then
- thispkg=(echo ${pkg} grep -v centos | head -1)
+else
- echo 'Something went terribly wrong'
- exit 1
+fi
+tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]])
+echo ${tag}
typo
On Tue, Jun 10, 2014 at 10:12 AM, Karanbir Singh mail-lists@karan.org wrote:
Applied, pushed, thanks https://git.centos.org/summary/centos-git-common
On 06/10/2014 03:08 PM, Pat Riehecky wrote:
From: Pat Riehecky riehecky@fnal.gov
return_disttag.sh | 71
+++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-) create mode 100755 return_disttag.sh
diff --git a/return_disttag.sh b/return_disttag.sh new file mode 100755 index 0000000..cc4829c --- /dev/null +++ b/return_disttag.sh @@ -0,0 +1,71 @@ +#!/bin/bash -u +# +# Extracts what appears to be the value of %{dist} from the commit
message
+# +# Might want to drop this in ~/bin/ and chmod u+x it
+##################################################################### +usage() {
- echo '' >&2
- echo "$0 [-hr]" >&2
- echo '' >&2
- echo ' -h: This help message' >&2
- echo ' -r: Use the Redhat tag rather than centos tag' >&2
- echo '' >&2
- echo ' Attempt to extract what appears to be the value of %{dist}'
&2
- echo ' from the git.centos.org commit message' >&2
- exit 1
+}
+##################################################################### +# setup args in the right order for making getopt evaluation +# nice and easy. You'll need to read the manpages for more info +args=$(getopt -o hr -- "$@") +if [[ $? -ne 0 ]]; then
- usage
+fi +eval set -- "$args"
+RHELTAG=0 +for arg in $@; do
- case $1 in
-- )
# end of getopt args, shift off the -- and get out of the
loop
shift
break 2
;;
-r )
# skip any package with 'centos' in the dist area
RHELTAG=1
;;
-h )
# get help
usage
;;
- esac
+done
+packagename=$(basename `pwd`) +metadata=.${packagename}.metadata
+if [[ ! -e ${metadata} ]] || [[ ! -d .git ]] || [[ ! -d SOURCES ]];
then
- echo 'You need to run this from inside a sources git repo'
- exit 1
+fi
+msg=$(git log --pretty=format:"%s") +pkg=$(echo ${msg} | cut -d' ' -f2)
+if [[ ${RHELTAG} -eq 0 ]]; then
- thispkg=(echo ${pkg} | head -1)
+elif [[ ${RHELTAG} -eq 1 ]]; then
- thispkg=(echo ${pkg} grep -v centos | head -1)
+else
- echo 'Something went terribly wrong'
- exit 1
+fi
+tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep
-e el[[:digit:]])
+echo ${tag}
-- Karanbir Singh +44-207-0999389 | http://www.karan.org/ | twitter.com/kbsingh GnuPG Key : http://www.karan.org/publickey.asc _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
good spot, pushed.
On 06/10/2014 03:27 PM, Mike McLean wrote:
typo
Also, I suggest piping that git log output through |grep import |head -n 1. No need to process the entire history and we could have non-import commits. E.g. attached patch
On Tue, Jun 10, 2014 at 10:29 AM, Karanbir Singh mail-lists@karan.org wrote:
good spot, pushed.
On 06/10/2014 03:27 PM, Mike McLean wrote:
typo
-- Karanbir Singh +44-207-0999389 | http://www.karan.org/ | twitter.com/kbsingh GnuPG Key : http://www.karan.org/publickey.asc _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
I wrote a script for extracting the dist macro value a while back. One of the odd cases is when rpms have what /looks like/ a dist tag in the release field, but is in fact a hard coded part of the release. I've seen some pretty strange things.
At any rate, I figured out a way to extract the true dist tag, given the spec and the nvr. I've applied similar changes here for review.
On Tue, Jun 10, 2014 at 10:35 AM, Mike McLean mikem@imponderable.org wrote:
Also, I suggest piping that git log output through |grep import |head -n
- No need to process the entire history and we could have non-import
commits. E.g. attached patch
On Tue, Jun 10, 2014 at 10:29 AM, Karanbir Singh mail-lists@karan.org wrote:
good spot, pushed.
On 06/10/2014 03:27 PM, Mike McLean wrote:
typo
-- Karanbir Singh +44-207-0999389 | http://www.karan.org/ | twitter.com/kbsingh GnuPG Key : http://www.karan.org/publickey.asc _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
hi
On 06/10/2014 03:49 PM, Mike McLean wrote:
I wrote a script for extracting the dist macro value a while back. One of the odd cases is when rpms have what /looks like/ a dist tag in the release field, but is in fact a hard coded part of the release. I've seen some pretty strange things.
At any rate, I figured out a way to extract the true dist tag, given the spec and the nvr. I've applied similar changes here for review.
added in, looks good to me, not tested though.
Also, i wonder if spectool might be brought into the loop at some point to address some of these things ?
- KB
On Tue, Jun 10, 2014 at 10:35 AM, Mike McLean <mikem@imponderable.org mailto:mikem@imponderable.org> wrote:
Also, I suggest piping that git log output through |grep import |head -n 1. No need to process the entire history and we could have non-import commits. E.g. attached patch On Tue, Jun 10, 2014 at 10:29 AM, Karanbir Singh <mail-lists@karan.org <mailto:mail-lists@karan.org>> wrote: good spot, pushed. On 06/10/2014 03:27 PM, Mike McLean wrote: > typo > > -- Karanbir Singh +44-207-0999389 <tel:%2B44-207-0999389> | http://www.karan.org/ | twitter.com/kbsingh <http://twitter.com/kbsingh> GnuPG Key : http://www.karan.org/publickey.asc _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org <mailto:CentOS-devel@centos.org> http://lists.centos.org/mailman/listinfo/centos-devel
CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
Hi
On 06/10/2014 03:35 PM, Mike McLean wrote:
Also, I suggest piping that git log output through |grep import |head -n
- No need to process the entire history and we could have non-import
commits. E.g. attached patch
added in. I think we might need to sometimes consider being able to build the entire stock of srpms for a specific repo / branch; in that case we might need more tools to do the rewind / walk down the branch. and in that case, this -n1 would be perfect.
- KB
derp, thanks! I sent the wrong diff....
On 06/10/2014 09:27 AM, Mike McLean wrote:
typo
On Tue, Jun 10, 2014 at 10:12 AM, Karanbir Singh <mail-lists@karan.org mailto:mail-lists@karan.org> wrote:
Applied, pushed, thanks https://git.centos.org/summary/centos-git-common On 06/10/2014 03:08 PM, Pat Riehecky wrote: > From: Pat Riehecky <riehecky@fnal.gov <mailto:riehecky@fnal.gov>> > > --- > return_disttag.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 71 insertions(+), 0 deletions(-) > create mode 100755 return_disttag.sh > > diff --git a/return_disttag.sh b/return_disttag.sh > new file mode 100755 > index 0000000..cc4829c > --- /dev/null > +++ b/return_disttag.sh > @@ -0,0 +1,71 @@ > +#!/bin/bash -u > +# > +# Extracts what appears to be the value of %{dist} from the commit message > +# > +# Might want to drop this in ~/bin/ and chmod u+x it > + > +##################################################################### > +usage() { > + echo '' >&2 > + echo "$0 [-hr]" >&2 > + echo '' >&2 > + echo ' -h: This help message' >&2 > + echo ' -r: Use the Redhat tag rather than centos tag' >&2 > + echo '' >&2 > + echo ' Attempt to extract what appears to be the value of %{dist}' >&2 > + echo ' from the git.centos.org <http://git.centos.org> commit message' >&2 > + exit 1 > +} > + > + > +##################################################################### > +# setup args in the right order for making getopt evaluation > +# nice and easy. You'll need to read the manpages for more info > +args=$(getopt -o hr -- "$@") > +if [[ $? -ne 0 ]]; then > + usage > +fi > +eval set -- "$args" > + > +RHELTAG=0 > +for arg in $@; do > + case $1 in > + -- ) > + # end of getopt args, shift off the -- and get out of the loop > + shift > + break 2 > + ;; > + -r ) > + # skip any package with 'centos' in the dist area > + RHELTAG=1 > + ;; > + -h ) > + # get help > + usage > + ;; > + esac > +done > + > +packagename=$(basename `pwd`) > +metadata=.${packagename}.metadata > + > +if [[ ! -e ${metadata} ]] || [[ ! -d .git ]] || [[ ! -d SOURCES ]]; then > + echo 'You need to run this from inside a sources git repo' > + exit 1 > +fi > + > +msg=$(git log --pretty=format:"%s") > +pkg=$(echo ${msg} | cut -d' ' -f2) > + > +if [[ ${RHELTAG} -eq 0 ]]; then > + thispkg=(echo ${pkg} | head -1) > +elif [[ ${RHELTAG} -eq 1 ]]; then > + thispkg=(echo ${pkg} grep -v centos | head -1) > +else > + echo 'Something went terribly wrong' > + exit 1 > +fi > + > +tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]]) > + > +echo ${tag} > -- Karanbir Singh +44-207-0999389 <tel:%2B44-207-0999389> | http://www.karan.org/ | twitter.com/kbsingh <http://twitter.com/kbsingh> GnuPG Key : http://www.karan.org/publickey.asc _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org <mailto:CentOS-devel@centos.org> http://lists.centos.org/mailman/listinfo/centos-devel
CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
Maybe I'm too sleep deprived to make sense of what I'm reading, but...
On 2014-06-10 16:12, Karanbir Singh wrote:
On 06/10/2014 03:08 PM, Pat Riehecky wrote:
From: Pat Riehecky riehecky@fnal.gov
<snip>
+##################################################################### +# setup args in the right order for making getopt evaluation +# nice and easy. You'll need to read the manpages for more info +args=$(getopt -o hr -- "$@") +if [[ $? -ne 0 ]]; then
- usage
+fi +eval set -- "$args"
+RHELTAG=0 +for arg in $@; do
Shouldn't this be quoted (or just `for arg;`)? Otherwise, why not just use `$args` and skip the `eval set ...`?
- case $1 in
-- )
# end of getopt args, shift off the -- and get out of the loop
<snip>
- exit 1
+fi
+msg=$(git log --pretty=format:"%s") +pkg=$(echo ${msg} | cut -d' ' -f2)
More missing quoting?
+if [[ ${RHELTAG} -eq 0 ]]; then
- thispkg=(echo ${pkg} | head -1)
+elif [[ ${RHELTAG} -eq 1 ]]; then
- thispkg=(echo ${pkg} grep -v centos | head -1)
In addition to the already mentioned missing $:s, there should presumably be a pipe before that `grep`, and unless that `head` is redundant, `${pkg}` should be quoted. (Unless there's some portability issue I'm missing, isn't `grep -v -m 1 -e centos` equivalent?)
+else
- echo 'Something went terribly wrong'
- exit 1
+fi
+tag=$(echo ${thispkg} | awk -F"-" '{print $NF}' | tr '.' '\012'| grep -e el[[:digit:]])
+echo ${tag}
On Wed, Jun 11, 2014 at 5:08 AM, Elias Persson delreich@takeit.se wrote:
Maybe I'm too sleep deprived to make sense of what I'm reading, but...
On 2014-06-10 16:12, Karanbir Singh wrote:
On 06/10/2014 03:08 PM, Pat Riehecky wrote:
From: Pat Riehecky riehecky@fnal.gov
<snip> >> +##################################################################### >> +# setup args in the right order for making getopt evaluation >> +# nice and easy. You'll need to read the manpages for more info >> +args=$(getopt -o hr -- "$@") >> +if [[ $? -ne 0 ]]; then >> + usage >> +fi >> +eval set -- "$args" >> + >> +RHELTAG=0 >> +for arg in $@; do
Shouldn't this be quoted (or just `for arg;`)? Otherwise, why not just use `$args` and skip the `eval set ...`?
Agreed. "$@" to preserve the argv array. Granted, I don't think the script is likely to run into any such cases, but still good practice. An unquoted $@ is a little silly anyway -- that's what $* is for.
- case $1 in
-- )
# end of getopt args, shift off the -- and get out of the
loop
<snip> >> + exit 1 >> +fi >> + >> +msg=$(git log --pretty=format:"%s") >> +pkg=$(echo ${msg} | cut -d' ' -f2)
More missing quoting?
Well here it's actually arguable. You don't need quotes around a single command substitution in an assignment. Not that they'd hurt anything
As for ${msg} vs "${msg}", it's just a matter of collapsing whitespace. In fact, unquoted is beneficial if there happens to be a stray space in the commit message. # msg="import foo-1-1" # pkg=$(echo ${msg} | cut -d' ' -f2) # printf "%q\n" "$pkg" foo-1-1 # pkg=$(echo "${msg}" | cut -d' ' -f2) # printf "%q\n" "$pkg" ''
Personally, I'd probably just let bash do the splitting. E.g. # set -- $msg # pkg="$2" # printf "%q\n" "$pkg" foo-1-1
+if [[ ${RHELTAG} -eq 0 ]]; then
- thispkg=(echo ${pkg} | head -1)
+elif [[ ${RHELTAG} -eq 1 ]]; then
- thispkg=(echo ${pkg} grep -v centos | head -1)
In addition to the already mentioned missing $:s, there should presumably be a pipe before that `grep`, and unless that `head` is redundant, `${pkg}` should be quoted. (Unless there's some portability issue I'm missing, isn't `grep -v -m 1 -e centos` equivalent?)
Yes, the pipe is missing and ${pkg} should be quoted. The head was not originally redundant, but one of my patches made it so (and inadvertently broke the script's -r option).
Actually, about to post a new patch which will address the quoting and also allow the script to work even if the repo is cloned to a differently named directory.
On Wed, Jun 11, 2014 at 7:26 PM, Mike McLean mikem@imponderable.org wrote:
Actually, about to post a new patch which will address the quoting and also allow the script to work even if the repo is cloned to a differently named directory.
I started out trying to make the script work even if the directory name varies. Then I noticed I'd broken the -r option, so I fixed that too. Also added a sanity check to make sure the %{dist} value we generate really recreates the nvr, and addressed some of the quoting concerns.
On 06/12/2014 01:03 AM, Mike McLean wrote:
On Wed, Jun 11, 2014 at 7:26 PM, Mike McLean <mikem@imponderable.org mailto:mikem@imponderable.org> wrote:
Actually, about to post a new patch which will address the quoting and also allow the script to work even if the repo is cloned to a differently named directory.
I started out trying to make the script work even if the directory name varies. Then I noticed I'd broken the -r option, so I fixed that too. Also added a sanity check to make sure the %{dist} value we generate really recreates the nvr, and addressed some of the quoting concerns.
looks good, posted.
- KB