Compare commits

...

3 Commits

Author SHA1 Message Date
Eisuke Kawashima
dcfc8add71
refactor: use mktemp for temporary directories 2025-03-22 12:18:04 +09:00
helixarch
0c4f92b12e
Merge pull request #93 from SnivySquid65/master
Added choice in updating when given the "run debtap -u" prompt.
2025-03-06 00:12:23 +02:00
SnivySquid65
795ad62414 patch for teh pull request 2025-03-05 22:04:21 +00:00

74
debtap
View File

@ -131,10 +131,20 @@ elif [[ $(file -S -b "${@: -1}" | grep -q "Debian binary package"; echo $?) != 0
fi
if [[ ! $(ls /var/cache/pkgfile/*.files 2> /dev/null) ]] || [[ ! $(ls /var/cache/debtap/*-packages-files 2> /dev/null) ]] || [[ ! -e /var/cache/debtap/base-packages ]] || [[ ! -e /var/cache/debtap/aur-packages ]] || [[ ! -e /var/cache/debtap/virtual-packages ]]; then
# This should fix it. Patch by SnivySquid65!
if [[ $pseudo != set ]]; then
echo -e "${red}Error: You must run at least once \"debtap -u\" with root privileges (preferably recently), before running this script${NC}"; exit 1
while true; do
read -p "Updates may be available that are not installed! Proceed anyway? (If you've already ran 'debtap -u' recently, you can ignore this and continue.) (y/n) " yn
case $yn in
[yY] ) echo "Then let's continue!";
break;;
[nN] ) echo "Aborted!!";
exit;;
* ) echo "Invalid input.";;
esac
done
else
echo -e "${red}Error: You must enable a multilib repository, synchronize pacman database and then run at least once \"debtap -u\" with root privileges (preferably recently), before running this script${NC}"; exit 1
echo "You made it past the update request bug! Yay!"
fi
fi
@ -163,9 +173,8 @@ tar_extract_cmd() {
# Defining package with full path & defining and creating working directory
package_with_full_path="`readlink -f "${@: -1}"`"
working_directory="`pwd`/`basename "${@: -1}" | tr '[:upper:]' '[:lower:]' | sed s'/\.deb$//'`-working-directory"
rm -rf "$working_directory" 2> /dev/null
mkdir "$working_directory" 2> /dev/null
working_directory=$(mktemp -d -p "`pwd`" "`basename "${@: -1}" | tr '[:upper:]' '[:lower:]' | sed s'/\.deb$//'`".XXXXXXXXXX)
trap 'rm -rf "$working_directory"' EXIT
if [[ $(echo $?) != 0 ]]; then
echo -e "${red}Error: Cannot create working directory, permission denied. Exiting...${NC}"
exit 1
@ -177,14 +186,12 @@ echo -e "${lightgreen}==>${NC} ${bold}Extracting package data...${normal}"
control_tar_check=$(ar t "$package_with_full_path" | grep -m 1 "control\.tar")
control_extract=$(tar_extract_cmd "$control_tar_check")
if [ $? != 0 ]; then
rm -rf "$working_directory"
exit 1
fi
ar p "$package_with_full_path" "$control_tar_check" | $control_extract
if [[ $pseudo == set ]] && [[ $(grep ^Architecture: control | grep -q i386; echo $?) != 0 ]]; then
echo -e "${red}Error: Invalid package architecture. Removing extracted package data and exiting...${NC}"
rm -rf "$working_directory"
exit 1
fi
@ -192,7 +199,6 @@ rm -rf $(ls * | grep -v 'control\|preinst\|postinst\|prerm\|postrm\|conffiles')
data_tar_check=$(ar t "$package_with_full_path" | grep -m 1 "data\.tar")
data_extract=$(tar_extract_cmd "$data_tar_check")
if [ $? != 0 ]; then
rm -rf "$working_directory"
exit 1
fi
ar p "$package_with_full_path" "$data_tar_check" | $data_extract
@ -2930,59 +2936,59 @@ if [[ $(grep -q '^Recommends:\|^Suggests:' control; echo $?) == 0 ]]; then
rm -rf *tempfile* optional-dependencies-initial-check-list final-check-list
fi
# Moving report files to /tmp/debtap (if any exist)
rm -rf /tmp/debtap 2> /dev/null
mkdir /tmp/debtap 2> /dev/null
# Moving report files to debtap temporary directory (if any exist)
debtap_tmp=$(mktemp -d -p /tmp debtap.XXXXXXXXXX)
if [[ $(echo $?) != 0 ]]; then
echo -e "${red}Error: Cannot create /tmp/debtap, permission denied${NC}"
echo -e "${red}Error: Cannot create a temporary directory, permission denied${NC}"
fi
mv *untranslated* /tmp/debtap 2> /dev/null
mv *missing-files /tmp/debtap 2> /dev/null
trap 'rm -rf "$working_directory" "$debtap_tmp"' EXIT
mv *untranslated* "$debtap_tmp" 2> /dev/null
mv *missing-files "$debtap_tmp" 2> /dev/null
# Report of (warning messages for) untranslated packages names and packages with missing files (if any exist)
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]]; then
echo -e "\n${lightred}Warning: These dependencies (depend = fields) could not be translated into Arch Linux packages names:${NC}"
echo `cat /tmp/debtap/dependencies-untranslated-names-only` | sed s'/ /, /g'
echo `cat "$debtap_tmp/dependencies-untranslated-names-only"` | sed s'/ /, /g'
fi
if [[ -e /tmp/debtap/dependencies-missing-files ]]; then
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]]; then
if [[ -e "$debtap_tmp/dependencies-missing-files" ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]]; then
echo -e "${lightred}Warning: These packages names could not be included as dependencies, because debtap has translated them into the same name with the package for conversion. This happens sometimes when you convert packages that already exist in your repositories (which is a bad idea in general). The following packages contain files that are already included in the package from your repositories (without these files your converted package may be dysfunctional):${NC}"
else
echo -e "\n${lightred}Warning: These packages names could not be included as dependencies, because debtap has translated them into the same name with the package for conversion. This happens sometimes when you convert packages that already exist in your repositories (which is a bad idea in general). The following packages contain files that are already included in the package from your repositories (without these files your converted package may be dysfunctional):${NC}"
fi
echo `cat /tmp/debtap/dependencies-missing-files` | sed s'/ /, /g'
echo `cat "$debtap_tmp/dependencies-missing-files"` | sed s'/ /, /g'
fi
if [[ -e /tmp/debtap/optional-dependencies-untranslated-names-only-1 ]]; then
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]] || [[ -e /tmp/debtap/dependencies-missing-files ]]; then
if [[ -e "$debtap_tmp/optional-dependencies-untranslated-names-only-1" ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]] || [[ -e "$debtap_tmp/dependencies-missing-files" ]]; then
echo -e "${lightred}Warning: These optional dependencies (optdepend = fields) could not be translated into Arch Linux packages names:${NC}"
else
echo -e "\n${lightred}Warning: These optional dependencies (optdepend = fields) could not be translated into Arch Linux packages names:${NC}"
fi
echo `cat /tmp/debtap/optional-dependencies-untranslated-names-only-1` | sed s'/ /, /g'
echo `cat "$debtap_tmp/optional-dependencies-untranslated-names-only-1"` | sed s'/ /, /g'
fi
if [[ -e /tmp/debtap/replacements-untranslated-names-only ]]; then
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]] || [[ -e /tmp/debtap/dependencies-missing-files ]] || [[ -e /tmp/debtap/optional-dependencies-untranslated-names-only-1 ]]; then
if [[ -e "$debtap_tmp/replacements-untranslated-names-only" ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]] || [[ -e "$debtap_tmp/dependencies-missing-files" ]] || [[ -e "$debtap_tmp/optional-dependencies-untranslated-names-only-1" ]]; then
echo -e "${lightred}Warning: These replacements (replaces = fields) could not be translated into Arch Linux packages names:${NC}"
else
echo -e "\n${lightred}Warning: These replacements (replaces = fields) could not be translated into Arch Linux packages names:${NC}"
fi
echo `cat /tmp/debtap/replacements-untranslated-names-only` | sed s'/ /, /g'
echo `cat "$debtap_tmp/replacements-untranslated-names-only"` | sed s'/ /, /g'
fi
if [[ -e /tmp/debtap/conflicts-untranslated-names-only ]]; then
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]] || [[ -e /tmp/debtap/dependencies-missing-files ]] || [[ -e /tmp/debtap/optional-dependencies-untranslated-names-only-1 ]] || [[ -e /tmp/debtap/replacements-untranslated-names-only ]]; then
if [[ -e "$debtap_tmp/conflicts-untranslated-names-only" ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]] || [[ -e "$debtap_tmp/dependencies-missing-files" ]] || [[ -e "$debtap_tmp/optional-dependencies-untranslated-names-only-1" ]] || [[ -e "$debtap_tmp/replacements-untranslated-names-only" ]]; then
echo -e "${lightred}Warning: These conflicts (conflict = fields) could not be translated into Arch Linux packages names:${NC}"
else
echo -e "\n${lightred}Warning: These conflicts (conflict = fields) could not be translated into Arch Linux packages names:${NC}"
fi
echo `cat /tmp/debtap/conflicts-untranslated-names-only` | sed s'/ /, /g'
echo `cat "$debtap_tmp/conflicts-untranslated-names-only"` | sed s'/ /, /g'
fi
if [[ -e /tmp/debtap/provisions-untranslated-names-only ]]; then
if [[ -e /tmp/debtap/dependencies-untranslated-names-only ]] || [[ -e /tmp/debtap/dependencies-missing-files ]] || [[ -e /tmp/debtap/optional-dependencies-untranslated-names-only-1 ]] || [[ -e /tmp/debtap/replacements-untranslated-names-only ]] || [[ -e /tmp/debtap/conflicts-untranslated-names-only ]]; then
if [[ -e "$debtap_tmp/provisions-untranslated-names-only" ]]; then
if [[ -e "$debtap_tmp/dependencies-untranslated-names-only" ]] || [[ -e "$debtap_tmp/dependencies-missing-files" ]] || [[ -e "$debtap_tmp/optional-dependencies-untranslated-names-only-1" ]] || [[ -e "$debtap_tmp/replacements-untranslated-names-only" ]] || [[ -e "$debtap_tmp/conflicts-untranslated-names-only" ]]; then
echo -e "${lightred}Warning: These provisions (provides = fields) could not be translated into Arch Linux packages names:${NC}"
else
echo -e "\n${lightred}Warning: These provisions (provides = fields) could not be translated into Arch Linux packages names:${NC}"
fi
echo `cat /tmp/debtap/provisions-untranslated-names-only` | sed s'/ /, /g'
echo `cat "$debtap_tmp/provisions-untranslated-names-only"` | sed s'/ /, /g'
fi
# Generating .INSTALL file (if necessary)
@ -3195,8 +3201,6 @@ fi
if [[ $pkgbuild != set ]] && [[ $Pkgbuild != set ]]; then
# Removing leftover files
echo -e "${lightgreen}==>${NC} ${bold}Removing leftover files...${normal}"
rm -rf "$working_directory"
rm -rf /tmp/debtap
exit 0
fi
@ -3383,8 +3387,6 @@ rm -rf "../$pkgname" 2> /dev/null
mkdir "../$pkgname" 2> /dev/null
if [[ $(echo $?) != 0 ]]; then
echo -e "${red}Error: Cannot create PKGBUILD directory, permission denied. Removing leftover files and exiting...${NC}"
rm -rf "$working_directory"
rm -rf /tmp/debtap
exit 1
fi
mv PKGBUILD "../$pkgname"
@ -3399,6 +3401,4 @@ fi
# Removing leftover files
echo -e "${lightgreen}==>${NC} ${bold}Removing leftover files...${normal}"
rm -rf "$working_directory"
rm -rf /tmp/debtap
exit 0