Code Block | ||
---|---|---|
| ||
#!/bin/bash ## If you need log then put here the name of the log file #LOGDEP_FILE="" #DEP_FILE="req.txt" LOG_FILE="list_deps" LOG#LOG_FILE="/export/admin/repo.log" function print_log { if [[ "$LOG_FILE" != "" ]]; then echo "$1" >> $LOG_FILE fi } ## Loop for get dependsbuild forcomponents builddependencies componentsecho ##"" The> list_to_componentcheck isecho a"publicsuffix" subject to check dependencies> final_list sed -i '/^[ \t]*$/d' list_component echo "" cp>> list_component list_to_check ## Prepare the final list of packages. Initially it is empty echo "" > final_list end=$(cat list_to_check) ## Working while there is a subject to check while [[ "$endecho "" > 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" != "" ]]; do ## Create an temporary file to collect dependencies 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 "" > temp>> list_to_check ## Check components one-by-one while read comp; do ifmkdir /data/repo/pkg/_tdir apt-get -R /data/repo/pkg/_tdir update ## Loop for get packages dependencies while [[ "$end" !== "$comp" ]]; then do echo "" > temp while read comp; do ## Skip empty line if [[ "" == "$comp" ]]; then continue fi ## CheckSkip ifpackages thisthat component isare already checked for dependencies res=$(grep "^[ \t]*$comp[ \t]*\$" final_list) if [[ "" != "$res" ]]; then continue fi ## Skip already checked component echo "=====> Getting depends for $comp..." continueapt-get -R /data/repo/pkg/_tdir install --dry-run fi$comp | grep "^Inst " ##| Check component dependencies echo -e "\033[33m =====> Getting depends for $comp... \033[0m" res=$(apt-rdepends --build-depends --follow=DEPENDSsed '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|]*Build-Depends:[ \t]*// //; /</d; s/^[ \t]*Build-Depends-Indep:[ \t]*//' | sed "'s/^[ \\t|]*${component}[ \\t]*\$Depends: //; /^[ \\t]*\$</d; s/^[ \\t]*(.*)\$//")' >> temp ## Add Putchecked dependenciespackage to the temporary file list of already checked packages echo "$res$comp" >> tempfinal_list ##if Put the component name to the list of already checked components echo "$comp" >> final_list[[ "$DEP_FILE" != "" ]]; then sed "s/^/$comp:/g" temp >> $DEP_FILE fi done < list_to_check ## Remove duplucatedrepeated dependenciers and put them torecords from the list of subjects to check 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 ## Clear the final list from empty stringsrmdir --ignore-fail-on-non-empty /data/repo/pkg/_tdir sed -i '/^[ \t]*$/d' final_list sort -u final_list > temp rmmv -f temp final_list echo "" >> final_list rm -f list_to_check while ##read Scanpkg; thedo final list ofif packages one-by-one while read pkg; do[[ "" == "$pkg" ]]; then continue fi echo -e "\033[36m =====> Check $pkg... \033[0m" ## Check if thea package exists res=$(apt-cache show $pkg | grep "Package: $pkg") if [[ "$res" != "" ]]; then ## Download theexisted package echo -e "\033[35m =====> Downloading package $pkg... \033[0m" res=$(apt-get -R /data/repo/pkg/_tdir download $pkg | grep "E:" | sed -n 's/E://') ## Check the result of downloading 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 "=======================================" >> errors.log echo "$pkg: $res" >> 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" != "" ]]; then echo "=======================================" >> errors.log echo "$pkg: No package found" >> list_deps errors.log grep ":$pkg" $DEP_FILE >> errors.log fi fi done < final_list ## UploadingDownloading *.deb packages to the local repo echo -e "\033[32;1m =====> Uploading *.deb packages... \033[0m" reprepro -b /data/repo --export=never -C main includedeb du2-prebuild /data/repo/pkg/*.deb ## Loop for download sources while read component; do ## Download source filesif [[ "" == "$component" ]]; then continue fi echo -e "\033[33;1m =====> Downloading sources for $component... \033[0m" apt-get source --download-only $component ## Upload source files to the repo 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