ppa2pup: allow distro other than "$DISTRO_BINARY_COMPAT"
Currently, in ppa2pup, the name of the file which containes the package metadata (e.g. Packages-devuan-ascii-main) must match "DISTRO_BINARY_COMPAT" (e.g. devuan). I suggest that we first try to get the filename from sources-all and then only use "
DISTRO_BINARY_COMPAT" as a fallback. Here is some code:
function get_distro(){
local a_repo_url=$1
local a_distro_ver=$2
local a_stream=$3
cat /root/.pkg/sources-all | awk -v VER="$a_distro_ver" -v STREAM="$a_stream" -v URL="$a_repo_url" \
'BEGIN{FS="|"}
/^.+$/ {
if ( (index($4,URL) > 0 ) && ( index($3, VER "-" STREAM) > 0 ) ) {
split($3, array , "-" )
print array[2]
}
}'
}
/s243a/.../usr/sbin/ppa2pup#L32
function set_names(){
# if we didn't get the name from the ppa:foo/bar style URL
if [[ ! "$1" =~ 'ppa:' ]]
then
# check if this repo is already installed (find its name in Pkg sources files)
if [ -z "$repo_url" ]; then
PPA_NAME="$(grep -m1 "^${distro_ver}-${stream:-main}|" /root/.pkg/sources-all | cut -f1 -d'|' 2>/dev/null)"
else
PPA_NAME="$(grep "^${distro_ver}-${stream:-main}|" /root/.pkg/sources-all | grep -m1 "$repo_url" | cut -f1 -d'|' 2>/dev/null)"
if [ -z "$PPA_NAME" ]; then
PPA_NAME="$(grep "^${distro_ver}-${stream:-main}-" /root/.pkg/sources-all | grep -m1 "$repo_url" | cut -f1 -d'|' 2>/dev/null)"
fi
fi
# get repo name and filename
if [ "$PPA_NAME" = "" ];then
echo
read -e -p "Enter a repo name, such as '${distro_ver}-${stream:-main}': " -i "${distro_ver}-${stream:-main}" PPA_NAME
fi
# replace any spaces or underscores with dashes, all lower case
PPA_NAME="$( echo "${PPA_NAME// /-}" | tr '_' '-' | tr '[:upper:]' '[:lower:]' )"
repo_name="$PPA_NAME"
distro="$(get_distro $repo_url $distro_ver $repo_stream)"
distro=${distro:-$DISTRO_BINARY_COMPAT}
repo_filename="Packages-$distro-${PPA_NAME}"
fi
}
/s243a/.../usr/sbin/ppa2pup#L170
for stream in ${repo_streams[@]} #$repo_stream $repo_stream2 $repo_stream3 $repo_stream4
do
if [ repo_type=debian ]; then
distro="$(get_distro $repo_url $distro_ver $stream)"
distro="$(get_distro $repo_url $distro_ver $repo_stream)"
fi
set_names $1
Note that in the above function set_names(), I added a prompt for the name of the distro:
read -e -p "Enter a repo name, such as '${distro_ver}-${stream:-main}': " -i "${distro_ver}-${stream:-main}" PPA_NAME
read -e -p "Enter a distro name name, such as '$DISTRO_BINARY_COMPAT': " -i "$DISTRO_BINARY_COMPAT" distro
/s243a/.../usr/sbin/ppa2pup#L187
but I haven't pushed this change to github yet. Regarding this, what does the "-i" option do in a read statement. I can't find it documented anywhere so I'm not sure that it is valid.
Edited by sc0ttj