Skip to content

Commit

Permalink
Improve import.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Oct 22, 2024
1 parent 5342aed commit b8c72e2
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 14 deletions.
31 changes: 20 additions & 11 deletions reprepro/import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,39 @@ function filter {
}

# Import sources
printf "\nImporting source packages"
if [ "$ARCH" == "amd64" ]; then
printf "\nImporting source packages\n"
for f in "$INCOMING_DIR"/*.dsc; do
echo "$f"
[ -f "$f" ] || break # Handle case of no files found
echo "${f#"$INCOMING_DIR/"}"
reprepro includedsc "$DISTRO" "$f" | filter
done
fi

# Import packages
printf "\nImporting binary packages"
reprepro -A "$ARCH" includedeb "$DISTRO" "$INCOMING_DIR"/*.deb | filter
printf "\nImporting binary packages\n"
for f in "$INCOMING_DIR"/*.deb; do
[ -f "$f" ] || break # Handle case of no files found
echo "${f#"$INCOMING_DIR/"}"
reprepro -A "$ARCH" includedeb "$DISTRO" "$f" | filter
done

# Cleanup files
(cd "$INCOMING_DIR" || exit 1; rm -f ./*.log ./*.deb ./*.dsc ./*.tar.gz ./*.tar.xz ./*.changes ./*.buildinfo)

# Rename, Import, and Cleanup ddeb files (if existing)
printf "\nImporting debug packages"
if [ -n "$(ls -A "$INCOMING_DIR"/*.ddeb 2>/dev/null)" ]; then
mmv "$INCOMING_DIR/*.ddeb" "$INCOMING_DIR/#1.deb"
reprepro -A "$ARCH" -C main-dbg includedeb "$DISTRO" "$INCOMING_DIR"/*.deb | filter
(cd "$INCOMING_DIR" || exit 1; rm ./*.deb)
fi
printf "\nImporting debug packages\n"
for f in "$INCOMING_DIR"/*.ddeb; do
[ -f "$f" ] || break # Handle case of no files found
echo "${f#"$INCOMING_DIR/"}"
# remove .ddeb suffix
f=${f%.ddeb}
mv "${f}.ddeb" "${f}.deb"
reprepro -A "$ARCH" -C main-dbg includedeb "$DISTRO" "${f}.deb" | filter
done
(cd "$INCOMING_DIR" || exit 1; rm ./*.deb)

printf "\nExporting"
printf "\nExporting\n"
reprepro export "$DISTRO"

# Merge local.yaml into ros-one.yaml
Expand Down
43 changes: 43 additions & 0 deletions reprepro/reinit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

function process {
local f=$1
echo "$f"
local args=""
local distros=""

case "$f" in
*_arm64.deb) args="-A arm64" ;;
*_amd64.deb) args="-A amd64" ;;
*_all.deb) distros="jammy noble";;
*)
echo "Unknown arch"
exit 1
;;
esac

if [[ $f == *-dbgsym_* ]]; then
args="$args -C main-dbg"
fi

case $f in
*jammy.*) distros="jammy" ;;
*noble.*) distros="noble" ;;
*)
if [ -z "$distros" ]; then
echo "Unknown distro"
exit 1
fi
;;
esac

# shellcheck disable=SC2086
for distro in $distros; do
reprepro $args includedeb "$distro"-testing "$f"
done
}

while IFS= read -r -d '' file
do
process "$file"
done < <(find /var/www/repos -iname "*.deb" -print0)
14 changes: 11 additions & 3 deletions reprepro/stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ fi
[ -z "$ARCH" ] && echo "ARCH undefined" && exit 1
[ -z "$REPO" ] && echo "github repo undefined" && exit 1

# Move packages from testing to production stage
pkgs=$(reprepro -A "$ARCH" list "$DISTRO-testing" | grep -v "|source" | cut -s -d " " -f 2)
# Move deb packages from testing to production stage
pkgs=$(reprepro -A "$ARCH" -T deb list "$DISTRO-testing" | cut -s -d " " -f 2)
# shellcheck disable=SC2086
reprepro -A "$ARCH" copy "$DISTRO" "$DISTRO-testing" $pkgs

# reprepro remove "$DISTRO-testing" "$pkgs"
# Move dsc packages from testing to production stage
if [ "$ARCH" == "amd64" ]; then
pkgs=$(reprepro -T dsc list "$DISTRO-testing" | cut -s -d " " -f 2)
for pkg in $pkgs; do
reprepro -T dsc copysrc "$DISTRO" "$DISTRO-testing" "$pkg"
done
fi

# reprepro remove "$DISTRO-testing" $pkgs

0 comments on commit b8c72e2

Please sign in to comment.