[pacman-dev] [PATCH] makepkg: Improve optdepends extraction
Prevents issues where optdepends descriptions contain a bracket. Also, strip all comments from arrays before joining them. Fixes FS#23307. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 23081fe..bb7616c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1258,7 +1258,8 @@ check_sanity() { fi local provides_list=() - eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | sed "s/provides=/provides_list+=/") + eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | \ + sed -e "s/provides=/provides_list+=/" -e "s/#.*//") for i in ${provides_list[@]}; do if [[ $i != ${i//</} || $i != ${i//>/} ]]; then error "$(gettext "Provides array cannot contain comparison (< or >) operators.")" @@ -1267,7 +1268,8 @@ check_sanity() { done local backup_list=() - eval $(awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | sed "s/backup=/backup_list+=/") + eval $(awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | \ + sed -e "s/backup=/backup_list+=/" -e "s/#.*//") for i in "${backup_list[@]}"; do if [[ ${i:0:1} = "/" ]]; then error "$(gettext "Backup entry should not contain leading slash : %s")" "$i" @@ -1276,7 +1278,8 @@ check_sanity() { done local optdepends_list=() - eval $(awk '/^[[:space:]]*optdepends=/,/\)/' "$BUILDFILE" | sed "s/optdepends=/optdepends_list+=/") + eval $(awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(|#.*)$/' "$BUILDFILE" | \ + sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//") for i in "${optdepends_list[@]}"; do local pkg=${i%%:*} if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]+$ ]]; then @@ -1300,7 +1303,8 @@ check_sanity() { local valid_options=1 local known kopt options_list - eval $(awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | sed "s/options=/options_list+=/") + eval $(awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | \ + sed -e "s/options=/options_list+=/" -e "s/#.*//") for i in ${options_list[@]}; do known=0 # check if option matches a known option or its inverse -- 1.7.4.1
Fixes FS#23343. Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/be_sync.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 6c0d2d6..216213b 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -84,6 +84,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) struct stat buf; size_t len; int ret; + mode_t oldmask; ALPM_LOG_FUNC; @@ -104,6 +105,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1)); sprintf(syncpath, "%s%s", dbpath, "sync/"); + /* make sure we have a sane umask */ + oldmask = umask(0022); + if(stat(syncpath, &buf) != 0) { _alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", syncpath); @@ -124,6 +128,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) ret = _alpm_download_single_file(dbfile, db->servers, syncpath, force); free(dbfile); free(syncpath); + umask(oldmask); if(ret == 1) { /* files match, do nothing */ -- 1.7.4.1
On Sat, Mar 19, 2011 at 11:24:22AM +1000, Allan McRae wrote:
Fixes FS#23343.
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/be_sync.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 6c0d2d6..216213b 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -84,6 +84,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) struct stat buf; size_t len; int ret; + mode_t oldmask;
ALPM_LOG_FUNC;
@@ -104,6 +105,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1)); sprintf(syncpath, "%s%s", dbpath, "sync/");
+ /* make sure we have a sane umask */ + oldmask = umask(0022);
Shouldn't this be 0133? We don't need the executable bit on tarballs.
+ if(stat(syncpath, &buf) != 0) { _alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", syncpath); @@ -124,6 +128,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) ret = _alpm_download_single_file(dbfile, db->servers, syncpath, force); free(dbfile); free(syncpath); + umask(oldmask);
if(ret == 1) { /* files match, do nothing */ -- 1.7.4.1
d
participants (2)
-
Allan McRae
-
Dave Reisner