Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed correct handling of OBS repositories as debian source #550

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,30 @@ function apt-get.update(){

cat Packages.gz | gunzip -c | grep -E "^Package:|^Filename:|^Depends:|^Version:" >> cache.txt || true

echo APT_GET_UPDATE
while read line; do
local line=$(echo "${line}" | sed 's|[[:space:]]| |g')
local repo_info=($(echo ${line} | tr " " "\n"))
local base_url=${repo_info[1]}
local dist_name=${repo_info[2]}

for i in $(seq 3 $((${#repo_info[@]} - 1))); do
echo "Caching ${base_url} ${dist_name} ${repo_info[${i}]}..."
local repo_url="${base_url}/dists/${dist_name}/${repo_info[${i}]}/binary-amd64/Packages.gz"
echo line=${line}
echo repo_info=${repo_info}
echo base_url=${base_url}
echo dist_name=${dist_name}

# Detect openSUSE Build Service (OBS) repositories, which are listed using a single / at the end (according to pkg2appimage documentation)
if test "${dist_name}" = "/" ; then
echo "Caching ${base_url} ${dist_name}..."
local repo_url="${base_url}/Packages.gz"
wget -q "${repo_url}" -O - | gunzip -c | grep -E "^Package:|^Filename:|^Depends:|^Version:" | sed "s|^Filename: |Filename: ${base_url}/|g" >> cache.txt
done
else
for i in $(seq 3 $((${#repo_info[@]} - 1))); do
echo "Caching ${base_url} ${dist_name} ${repo_info[${i}]}..."
local repo_url="${base_url}/dists/${dist_name}/${repo_info[${i}]}/binary-amd64/Packages.gz"
wget -q "${repo_url}" -O - | gunzip -c | grep -E "^Package:|^Filename:|^Depends:|^Version:" | sed "s|^Filename: |Filename: ${base_url}/|g" >> cache.txt
done
fi
done <sources.list
}

Expand All @@ -397,21 +410,36 @@ function apt-get.do-download(){
grep -q ^"Package: ${1}"$ status && return
}

echo "${already_downloaded_package[@]}" | sed 's| |\n|g' | grep -q ^"${1}"$ && return
local package_name=$(echo ${1} | cut -d= -f1)
local package_version=`echo ${1} | cut -s -d= -f2-`

echo "${already_downloaded_package[@]}" | sed 's| |\n|g' | grep -q ^"${package_name}"$ && return

already_downloaded_package+=(${1})
if ! test -z "${package_version}" ; then
local package_url=`cat cache.txt | grep -v ^"Depends: " \
| grep -A 3 ^"Package: ${package_name}"$ \
| grep -A 2 ^"Version: ${package_version}" \
| grep ^"Filename: " \
| cut -c 11-`
else
local package_url=`cat cache.txt | grep -v ^"Depends: " \
| grep -A 3 -m 1 ^"Package: ${package_name}"$ \
| grep ^"Filename: " \
| cut -c 11-`
fi

already_downloaded_package+=(${package_name})

local dependencies=($(cat cache.txt | grep -A 2 -m 1 ^"Package: ${1}"$ \
local dependencies=($(cat cache.txt | grep -A 2 -m 1 ^"Package: ${package_name}"$ \
| grep ^"Depends: " \
| cut -c 9- \
| sed "s|([^)]*)||g;s|[[:space:]]||g" \
| sed "s|,|\n|g" \
| cut -d"|" -f1 ))

local package_url=$(cat cache.txt | grep -A 3 -m 1 ^"Package: ${1}"$ \
| grep ^"Filename: " \
| cut -c 11-)

echo PACKAGE NAME: ${package_name}
echo PACKAGE_VERSION: ${package_version}
echo PACKAGE_URL: ${package_url}

[ ! -f "${package_url}" ] && {
[ ! "${package_url}" = "" ] && {
Expand Down
Loading