diff options
Diffstat (limited to 'src/share/xbs/db-functions')
-rw-r--r-- | src/share/xbs/db-functions | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/share/xbs/db-functions b/src/share/xbs/db-functions index 62260bb..315ebbc 100644 --- a/src/share/xbs/db-functions +++ b/src/share/xbs/db-functions @@ -43,7 +43,7 @@ REPO_MODIFIED=0 . "$(librelib common)" script_lock() { - local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" + local LOCKDIR="$TMP_DIR/.scriptlock.${0##*/}" if ! mkdir "$LOCKDIR" >/dev/null 2>&1 ; then local _owner="$(/usr/bin/stat -c %U "$LOCKDIR")" error "Script %s is already locked by %s." "${0##*/}" "$_owner" @@ -55,7 +55,7 @@ script_lock() { } script_unlock() { - local LOCKDIR="$TMPDIR/.scriptlock.${0##*/}" + local LOCKDIR="$TMP_DIR/.scriptlock.${0##*/}" if [ ! -d "$LOCKDIR" ]; then warning "Script %s was not locked!" "${0##*/}" restore_umask @@ -76,19 +76,19 @@ cleanup() { for l in "${LOCKS[@]}"; do repo=${l%.*} arch=${l#*.} - if [ -d "$TMPDIR/.repolock.$repo.$arch" ]; then + if [ -d "$TMP_DIR/.repolock.$repo.$arch" ]; then msg "Removing left over lock from [%s] (%s)" "${repo}" "${arch}" repo_unlock "$repo" "$arch" fi done - if [ -d "$TMPDIR/.scriptlock.${0##*/}" ]; then + if [ -d "$TMP_DIR/.scriptlock.${0##*/}" ]; then msg "Removing left over lock from %s" "${0##*/}" script_unlock fi rm -rf "$WORKDIR" if (( REPO_MODIFIED )); then - date +%s > "${FTP_BASE}/lastupdate" + date +%s > "${REPO_DIR}/lastupdate" fi [ "$1" ] && exit "$1" @@ -100,9 +100,9 @@ trap cleanup EXIT #repo_lock <repo-name> <arch> [timeout] repo_lock () { - local LOCKDIR="$TMPDIR/.repolock.$1.$2" - local DBLOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${DBEXT}.lck" - local FILESLOCKFILE="${FTP_BASE}/${1}/os/${2}/${1}${FILESEXT}.lck" + local LOCKDIR="$TMP_DIR/.repolock.$1.$2" + local DBLOCKFILE="${REPO_DIR}/${1}/os/${2}/${1}${DB_EXT}.lck" + local FILESLOCKFILE="${REPO_DIR}/${1}/os/${2}/${1}${FILES_EXT}.lck" local _count local _trial local _timeout @@ -148,7 +148,7 @@ repo_lock () { } repo_unlock () { #repo_unlock <repo-name> <arch> - local LOCKDIR="$TMPDIR/.repolock.$1.$2" + local LOCKDIR="$TMP_DIR/.repolock.$1.$2" if [ ! -d "$LOCKDIR" ]; then warning "Repo lock [%s] (%s) was not locked!" "${1}" "${2}" restore_umask @@ -360,10 +360,10 @@ check_pkgrepos() { local pkgarch="$(getpkgarch "${pkgfile}")" [ $? -ge 1 ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT} ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXT}.sig ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}" ] && return 1 - [ -f "${FTP_BASE}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1 + [ -f "${REPO_DIR}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKG_EXT} ] && return 1 + [ -f "${REPO_DIR}/${PKGPOOL}/${pkgname}-${pkgver}-${pkgarch}"${PKG_EXT}.sig ] && return 1 + [ -f "${REPO_DIR}/${PKGPOOL}/${pkgfile##*/}" ] && return 1 + [ -f "${REPO_DIR}/${PKGPOOL}/${pkgfile##*/}.sig" ] && return 1 return 0 } @@ -386,14 +386,14 @@ check_repo_permission() { in_array "${repo}" "${PKGREPOS[@]}" || return 1 - [ -w "$FTP_BASE/${PKGPOOL}" ] || return 1 + [ -w "$REPO_DIR/${PKGPOOL}" ] || return 1 local arch for arch in "${ARCHES[@]}"; do - local dir="${FTP_BASE}/${repo}/os/${arch}/" + local dir="${REPO_DIR}/${repo}/os/${arch}/" [ -w "${dir}" ] || return 1 - [ -f "${dir}${repo}"${DBEXT} -a ! -w "${dir}${repo}"${DBEXT} ] && return 1 - [ -f "${dir}${repo}"${FILESEXT} -a ! -w "${dir}${repo}"${FILESEXT} ] && return 1 + [ -f "${dir}${repo}"${DB_EXT} -a ! -w "${dir}${repo}"${DB_EXT} ] && return 1 + [ -f "${dir}${repo}"${FILES_EXT} -a ! -w "${dir}${repo}"${FILES_EXT} ] && return 1 done return 0 @@ -402,8 +402,8 @@ check_repo_permission() { set_repo_permission() { local repo=$1 local arch=$2 - local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" - local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" + local dbfile="${REPO_DIR}/${repo}/os/${arch}/${repo}${DB_EXT}" + local filesfile="${REPO_DIR}/${repo}/os/${arch}/${repo}${FILES_EXT}" if [ -w "${dbfile}" ]; then local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") @@ -416,30 +416,30 @@ set_repo_permission() { fi } -arch_repo_add() { +pkg_repo_add() { local repo=$1 local arch=$2 local pkgs=("${@:3}") printf -v pkgs_str -- '%q ' "${pkgs[@]}" # package files might be relative to repo dir - pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null - /usr/bin/repo-add -q "${repo}${DBEXT}" "${pkgs[@]}" \ - || error 'repo-add %q %s' "${repo}${DBEXT}" "${pkgs_str% }" - /usr/bin/repo-add -f -q "${repo}${FILESEXT}" "${pkgs[@]}" \ - || error 'repo-add -f %q %s' "${repo}${FILESEXT}" "${pkgs_str% }" + pushd "${REPO_DIR}/${repo}/os/${arch}" >/dev/null + /usr/bin/repo-add -q "${repo}${DB_EXT}" "${pkgs[@]}" \ + || error 'repo-add %q %s' "${repo}${DB_EXT}" "${pkgs_str% }" + /usr/bin/repo-add -f -q "${repo}${FILES_EXT}" "${pkgs[@]}" \ + || error 'repo-add -f %q %s' "${repo}${FILES_EXT}" "${pkgs_str% }" popd >/dev/null set_repo_permission "${repo}" "${arch}" REPO_MODIFIED=1 } -arch_repo_remove() { +pkg_repo_rm() { local repo=$1 local arch=$2 local pkgs=("${@:3}") - local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" - local filesfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${FILESEXT}" + local dbfile="${REPO_DIR}/${repo}/os/${arch}/${repo}${DB_EXT}" + local filesfile="${REPO_DIR}/${repo}/os/${arch}/${repo}${FILES_EXT}" if [ ! -f "${dbfile}" ]; then error "No database found at '%s'" "${dbfile}" |