| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | #!/bin/sh
 | 
					
						
							|  |  |  | # Nico Schottelius | 
					
						
							|  |  |  | # Fri May  1 17:31:50 CEST 2015 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PATH=/bin:/sbin:/usr/bin:/usr/sbin | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | if [ "$#" -ne 1 ]; then | 
					
						
							|  |  |  |     echo "$0 dir-out" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | out_dir=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 11:52:14 +02:00
										 |  |  | #bin_list="udevadm bash fdisk mount syslinux umount rm mv" | 
					
						
							|  |  |  | bin_list="udevadm fdisk" | 
					
						
							| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 11:52:14 +02:00
										 |  |  | libs=$(mktemp /tmp/cdist-preos-libs.XXXXXXXXXXXXX) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | mkdir -p "$out_dir/bin" "$out_dir/lib" | 
					
						
							| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | (    | 
					
						
							|  |  |  |     for bin in $bin_list; do | 
					
						
							|  |  |  |         src=$(which "$bin") | 
					
						
							|  |  |  |         cp "$src" "$out_dir/bin" | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |         ldd "$src" | sed -e 's/=>//' -e 's/(.*//' | awk '{ if(NF == 2) { print $2 } else { print $1 } }' | 
					
						
							|  |  |  |     done | 
					
						
							|  |  |  | ) | sort | uniq > "$libs" | 
					
						
							| 
									
										
										
										
											2015-05-05 13:53:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | while read lib; do | 
					
						
							|  |  |  |     if echo $lib | grep '^/'; then | 
					
						
							|  |  |  |         # echo "Copying fqdn lib $lib ..." | 
					
						
							|  |  |  |         cp "$lib" "$out_dir/lib" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         echo "How to copy $lib ?" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | done < "$libs" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 11:52:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | rm -f "$libs" | 
					
						
							| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bin=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 15:16:56 +02:00
										 |  |  | # Not used alternatives | 
					
						
							|  |  |  | # new_list=$(objdump -p /usr/bin/ls | awk '$1 ~ /NEEDED/ { print $2 }') | 
					
						
							|  |  |  | # ldconfig -p | grep 'libBrokenLocale.so.1$' | sed 's/.* => //' | 
					
						
							| 
									
										
										
										
											2015-05-02 12:24:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for new_item in $new_list; do | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ldconfig -p |  |