Code Block | ||
---|---|---|
| ||
#!/bin/bash # File create for save temporary values >list_one >list_two >pkg_dep >tmp0 >tmp1 >tmp function get_depends() { ## This function get depends for build component [ -z "$(grep -f pkg_dep <<< $1)" ] && apt-get install -s $1 2>/dev/null | grep Inst | awk '{print $2}'| sort -u && echo $pkg >> pkg_dep } function all_dep() { ## This recursion function for get recursion depends for build conmponents for pkg in $@; do all_dep $(get_depends $pkg) done }DEP_FILE="" #DEP_FILE="req.txt" LOG_FILE="" #LOG_FILE="/export/admin/repo.log" function print_log { if [[ "$LOG_FILE" != "" ]]; then echo "$1" >> $LOG_FILE fi } ## Loop for get build components dependencies echo "" > list_to_check echo "publicsuffix" > final_list sed -i '/^[ \t]*$/d' list_component echo "" >> list_component echo "" > temp if [[ "$DEP_FILE" != "" ]]; then echo "" > $DEP_FILE fi while read comp; do ## Skip empty line if [[ "" == "\$comp" ]]; then continue fi echo -e "\033[33m =====> Getting depends for $comp... \033[0m" res=$(apt-rdepends --build-depends --follow=DEPENDS $comp) echo "$res" | grep 'Build-Depends:' > tmp echo "$res" | grep 'Build-Depends-Indep:' >> tmp sed 's/^[ \t]*Build-Depends:[ \t]*//; s/^[ \t]*Build-Depends-Indep:[ \t]*//' tmp | sed 's/[ \t]*(.*)[ \t]*$//' >> temp rm -f tmp if [[ "$DEP_FILE" != "" ]]; then sed "s/^/$comp:/g" temp >> $DEP_FILE fi done < list_component ## Preparation of initial list of dependencies sort -u temp > list_to_check sed -i '/^[ \t]*$/d' list_to_check end=$(cat list_to_check) echo "" >> list_to_check mkdir /data/repo/pkg/_tdir apt-get -R /data/repo/pkg/_tdir update ## Loop for get depends for build components packages dependencies while [[ "$end" != "" ]]; do echo "" > temp while read componentcomp; do ## Skip empty line if [[ "" == "$component$comp" ]]; then continue fi echo -e "\033[33;1;4m ## Skip packages that are already checked for dependencies res=$(grep "^[ \t]*$comp[ \t]*\$" final_list) if [[ "" != "$res" ]]; then continue fi echo "=====> Getting depends for $component$comp..." \033[0m" apt-get -R /data/repo/pkg/_tdir install --dry-run build-dep $component 2>/dev/null | grep Inst | awk '{print $2}' >> list_one done < list_component $comp | grep "^Inst " | sed 's/^Inst //; s/ .*$//' >> temp ##apt-cache depends --no-pre-depends --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances apt-cache depends --no-pre-depends --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances $comp | sed 's/^[ \t|]*Depends: //; /</d; s/^[ \t]*//' | sed 's/^[ \t|]*Depends: //; /</d; s/^[ \t]*//' >> temp ## Add checked package to the list of already checked packages echo "$comp" >> final_list if [[ "$DEP_FILE" != "" ]]; then sed "s/^/$comp:/g" temp >> $DEP_FILE fi done < list_to_check ## Remove repeated records from the list sort -u temp > list_to_check ## Remove empty lines if any sed -i '/^[ \t]*$/d' list_to_check sed -i '/^[ \t]*$/d' final_list end=$(cat list_to_check) echo "" >> list_to_check done ## Loop for check and download dependencies rmdir --ignore-fail-on-non-empty /data/repo/pkg/_tdir sed -i '/^[ \t]*$/d' final_list sort -u final_list > temp mv -f temp final_list echo "" >> final_list rm -f list_to_check while read pkg; do if [[ "" == "$pkg" ]]; then continue fi echo -e "\033[32;1;4m36m =====> InstallingCheck $pkg... \033[0m" apt-get install -s $pkg 2>/dev/null## Check if a package exists res=$(apt-cache show $pkg | grep "Package: $pkg") if [[ "$res" != "" ]]; then ## Download existed package echo -e "\033[35m =====> Downloading package $pkg... \033[0m" res=$(apt-get -R /data/repo/pkg/_tdir download $pkg | grep Inst"E:" | sed awk '{print $2}' >> list_two done < list_pkg_sec cat list_one-n 's/E://') if [[ "$res" == "" ]]; then print_log "$pkg : OK" else echo -e "\033[31;1;4m $res \033[0m" print_log "$pkg: $res" if [[ "$DEP_FILE" != "" ]]; then echo "=======================================" >> tmp0 cat list_twoerrors.log echo "$pkg: $res" >> tmp0 cat list_component >> tmp0 cat list_pkg_sec >> tmp0 cat tmp0 | sort -u >> tmp1 ## Loop for get depends, use function 'all_dep' while read pkg; do errors.log grep ":$pkg" $DEP_FILE >> errors.log fi fi else ## Put error message if package doesn't exist echo -e "\033[31;1;4m$pkg: No package found \033[0m" print_log "$pkg: No package found" if [[ "$DEP_FILE" =!= "$pkg" ]]; then echo "=======================================" >> errors.log echo "$pkg: No package found" >> errors.log grep ":$pkg" $DEP_FILE >> errors.log continuefi fi done < final_list ## Downloading *.deb packages echo -e "\033[3632;1;4m1m =====> GettingUploading depends for $pkg*.deb packages... \033[0m" all_dep $pkg >/dev/null done < tmp1 cat pkg_dep >> tmp1 cat tmp1 | sort -u >> tmp while read pkgreprepro -b /data/repo --export=never -C main includedeb du2-prebuild /data/repo/pkg/*.deb ## Loop for download sources while read component; do if [[ "" == "$pkg$component" ]]; then continue fi echo -e "\033[3533;1;4m1m =====> Downloading sources for $pkg$component... \033[0m" sudo apt-get source --download $pkg done < tmp EOT-only $component echo -e "\033[32;1m =====> Uploading sources for $component... \033[0m" reprepro -b /data/repo --export=never -C main includedsc du2-prebuild $component*.dsc rm -rf $component* done < list_component ## Creating index for local repo echo -e "\033[32;1m =====> Creating indices for local repo... \033[0m" reprepro -Vb /data/repo export du2-prebuild echo -e "\033[32;1m =====> DONE \033[0m" if [[ "$LOG_FILE" != "" ]]; then echo "Downloaded package list is put to $LOG_FILE" fi |
Page Comparison
General
Content
Integrations