mirror of
https://github.com/helixarch/debtap
synced 2024-11-25 03:20:27 +01:00
update
This commit is contained in:
parent
ddb3b6bff2
commit
7fcff6b01f
|
@ -27,7 +27,7 @@ A script for converting .deb packages into Arch Linux packages, focused on accur
|
||||||
|
|
||||||
**Q: How do I use debtap?**
|
**Q: How do I use debtap?**
|
||||||
|
|
||||||
**A:** The syntax is quite simple actually: `debtap package_filename`
|
**A:** The syntax is quite simple actually: `debtap [option] package_filename`
|
||||||
For example: `debtap world-of-goo-demo_1.0_i386.deb`
|
For example: `debtap world-of-goo-demo_1.0_i386.deb`
|
||||||
|
|
||||||
Any recommendations or questions for debtap are welcomed!
|
Any recommendations or questions for debtap are welcomed!
|
||||||
|
|
102
debtap
102
debtap
|
@ -10,40 +10,76 @@ bold=`tput bold`
|
||||||
normal=`tput sgr0`
|
normal=`tput sgr0`
|
||||||
|
|
||||||
# Help and error messages
|
# Help and error messages
|
||||||
if [[ "$1" == "-h" ]] || [[ "$1" == "--h" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "--help" ]]; then
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
echo "Syntax: debtap package_filename"; exit 0
|
if [[ "$2" == "-h" ]] || [[ "$2" == "--h" ]] || [[ "$2" == "-help" ]] || [[ "$2" == "--help" ]]; then
|
||||||
elif [[ "$1" == "" ]]; then
|
echo -e "Syntax: debtap [option] package_filename\n\nOptions:\n\n -h --h -help --help Prints this help message\n -q --q -quiet --quiet Bypass all questions, except for editing metadata file(s)\n -Q --Q -Quiet --Quiet Bypass all questions (not recommended)"; exit 0
|
||||||
echo -e "${red}Error: You haven't specified a deb package${NC}\nSyntax: debtap package_filename"; exit 1
|
elif [[ "$2" == "" ]]; then
|
||||||
elif [[ $(ls "$1" &> /dev/null; echo $?) != 0 ]]; then
|
echo -e "${red}Error: You haven't specified a deb package${NC}\nSyntax: debtap [option] package_filename\n\nOptions:\n\n -h --h -help --help Prints this help message\n -q --q -quiet --quiet Bypass all questions, except for editing metadata file(s)\n -Q --Q -Quiet --Quiet Bypass all questions (not recommended)"; exit 1
|
||||||
echo -e "${red}Error: No such file or directory${NC}"; exit 1
|
elif [[ $(ls "$2" &> /dev/null; echo $?) != 0 ]]; then
|
||||||
elif [[ $(file -b "$1" | grep -q "Debian binary package"; echo $?) != 0 ]]; then
|
echo -e "${red}Error: No such file or directory or invalid option${NC}"; exit 1
|
||||||
|
elif [[ $(file -b "$2" | grep -q "Debian binary package"; echo $?) != 0 ]]; then
|
||||||
echo -e "${red}Error: You haven't specified a valid deb package${NC}"; exit 1
|
echo -e "${red}Error: You haven't specified a valid deb package${NC}"; exit 1
|
||||||
elif [[ $(ping -c 1 www.google.com &> /dev/null; echo $?) != 0 ]]; then
|
fi
|
||||||
|
else
|
||||||
|
if [[ "$1" == "-h" ]] || [[ "$1" == "--h" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "--help" ]]; then
|
||||||
|
echo -e "Syntax: debtap [option] package_filename\n\nOptions:\n\n -h --h -help --help Prints this help message\n -q --q -quiet --quiet Bypass all questions, except for editing metadata file(s)\n -Q --Q -Quiet --Quiet Bypass all questions (not recommended)"; exit 0
|
||||||
|
elif [[ "$1" == "" ]]; then
|
||||||
|
echo -e "${red}Error: You haven't specified a deb package${NC}\nSyntax: debtap [option] package_filename\n\nOptions:\n\n -h --h -help --help Prints this help message\n -q --q -quiet --quiet Bypass all questions, except for editing metadata file(s)\n -Q --Q -Quiet --Quiet Bypass all questions (not recommended)"; exit 1
|
||||||
|
elif [[ $(ls "$1" &> /dev/null; echo $?) != 0 ]]; then
|
||||||
|
echo -e "${red}Error: No such file or directory or invalid option${NC}"; exit 1
|
||||||
|
elif [[ $(file -b "$1" | grep -q "Debian binary package"; echo $?) != 0 ]]; then
|
||||||
|
echo -e "${red}Error: You haven't specified a valid deb package${NC}"; exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ $(ping -c 1 www.google.com &> /dev/null; echo $?) != 0 ]]; then
|
||||||
echo -e "${red}Error: You have no internet access, which is necessary for this script to work${NC}"; exit 1
|
echo -e "${red}Error: You have no internet access, which is necessary for this script to work${NC}"; exit 1
|
||||||
elif [[ $(ls /var/cache/pkgfile/*.files | wc -l) == 0 ]]; then
|
elif [[ $(ls /var/cache/pkgfile/*.files 2> /dev/null | wc -l) == 0 ]]; then
|
||||||
echo -e "${red}Error: You must run at least once \"pkgfile -u\" with root privileges (preferably recently), before running this script${NC}"; exit 1
|
echo -e "${red}Error: You must run at least once \"pkgfile -u\" with root privileges (preferably recently), before running this script${NC}"; exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining and creating working directory
|
# Defining and creating working directory
|
||||||
working_directory="`ls "$1" | tr '[:upper:]' '[:lower:]' | sed s'/\.deb//'`-working-directory"
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
|
working_directory="`ls "$2" | tr '[:upper:]' '[:lower:]' | sed s'/\.deb//'`-working-directory"
|
||||||
|
else
|
||||||
|
working_directory="`ls "$1" | tr '[:upper:]' '[:lower:]' | sed s'/\.deb//'`-working-directory"
|
||||||
|
fi
|
||||||
mkdir "$working_directory"
|
mkdir "$working_directory"
|
||||||
cd "$working_directory"
|
cd "$working_directory"
|
||||||
|
|
||||||
# Extracting package data and metadata in working directory
|
# Extracting package data and metadata in working directory
|
||||||
echo -e "${lightgreen}==>${NC} ${bold}Extracting package data...${normal}"
|
echo -e "${lightgreen}==>${NC} ${bold}Extracting package data...${normal}"
|
||||||
ar p ../"$1" control.tar.gz | tar xz
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
|
ar p ../"$2" control.tar.gz | tar xz
|
||||||
|
else
|
||||||
|
ar p ../"$1" control.tar.gz | tar xz
|
||||||
|
fi
|
||||||
rm -rf $(ls * | grep -v 'control\|conffiles')
|
rm -rf $(ls * | grep -v 'control\|conffiles')
|
||||||
data_tar_check=`ar t ../"$1" | grep data`
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
if [ $data_tar_check == data.tar.gz ]; then
|
data_tar_check=`ar t ../"$2" | grep data`
|
||||||
|
if [ $data_tar_check == data.tar.gz ]; then
|
||||||
|
ar p ../"$2" data.tar.gz | tar xz
|
||||||
|
elif [ $data_tar_check == data.tar.xz ]; then
|
||||||
|
ar p ../"$2" data.tar.xz | tar xJ
|
||||||
|
elif [ $data_tar_check == data.tar.bz2 ]; then
|
||||||
|
ar p ../"$2" data.tar.bz2 | tar xj
|
||||||
|
elif [ $data_tar_check == data.tar.lzma ]; then
|
||||||
|
ar p ../"$2" data.tar.lzma | tar xJ
|
||||||
|
elif [ $data_tar_check == data.tar ]; then
|
||||||
|
ar p ../"$2" data.tar | tar x
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
data_tar_check=`ar t ../"$1" | grep data`
|
||||||
|
if [ $data_tar_check == data.tar.gz ]; then
|
||||||
ar p ../"$1" data.tar.gz | tar xz
|
ar p ../"$1" data.tar.gz | tar xz
|
||||||
elif [ $data_tar_check == data.tar.xz ]; then
|
elif [ $data_tar_check == data.tar.xz ]; then
|
||||||
ar p ../"$1" data.tar.xz | tar xJ
|
ar p ../"$1" data.tar.xz | tar xJ
|
||||||
elif [ $data_tar_check == data.tar.bz2 ]; then
|
elif [ $data_tar_check == data.tar.bz2 ]; then
|
||||||
ar p ../"$1" data.tar.bz2 | tar xj
|
ar p ../"$1" data.tar.bz2 | tar xj
|
||||||
elif [ $data_tar_check == data.tar.lzma ]; then
|
elif [ $data_tar_check == data.tar.lzma ]; then
|
||||||
ar p ../"$1" data.tar.lzma | tar xJ
|
ar p ../"$1" data.tar.lzma | tar xJ
|
||||||
elif [ $data_tar_check == data.tar ]; then
|
elif [ $data_tar_check == data.tar ]; then
|
||||||
ar p ../"$1" data.tar | tar x
|
ar p ../"$1" data.tar | tar x
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fixing possible differences in filesystem hierarchy of the extracted package data, so that it matches Arch Linux filesystem hierarchy
|
# Fixing possible differences in filesystem hierarchy of the extracted package data, so that it matches Arch Linux filesystem hierarchy
|
||||||
|
@ -160,9 +196,13 @@ echo "url = `grep Homepage: control | gawk '{print $2}'`" | sed s'/\/$//' >> .PK
|
||||||
echo "builddate = `date -u "+%s"`" >> .PKGINFO
|
echo "builddate = `date -u "+%s"`" >> .PKGINFO
|
||||||
|
|
||||||
# Generating packager field
|
# Generating packager field
|
||||||
echo -e "\n${lightblue}::${NC} Enter Packager name:"
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
read packager_name
|
echo "packager = Unknown Packager" >> .PKGINFO
|
||||||
echo "packager = $packager_name" >> .PKGINFO
|
else
|
||||||
|
echo -e "\n${lightblue}::${NC} Enter Packager name:"
|
||||||
|
read packager_name
|
||||||
|
echo "packager = $packager_name" >> .PKGINFO
|
||||||
|
fi
|
||||||
|
|
||||||
# Generating arch field
|
# Generating arch field
|
||||||
echo "arch = `grep Architecture: control | gawk '{print $2}' | sed -e s'/i386/i686/' -e s'/amd64/x86_64/' -e s'/all/any/'`" >> .PKGINFO
|
echo "arch = `grep Architecture: control | gawk '{print $2}' | sed -e s'/i386/i686/' -e s'/amd64/x86_64/' -e s'/all/any/'`" >> .PKGINFO
|
||||||
|
@ -176,13 +216,17 @@ fi
|
||||||
echo "size =" $(expr `du -sb | tr -d " ."` - `ls -l | grep control | gawk '{print $5}'` - $conffiles_size - `ls -la | grep .PKGINFO | gawk '{print $5}'` - 4096) >> .PKGINFO
|
echo "size =" $(expr `du -sb | tr -d " ."` - `ls -l | grep control | gawk '{print $5}'` - $conffiles_size - `ls -la | grep .PKGINFO | gawk '{print $5}'` - 4096) >> .PKGINFO
|
||||||
|
|
||||||
# Generating license field
|
# Generating license field
|
||||||
echo -e "\n${lightblue}::${NC} Enter package license (you can enter multiple licenses comma seperated):"
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
read package_license
|
echo "license = custom" >> .PKGINFO
|
||||||
for i in `echo "$package_license" | sed -e s'/ /__/g' -e s'/,/ /g'`; do
|
else
|
||||||
|
echo -e "\n${lightblue}::${NC} Enter package license (you can enter multiple licenses comma seperated):"
|
||||||
|
read package_license
|
||||||
|
for i in `echo "$package_license" | sed -e s'/ /__/g' -e s'/,/ /g'`; do
|
||||||
license+=($i)
|
license+=($i)
|
||||||
done
|
done
|
||||||
for (( i=0; i<$(echo ${#license[@]}); i=i+1 )); do license[$i]=$(echo ${license[$i]} | sed s'/__/ /g'); done
|
for (( i=0; i<$(echo ${#license[@]}); i=i+1 )); do license[$i]=$(echo ${license[$i]} | sed s'/__/ /g'); done
|
||||||
printf '%s\n' "${license[@]}" | while read line; do echo "license = $line" >> .PKGINFO ; done
|
printf '%s\n' "${license[@]}" | while read line; do echo "license = $line" >> .PKGINFO ; done
|
||||||
|
fi
|
||||||
|
|
||||||
# The packages names translator function
|
# The packages names translator function
|
||||||
packages-names-translator() {
|
packages-names-translator() {
|
||||||
|
@ -3279,7 +3323,8 @@ fi
|
||||||
rm -rf control conffiles virtual-packages
|
rm -rf control conffiles virtual-packages
|
||||||
|
|
||||||
# Prompting user for editing .PKGINFO and .INSTALL files
|
# Prompting user for editing .PKGINFO and .INSTALL files
|
||||||
if [ -e .INSTALL ]; then
|
if [[ "$1" != "-Q" ]] && [[ "$1" != "--Q" ]] && [[ "$1" != "-Quiet" ]] && [[ "$1" != "--Quiet" ]]; then
|
||||||
|
if [ -e .INSTALL ]; then
|
||||||
echo -en "\n${lightblue}::${NC} ${bold}If you want to edit .PKGINFO and .INSTALL files (in this order), press (1) For${normal} ${lightred}vi${NC} ${bold}(2) For${normal} ${lightred}nano${NC} ${bold}(3) For${normal} ${lightred}a custom editor${NC} ${bold}or any other key to continue: ${normal}"
|
echo -en "\n${lightblue}::${NC} ${bold}If you want to edit .PKGINFO and .INSTALL files (in this order), press (1) For${normal} ${lightred}vi${NC} ${bold}(2) For${normal} ${lightred}nano${NC} ${bold}(3) For${normal} ${lightred}a custom editor${NC} ${bold}or any other key to continue: ${normal}"
|
||||||
read -n 1 number
|
read -n 1 number
|
||||||
if [[ $number == 1 ]]; then
|
if [[ $number == 1 ]]; then
|
||||||
|
@ -3293,7 +3338,7 @@ if [ -e .INSTALL ]; then
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -en "\n${lightblue}::${NC} ${bold}If you want to edit .PKGINFO file, press (1) For${normal} ${lightred}vi${NC} ${bold}(2) For${normal} ${lightred}nano${NC} ${bold}(3) For${normal} ${lightred}a custom editor${NC} ${bold}or any other key to continue: ${normal}"
|
echo -en "\n${lightblue}::${NC} ${bold}If you want to edit .PKGINFO file, press (1) For${normal} ${lightred}vi${NC} ${bold}(2) For${normal} ${lightred}nano${NC} ${bold}(3) For${normal} ${lightred}a custom editor${NC} ${bold}or any other key to continue: ${normal}"
|
||||||
read -n 1 number
|
read -n 1 number
|
||||||
if [[ $number == 1 ]]; then
|
if [[ $number == 1 ]]; then
|
||||||
|
@ -3307,6 +3352,7 @@ else
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generating .MTREE file
|
# Generating .MTREE file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user