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!
|
||||||
|
|
56
debtap
56
debtap
|
@ -10,29 +10,64 @@ bold=`tput bold`
|
||||||
normal=`tput sgr0`
|
normal=`tput sgr0`
|
||||||
|
|
||||||
# Help and error messages
|
# Help and error messages
|
||||||
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
|
if [[ "$2" == "-h" ]] || [[ "$2" == "--h" ]] || [[ "$2" == "-help" ]] || [[ "$2" == "--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 [[ "$2" == "" ]]; 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 "$2" &> /dev/null; 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
|
||||||
|
fi
|
||||||
|
else
|
||||||
if [[ "$1" == "-h" ]] || [[ "$1" == "--h" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "--help" ]]; then
|
if [[ "$1" == "-h" ]] || [[ "$1" == "--h" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "--help" ]]; then
|
||||||
echo "Syntax: debtap package_filename"; exit 0
|
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
|
elif [[ "$1" == "" ]]; then
|
||||||
echo -e "${red}Error: You haven't specified a deb package${NC}\nSyntax: debtap package_filename"; exit 1
|
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
|
elif [[ $(ls "$1" &> /dev/null; echo $?) != 0 ]]; then
|
||||||
echo -e "${red}Error: No such file or directory${NC}"; exit 1
|
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
|
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
|
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
|
||||||
|
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
|
||||||
|
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"
|
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}"
|
||||||
|
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
|
ar p ../"$1" control.tar.gz | tar xz
|
||||||
|
fi
|
||||||
rm -rf $(ls * | grep -v 'control\|conffiles')
|
rm -rf $(ls * | grep -v 'control\|conffiles')
|
||||||
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; 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`
|
data_tar_check=`ar t ../"$1" | grep data`
|
||||||
if [ $data_tar_check == data.tar.gz ]; then
|
if [ $data_tar_check == data.tar.gz ]; then
|
||||||
ar p ../"$1" data.tar.gz | tar xz
|
ar p ../"$1" data.tar.gz | tar xz
|
||||||
|
@ -45,6 +80,7 @@ elif [ $data_tar_check == data.tar.lzma ]; then
|
||||||
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
|
||||||
echo -e "${lightgreen}==>${NC} ${bold}Fixing possible directories structure differencies...${normal}"
|
echo -e "${lightgreen}==>${NC} ${bold}Fixing possible directories structure differencies...${normal}"
|
||||||
|
@ -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
|
||||||
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
|
echo "packager = Unknown Packager" >> .PKGINFO
|
||||||
|
else
|
||||||
echo -e "\n${lightblue}::${NC} Enter Packager name:"
|
echo -e "\n${lightblue}::${NC} Enter Packager name:"
|
||||||
read packager_name
|
read packager_name
|
||||||
echo "packager = $packager_name" >> .PKGINFO
|
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,6 +216,9 @@ 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
|
||||||
|
if [[ "$1" == "-q" ]] || [[ "$1" == "--q" ]] || [[ "$1" == "-quiet" ]] || [[ "$1" == "--quiet" ]] || [[ "$1" == "-Q" ]] || [[ "$1" == "--Q" ]] || [[ "$1" == "-Quiet" ]] || [[ "$1" == "--Quiet" ]]; then
|
||||||
|
echo "license = custom" >> .PKGINFO
|
||||||
|
else
|
||||||
echo -e "\n${lightblue}::${NC} Enter package license (you can enter multiple licenses comma seperated):"
|
echo -e "\n${lightblue}::${NC} Enter package license (you can enter multiple licenses comma seperated):"
|
||||||
read package_license
|
read package_license
|
||||||
for i in `echo "$package_license" | sed -e s'/ /__/g' -e s'/,/ /g'`; do
|
for i in `echo "$package_license" | sed -e s'/ /__/g' -e s'/,/ /g'`; do
|
||||||
|
@ -183,6 +226,7 @@ for i in `echo "$package_license" | sed -e s'/ /__/g' -e s'/,/ /g'`; do
|
||||||
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,6 +3323,7 @@ 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 [[ "$1" != "-Q" ]] && [[ "$1" != "--Q" ]] && [[ "$1" != "-Quiet" ]] && [[ "$1" != "--Quiet" ]]; then
|
||||||
if [ -e .INSTALL ]; 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
|
||||||
|
@ -3308,6 +3353,7 @@ else
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Generating .MTREE file
|
# Generating .MTREE file
|
||||||
echo -e "\n${lightgreen}==>${NC} ${bold}Generating .MTREE file...${normal}"
|
echo -e "\n${lightgreen}==>${NC} ${bold}Generating .MTREE file...${normal}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user