Skip to content

Commit

Permalink
tools/unobsolete: Add a tool to restore 'obsolete' packages
Browse files Browse the repository at this point in the history
* We do some checks for collisions and then raise them from the dead
* We don't regenerate the repo.. we just wait for haikuporter to do it.
* workaround for haikuports/haikuporter#213
  • Loading branch information
kallisti5 committed Feb 20, 2021
1 parent 7d3576d commit 461403d
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tools/unobsolete
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# see https://github.com/haikuports/haikuporter/issues/213

if [[ $# -ne 2 ]]; then
echo "A dirty hack to unobsolete packages"
echo "usage: $0 <branch> <package-version-revision>"
exit 1
fi

BRANCH=$1
PACKAGE=$2

BASE=/var/lib/docker/plugins/0b25ebdee8b48451b1459c6c1965570c948ef97028d78e96057a0962b482ce84/propagated-mount/volumes/ci-packages/data
REPO=$BASE/repository/$BRANCH
BUILDER=$BASE/instances/$BRANCH

# sanity checks
if [[ ! -d $BASE ]]; then
echo "Invalid base haikuporter buildmaster directory!"
exit 1;
fi

PACKAGE_NAME=$(echo $PACKAGE | cut -d'-' -f1)
PACKAGE_VERSION=$(echo $PACKAGE | cut -d'-' -f2)
PACKAGE_REVISION=$(echo $PACKAGE | cut -d'-' -f3)

CURRENT=$(find $REPO -name "$PACKAGE_NAME-*.hpkg")
if [[ $CURRENT != "" ]]; then
echo "WARNING: found the following packages which may conflict..."
for i in $CURRENT; do
echo $i
done
exit 1
fi

OBSOLETES=$(find $BUILDER -name "$PACKAGE-*.hpkg" | grep .obsolete)
if [ -z "$OBSOLETES" ]; then
echo "WARNING: Didn't find any obsolete packages matching '$PACKAGE'"
exit 1;
fi

echo "Found the following obsolete packages..."
for i in $OBSOLETES; do
echo -n "..."
echo $i | sed "s%$BUILDER%%g";
done

echo "To resurrect them, press enter. Press <ctl+c> to cancel."
read

for i in $OBSOLETES; do
DIR=$(dirname $i)
ARCH=$(basename $i | cut -d- -f4 | cut -d. -f1)
echo "resurrecting $PACKAGE for $ARCH..."
cp $i $BUILDER/$ARCH/
cp $DIR/${PACKAGE_NAME}_source-$PACKAGE_VERSION-$PACKAGE_REVISION-*.hpkg $BUILDER/$ARCH/
cp $DIR/${PACKAGE_NAME}_debuginfo-$PACKAGE_VERSION-$PACKAGE_REVISION-*.hpkg $BUILDER/$ARCH/

# TODO: Should we be removing them from .obsolete?
done

echo "The next haikuporter buildmaster run should add $PACKAGE to the repos via hardlinks."

0 comments on commit 461403d

Please sign in to comment.