Compare commits
3 commits
andrew/pre
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fe6e678e59 | ||
![]() |
48a784dde8 | ||
![]() |
67e3a7be36 |
8 changed files with 45 additions and 98 deletions
|
@ -292,9 +292,6 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
|
|||
exclamation mark. Subsequent matches will override previous ones. A leading
|
||||
literal exclamation mark or backslash needs to be escaped.
|
||||
|
||||
*\--preremove <package>::
|
||||
Uninstall 'package' before performing the requested installation. Multiple
|
||||
packages can be specified by separating them with commas.
|
||||
|
||||
Query Options (apply to '-Q')[[QO]]
|
||||
-----------------------------------
|
||||
|
|
|
@ -1118,31 +1118,34 @@ static int finalize_download_locations(alpm_list_t *payloads, const char *localp
|
|||
filename = payload->tempfile_name;
|
||||
}
|
||||
|
||||
/* if neither file exists then the download failed and logged an error for us */
|
||||
if(!filename) {
|
||||
returnvalue = -1;
|
||||
continue;
|
||||
}
|
||||
if(filename) {
|
||||
int ret = move_file(filename, localpath);
|
||||
|
||||
int ret = move_file(filename, localpath);
|
||||
|
||||
if(ret == -1) {
|
||||
/* ignore error if the file already existed - only signature file was downloaded */
|
||||
if(payload->mtime_existing_file == 0) {
|
||||
_alpm_log(payload->handle, ALPM_LOG_ERROR, _("could not move %s into %s (%s)\n"),
|
||||
filename, localpath, strerror(errno));
|
||||
returnvalue = -1;
|
||||
if(ret == -1) {
|
||||
if(payload->mtime_existing_file == 0) {
|
||||
_alpm_log(payload->handle, ALPM_LOG_ERROR, _("could not move %s into %s (%s)\n"),
|
||||
filename, localpath, strerror(errno));
|
||||
returnvalue = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (payload->download_signature) {
|
||||
const char sig_suffix[] = ".sig";
|
||||
char *sig_filename = NULL;
|
||||
size_t sig_filename_len = strlen(filename) + sizeof(sig_suffix);
|
||||
MALLOC(sig_filename, sig_filename_len, continue);
|
||||
snprintf(sig_filename, sig_filename_len, "%s%s", filename, sig_suffix);
|
||||
move_file(sig_filename, localpath);
|
||||
FREE(sig_filename);
|
||||
char *sig_filename;
|
||||
int ret;
|
||||
|
||||
filename = payload->destfile_name ? payload->destfile_name : payload->tempfile_name;
|
||||
sig_filename = _alpm_get_fullpath("", filename, ".sig");
|
||||
ASSERT(sig_filename, RET_ERR(payload->handle, ALPM_ERR_MEMORY, -1));
|
||||
ret = move_file(sig_filename, localpath);
|
||||
free(sig_filename);
|
||||
|
||||
if(ret == -1) {
|
||||
sig_filename = _alpm_get_fullpath("", filename, ".sig.part");
|
||||
ASSERT(sig_filename, RET_ERR(payload->handle, ALPM_ERR_MEMORY, -1));
|
||||
move_file(sig_filename, localpath);
|
||||
free(sig_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnvalue;
|
||||
|
@ -1296,7 +1299,7 @@ download_signature:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static char *filecache_find_url(alpm_handle_t *handle, const char *url)
|
||||
static const char *url_basename(const char *url)
|
||||
{
|
||||
const char *filebase = strrchr(url, '/');
|
||||
|
||||
|
@ -1309,7 +1312,7 @@ static char *filecache_find_url(alpm_handle_t *handle, const char *url)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return _alpm_filecache_find(handle, filebase);
|
||||
return filebase;
|
||||
}
|
||||
|
||||
int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls,
|
||||
|
@ -1331,9 +1334,26 @@ int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls,
|
|||
|
||||
for(i = urls; i; i = i->next) {
|
||||
char *url = i->data;
|
||||
char *filepath = NULL;
|
||||
const char *urlbase = url_basename(url);
|
||||
|
||||
if(urlbase) {
|
||||
/* attempt to find the file in our pkgcache */
|
||||
filepath = _alpm_filecache_find(handle, urlbase);
|
||||
|
||||
if(filepath && (handle->siglevel & ALPM_SIG_PACKAGE)) {
|
||||
char *sig_filename = _alpm_get_fullpath("", urlbase, ".sig");
|
||||
|
||||
/* if there's no .sig file then forget about the pkg file and go for download */
|
||||
if(!_alpm_filecache_exists(handle, sig_filename)) {
|
||||
free(filepath);
|
||||
filepath = NULL;
|
||||
}
|
||||
|
||||
free(sig_filename);
|
||||
}
|
||||
}
|
||||
|
||||
/* attempt to find the file in our pkgcache */
|
||||
char *filepath = filecache_find_url(handle, url);
|
||||
if(filepath) {
|
||||
/* the file is locally cached so add it to the output right away */
|
||||
alpm_list_append(fetched, filepath);
|
||||
|
|
|
@ -17,7 +17,6 @@ sources = [
|
|||
'package_function.sh.in',
|
||||
'package_function_variable.sh.in',
|
||||
'pkgbase.sh.in',
|
||||
'pkglist.sh.in',
|
||||
'pkgname.sh.in',
|
||||
'pkgrel.sh.in',
|
||||
'pkgver.sh.in',
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# pkglist.sh - Check the packages selected to build exist.
|
||||
#
|
||||
# Copyright (c) 2014-2025 Pacman Development Team <pacman-dev@lists.archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH" ]] && return
|
||||
LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH=1
|
||||
|
||||
MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}
|
||||
|
||||
source "$MAKEPKG_LIBRARY/util/message.sh"
|
||||
source "$MAKEPKG_LIBRARY/util/util.sh"
|
||||
|
||||
|
||||
lint_pkgbuild_functions+=('lint_pkglist')
|
||||
|
||||
|
||||
lint_pkglist() {
|
||||
local i ret=0
|
||||
|
||||
for i in "${PKGLIST[@]}"; do
|
||||
if ! in_array "$i" "${pkgname[@]}"; then
|
||||
error "$(gettext "Requested package %s is not provided in %s")" "$i" "$BUILDFILE"
|
||||
ret=1
|
||||
fi
|
||||
done
|
||||
|
||||
return $ret
|
||||
}
|
|
@ -150,7 +150,6 @@ int config_free(config_t *oldconfig)
|
|||
FREELIST(oldconfig->noupgrade);
|
||||
FREELIST(oldconfig->noextract);
|
||||
FREELIST(oldconfig->overwrite_files);
|
||||
FREELIST(oldconfig->preremove);
|
||||
free(oldconfig->configfile);
|
||||
free(oldconfig->sysroot);
|
||||
free(oldconfig->rootdir);
|
||||
|
|
|
@ -134,8 +134,6 @@ typedef struct __config_t {
|
|||
/* our connection to libalpm */
|
||||
alpm_handle_t *handle;
|
||||
|
||||
alpm_list_t *preremove;
|
||||
|
||||
alpm_list_t *explicit_adds;
|
||||
alpm_list_t *explicit_removes;
|
||||
|
||||
|
@ -216,8 +214,7 @@ enum {
|
|||
OP_REFRESH,
|
||||
OP_ASSUMEINSTALLED,
|
||||
OP_DISABLEDLTIMEOUT,
|
||||
OP_DISABLESANDBOX,
|
||||
OP_PREREMOVE,
|
||||
OP_DISABLESANDBOX
|
||||
};
|
||||
|
||||
/* clean method */
|
||||
|
|
|
@ -196,8 +196,6 @@ static void usage(int op, const char * const myname)
|
|||
addlist(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
|
||||
addlist(_(" --ignoregroup <grp>\n"
|
||||
" ignore a group upgrade (can be used more than once)\n"));
|
||||
addlist(_(" --preremove <pkg>\n"));
|
||||
addlist(_(" uninstall <pkg> before performing installation\n"));
|
||||
__attribute__((fallthrough));
|
||||
case PM_OP_REMOVE:
|
||||
addlist(_(" -d, --nodeps skip dependency version checks (-dd to skip all checks)\n"));
|
||||
|
@ -772,9 +770,6 @@ static int parsearg_upgrade(int opt)
|
|||
case OP_IGNOREGROUP:
|
||||
parsearg_util_addlist(&(config->ignoregrp));
|
||||
break;
|
||||
case OP_PREREMOVE:
|
||||
parsearg_util_addlist(&(config->preremove));
|
||||
break;
|
||||
case OP_DOWNLOADONLY:
|
||||
case 'w':
|
||||
config->op_s_downloadonly = 1;
|
||||
|
@ -987,7 +982,6 @@ static int parseargs(int argc, char *argv[])
|
|||
{"color", required_argument, 0, OP_COLOR},
|
||||
{"disable-download-timeout", no_argument, 0, OP_DISABLEDLTIMEOUT},
|
||||
{"disable-sandbox", no_argument, 0, OP_DISABLESANDBOX},
|
||||
{"preremove", required_argument, 0, OP_PREREMOVE},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -717,21 +717,6 @@ static int sync_trans(alpm_list_t *targets)
|
|||
}
|
||||
}
|
||||
|
||||
for(i = config->preremove; i; i = i->next) {
|
||||
alpm_pkg_t *pkg;
|
||||
const char *pname = i->data;
|
||||
alpm_db_t *db_local = alpm_get_localdb(config->handle);
|
||||
|
||||
if((pkg = alpm_db_get_pkg(db_local, pname)) != NULL) {
|
||||
if(alpm_remove_pkg(config->handle, pkg) == -1) {
|
||||
alpm_errno_t err = alpm_errno(config->handle);
|
||||
pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", pname, alpm_strerror(err));
|
||||
retval = 1;
|
||||
}
|
||||
config->explicit_removes = alpm_list_add(config->explicit_removes, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
if(retval) {
|
||||
trans_release();
|
||||
return retval;
|
||||
|
|
Loading…
Add table
Reference in a new issue