archlinux / asp

Arch Build Source Management Tool
MIT License
294 stars 34 forks source link

asp lists unavailable packages #19

Closed NicoHood closed 7 years ago

NicoHood commented 7 years ago
[arch@arch test]$ asp list-arches appdata-tools
remote: Counting objects: 38, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 38 (delta 6), reused 31 (delta 3)
Unpacking objects: 100% (38/38), done.
From git://git.archlinux.org/svntogit/packages
 * branch            packages/appdata-tools -> FETCH_HEAD
 * [new branch]      packages/appdata-tools -> packages/packages/appdata-tools

[arch@arch test]$ asp list-arches appdata-tools
falconindy commented 7 years ago

Ultimately, this seems like some to fix in SVN, no?

NicoHood commented 7 years ago

We have lots of outdated PKGBUILDs in svn, yes. They should be deleted if possible. pacman -Sl shows all packages, maybe this can be used as master reference which packages exist and which not?

falconindy commented 7 years ago

asp isn't interested in what pacman thinks. It mirrors the SVN repo. Why does this matter to you?

NicoHood commented 7 years ago

I want to parse all PKGBUILDs of all packages in the official repos.

I cannot just git clone the two svn2git repos, as they contain (as shown above) outdated data sometimes and duplicates (some PKGBUILDs exist in packages and community when they move from [community] to [extra]). Also svn2git always shows the latest commit, used for testing, but not the the normal repos. Asp clones the last tagged release.

So I found your asp tool. What I try to do now is write a script which:

Afterwards I want to parse all packages with my LSD.

For better understanding, this is what I got so far:

#!/bin/bash

#set -x
set -e

export ASPROOT=asp

ARCH="$(uname -m)"
# TODO use pacman -Sl instead of asp for available packages?
#PACKAGES="$(asp list-all 2>/dev/null)"
PACKAGES="$(pacman -Sl)"
PKGBUILD_PATH=PKGBUILDs

asp update
#rm -rf "${PKGBUILD_PATH}"
mkdir -p "${PKGBUILD_PATH}"
cd "${PKGBUILD_PATH}"

while read -r line; do
    # Get package data from input line
    # Sample: packages/bash
    #GIT_REPO="${line%/*}"
    #PACKAGE="${line#*/}"

    #echo $line
    PACKAGE="$(awk '{print $2}' <<< "${line}")"
    REPO="$(awk '{print $1}' <<< "${line}")"

    # Check package architecture
    ARCHES="$(asp list-arches ${PACKAGE} 2>/dev/null)"
    PKG_ARCH=""
    if [[ "${ARCHES}" == *"any"* ]]; then
        PKG_ARCH=any
    elif [[ "${ARCHES}" == *"${ARCH}"* ]]; then
        PKG_ARCH="${ARCH}"
    fi

    # Skip packages with invalid arch
    if [[ -z "${PKG_ARCH}" ]]; then
        echo "Warning: Package ${PACKAGE} not available for arch ${ARCH} or any!"
        continue
    fi

    # Skip packages with invalid repository
    #REPO="$(asp list-repos ${PACKAGE} 2>/dev/null)"
    if [[ -z "${REPO}" || "$(wc -l <<< "${REPO}")" -ne 1 ]]; then
        echo "Warning: Invalid repository for package ${PACKAGE}"
        exit
    fi

    echo "${PACKAGE}, ${REPO}, ${PKG_ARCH}"
    asp -a "${PKG_ARCH}" export "${REPO}/${PACKAGE}" || echo "Package already exists"
done <<< "${PACKAGES}"
falconindy commented 7 years ago

Well, svn2git is what asp is based on, so it seems odd to suggest that it doesn't have the repo-released packages.

What you're doing seems fine, with pacman -Sl as a starting to.