-
Notifications
You must be signed in to change notification settings - Fork 25
/
gen_replace_deps.sh
executable file
·83 lines (73 loc) · 4.6 KB
/
gen_replace_deps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# This script generates a dependencies map of debian packages to arch linux packages dict for using in gen-PKGBUILD.py
cat Packages-extracted | egrep "Depends|Suggests|Recommends" | sed 's/Depends: //' | sed 's/Suggests: //' | sed 's/Recommends: //' | sed 's/, /\n/g' | sort -u | grep -v "amdgpu" | sed "s/ | /\n/g" >tmp_extra_deps_in_debian.txt
cat tmp_extra_deps_in_debian.txt | cut -f1 -d" " | sort -u >tmp_extra_deps_in_debian_removed_versions.txt # removed versions
# Detecting dependencies, named with amdgpu (and their alternatives), that are not provided in bundled amd archive
cat Packages-extracted | egrep "Depends|Suggests|Recommends" | sed 's/Pre-Depends: //' | sed 's/Depends: //' | sed 's/Suggests: //' | sed 's/Recommends: //' | sed 's/, /\n/g' | sort -u | grep "amdgpu" | sed "s/ | /\n/g" >tmp_deps_in_debian_amdgpu.txt
cat tmp_deps_in_debian_amdgpu.txt | cut -f1 -d" " | sort -u >tmp_removed_versions_amdgpu.txt # removed versions
cat tmp_removed_versions_amdgpu.txt | sed "s/:i386$//g" | sort -u >tmp_amdgpu_deps_in_debian.txt
>tmp_extra_deps_in_debian_amdgpu.txt # clear file
for line in $(cat tmp_amdgpu_deps_in_debian.txt); do
if grep -q "Package: $line" Packages-extracted; then continue; fi
echo $line >>tmp_extra_deps_in_debian_amdgpu.txt
done
sed -i 's/-hwe//g' tmp_extra_deps_in_debian_amdgpu.txt
echo >tmp_translated_deps.txt # clear file
function dep_convert {
line=$1
case $line in
libc6) arch_str="None, #manually_mapped" ;; # It maps to 'glibc', which is required by base, so no need to explicitly depend on it
libvulkan1) arch_str="'vulkan-icd-loader', #manually_mapped" ;; # It maps to 'vulkan-icd-loader', because the automatic sets to use dicord for this lib
libgcc-s1) arch_str="None, #manually_mapped" ;; # It maps to 'gcc', but I doubt it depends on gcc, the compiler
libgl1) arch_str="'libglvnd', #manually_mapped" ;;
libjs-jquery) arch_str="'jquery', #manually_mapped" ;;
libjs-underscore) arch_str="'underscorejs', #manually_mapped" ;;
libstdc++6) arch_str="None, #manually_mapped" ;; # It maps to 'gcc-libs', which is required by base, so no need to explicitly depend on it
libtxc-dxtn-s2tc0) arch_str="'libtxc_dxtn', #manually_mapped" ;;
libtxc-dxtn0) arch_str="None, #manually_mapped" ;; # have alternative libtxc-dxtn-s2tc0
libtinfo5) arch_str="'ncurses5-compat-libs', #manually_mapped" ;;
libwayland-amdgpu-client0) arch_str="'wayland', #manually_mapped" ;;
libtinfo-dev) arch_str="'ncurses', #manually_mapped" ;;
libudev0) arch_str="None, #manually_mapped" ;; # have alternative libudev1
linux-firmware) arch_str="'linux-firmware', #manually_mapped" ;; # debtap takes very long time and finally faulty auto translates to None.
libgbm1-amdgpu) arch_str="None, #manually_Do_not_know_what_it_is" ;;
libssl1.1) arch_str="'openssl-1.1', #manually_mapped" ;; #for libssl1.1 to have correct dependency
mesa-vulkan-drivers) arch_str="'vulkan-radeon', #manually_mapped" ;; #for now it works with mesa
rocm-opencl-runtime) arch_str="'rocm-opencl-runtime', #manually_mapped" ;; # we anyway do not use it, but let's keep the dependency
libwayland-client0) arch_str="'wayland', #manually_mapped" ;; # we anyway do not use it, but let's keep the dependency
zlib1g) arch_str="'zlib', #manually_mapped" ;; # it seems to need the zlib, so we put it
#---) arch_str="'---', #manually_mapped" ;; # templpate
*)
arch_dep=$(bash ./translate_deb_to_arch_dependency.sh $line) # https://github.com/helixarch/debtap/issues/41#issuecomment-489166020
if [[ $arch_dep == "could_not_translate" ]]; then
arch_str="'$line', #could_not_auto_translate"
elif [[ $arch_dep == "" ]]; then
arch_str="None, #auto_translated"
else
arch_str="'$arch_dep', #auto_translated"
fi
;;
esac
str="'$line': "
str="$str $arch_str"
echo $str >>tmp_translated_deps.txt
}
for line in $(cat tmp_extra_deps_in_debian_removed_versions.txt tmp_extra_deps_in_debian_amdgpu.txt | sort); do
echo now processing $line >&2
dep_convert $line &
done
wait
cat tmp_translated_deps.txt | sort -k2,2 -t "'" | column -t | sed 's/^'\''/ '\''/' >tmp_prepared_columns.txt
echo -e "# Generated with ./gen_replace_deps.sh > replace_deps.py\n\
# for driver version $(sed -n 2p Packages-extracted | cut -f 2 -d " ")\n"
echo "replace_deps = {"
cat tmp_prepared_columns.txt
echo "}"
rm tmp_amdgpu_deps_in_debian.txt
rm tmp_deps_in_debian_amdgpu.txt
rm tmp_extra_deps_in_debian_amdgpu.txt
rm tmp_extra_deps_in_debian_removed_versions.txt
rm tmp_extra_deps_in_debian.txt
rm tmp_prepared_columns.txt
rm tmp_removed_versions_amdgpu.txt
rm tmp_translated_deps.txt