[pacman-dev] [PATCH] makepkg: extend test for hyphen prefixes to pkgbase and all pkgnames
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> --- Last patch before the big freeze... scripts/makepkg.sh.in | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..c451a36 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,8 +1139,8 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi if [ "$pkgver" != "${pkgver//-/}" ]; then @@ -1152,6 +1152,14 @@ check_sanity() { return 1 fi + local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done + if [ "$arch" != 'any' ]; then if ! in_array $CARCH ${arch[@]}; then if [ "$IGNOREARCH" -eq 0 ]; then -- 1.6.5.1
Cedric Staniewski wrote:
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
Last patch before the big freeze...
scripts/makepkg.sh.in | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..c451a36 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,8 +1139,8 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi
Unless I am missing something, pkgbase can start with anything. It is only used informationally in makepkg so does not cause problems with other tools.
if [ "$pkgver" != "${pkgver//-/}" ]; then @@ -1152,6 +1152,14 @@ check_sanity() { return 1 fi
+ local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done +
Why not keep this in the same place as the previous check on pkgname?
if [ "$arch" != 'any' ]; then if ! in_array $CARCH ${arch[@]}; then if [ "$IGNOREARCH" -eq 0 ]; then
Allan
Allan McRae wrote:
Cedric Staniewski wrote:
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
Last patch before the big freeze...
scripts/makepkg.sh.in | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..c451a36 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,8 +1139,8 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi
Unless I am missing something, pkgbase can start with anything. It is only used informationally in makepkg so does not cause problems with other tools.
In clean_up we had to use rm -f -- then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* if [ "$PKGFUNC" -eq 1 ]; then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* and according to PKGBUILD man page: pkgbase The name used to refer to the group of packages in the output of makepkg and in *the naming of source-only tarballs*. If not specified, the first element in the pkgname array is used. Just checked this (create_srcpackage): if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgbase}; then
if [ "$pkgver" != "${pkgver//-/}" ]; then @@ -1152,6 +1152,14 @@ check_sanity() { return 1 fi
+ local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done +
Why not keep this in the same place as the previous check on pkgname?
I moved that mostly because of the 'local name' part and the for loop, but it does not make any difference. So if you prefer the old place, I could move it there.
if [ "$arch" != 'any' ]; then if ! in_array $CARCH ${arch[@]}; then if [ "$IGNOREARCH" -eq 0 ]; then
Allan
Cedric Staniewski wrote:
Allan McRae wrote:
Cedric Staniewski wrote:
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
Last patch before the big freeze...
scripts/makepkg.sh.in | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..c451a36 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,8 +1139,8 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi
Unless I am missing something, pkgbase can start with anything. It is only used informationally in makepkg so does not cause problems with other tools.
In clean_up we had to use rm -f -- then
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* if [ "$PKGFUNC" -eq 1 ]; then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"*
and according to PKGBUILD man page:
pkgbase The name used to refer to the group of packages in the output of makepkg and in *the naming of source-only tarballs*. If not specified, the first element in the pkgname array is used.
Just checked this (create_srcpackage): if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgbase}; then
So it does.... I glad someone refers to the documentation!
if [ "$pkgver" != "${pkgver//-/}" ]; then @@ -1152,6 +1152,14 @@ check_sanity() { return 1 fi
+ local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done +
Why not keep this in the same place as the previous check on pkgname?
I moved that mostly because of the 'local name' part and the for loop, but it does not make any difference. So if you prefer the old place, I could move it there.
I prefer the old place as it keeps the checking in pkgname, pkgver, pkgrel order, which is the order given in the PKGBUILD prototype. Allan
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
So it does.... I glad someone refers to the documentation!
:) scripts/makepkg.sh.in | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..4c05ccc 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,10 +1139,17 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi + local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done if [ "$pkgver" != "${pkgver//-/}" ]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver" return 1 -- 1.6.5.1
Cedric Staniewski wrote:
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
So it does.... I glad someone refers to the documentation!
:)
scripts/makepkg.sh.in | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..4c05ccc 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,10 +1139,17 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi + local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done if [ "$pkgver" != "${pkgver//-/}" ]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver" return 1
Pushed to my working branch. I changed the order of the check of pkgbase and pkgname so that pkgname comes first like in the PKGBUILD prototype for no particular reason.... it just seemed nicer to me. Allan
Allan McRae wrote:
Cedric Staniewski wrote:
Since commit fb97d32, which brought in this test, support for split PKGBUILDs was added, and therefore, all values of pkgname and also pkgbase have to be checked now.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
So it does.... I glad someone refers to the documentation!
:)
scripts/makepkg.sh.in | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9cd7f2e..4c05ccc 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1139,10 +1139,17 @@ check_sanity() { error "$(gettext "%s is not allowed to be empty.")" "pkgrel" return 1 fi - if [ "${pkgname:0:1}" == "-" ]; then - error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + if [[ ${pkgbase:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" return 1 fi + local name + for name in "${pkgname[@]}"; do + if [[ ${name:0:1} = "-" ]]; then + error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname" + return 1 + fi + done if [ "$pkgver" != "${pkgver//-/}" ]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver" return 1
Pushed to my working branch. I changed the order of the check of pkgbase and pkgname so that pkgname comes first like in the PKGBUILD prototype for no particular reason.... it just seemed nicer to me.
Allan
Thought, I retained the order from the prototypes. Thanks for fixing this.
participants (2)
-
Allan McRae
-
Cedric Staniewski