Skip to content

Automatic broken link detection and rebuild #5

@petronny

Description

@petronny

Here is the script that I currently use to detect broken links.

#!/bin/bash
dbdir=/var/lib/pacman/sync
repo=$1

tmp=$(mktemp -d --tmpdir check-links.XXXXXXXXXX)

for i in core extra community arch4edu
do
        tar zxf $dbdir/$i.files --wildcards '*/files' -O 2>/dev/null
done | grep -a '\.so' | sed 's|.*/||g' | sort | uniq > $tmp/files

mkdir -p $tmp/links
tar -C $tmp/links -zxf $repo --wildcards '*/links'
sed 's|.*/||g' -i $(find $tmp/links -type f -name 'links')
sort $(find $tmp/links -name links -type f) | uniq > $tmp/sodepends

diff $tmp/files $tmp/sodepends | grep -P '^\>' | cut -c 3- > $tmp/broken-links
sed '/^%LINKS%$/d' -i $tmp/broken-links
sed '/^libc\.musl-x86_64\.so.*$/d' -i $tmp/broken-links
sed '/^ld-linux\.so.*$/d' -i $tmp/broken-links
sed '/^ld\.so.*$/d' -i $tmp/broken-links

cd $tmp/links

for link in $(cat $tmp/broken-links)
do
        grep -Fx "$link" -r .
done | sort | cut -c 3-

To use it, first update your local pacman database

pacman -Sy
pacman -Fy

Then

./check-links.sh /path/to/arch4edu.links.tar.gz

It will still has false alarmed packages. We need add a new setting in cactus.yaml like check-links:

  • when check-links: true, we find out their pkgbase path in arch4edu and trigger the rebuild.
  • when check-links: false, we ignore their outputs in check-links.sh.
  • when unset, we add a warning somehow to let everybody know it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions