From: Chris Koeritz Date: Mon, 13 Feb 2012 02:17:19 +0000 (-0500) Subject: renamed 'base' variable since that's too non-descript. X-Git-Tag: 2.140.90~1611 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=7ef9f4fdbae698dff9a08189f616564d471abc45;p=feisty_meow.git renamed 'base' variable since that's too non-descript. made snarf by pattern support an extra directory component. added quoting so that paths with spaces should work better. --- diff --git a/scripts/archival/shared_snarfer.pl b/scripts/archival/shared_snarfer.pl index 783a80d2..00c41d3f 100644 --- a/scripts/archival/shared_snarfer.pl +++ b/scripts/archival/shared_snarfer.pl @@ -177,7 +177,7 @@ sub snarfer { chdir($root); local($outcome) = 0; - my @lines = qx( $find_tool $subdir @extra_flags "-type" "f" ); + my @lines = qx( $find_tool "$subdir" @extra_flags "-type" "f" ); # if ( ($! != 0) || ($? != 0) ) { # die("failure to find files in $subdir"); # } @@ -277,7 +277,7 @@ sub remove_from_backup { # recursively scoops up a directory hierarchy. sub backup_hierarchy { local($prefix, $number, $root, $filepart) = @_; -#print "backup_hierarchy: pref=$prefix, num=$number, root=$root, filepart=$filepart\n"; +print "backup_hierarchy: pref=$prefix, num=$number, root=$root, filepart=$filepart\n"; local(@locus_temp) = &glob_list($root); local($save_root) = $root; local($root) = $locus_temp[0]; @@ -324,22 +324,30 @@ sub backup_hierarchies { } } -# grab up all the files in a directory (first parm) that are named matching -# a simple text pattern (second parm). +# grab up all the files in a directory (second parm) that are named matching +# a simple text pattern (third parm). if there is a fourth parameter, it is +# used as an extra directory component after the main directory. sub snarf_by_pattern { - local($dir, $pattern) = @_; + local($prefix, $dir, $pattern, $extra_component) = @_; # print "dir = $dir and patt = $pattern\n"; + $extra_piece = ""; + $dir_for_hierarchy = "."; + if (length($extra_component)) { + $extra_piece = "/" . $extra_component; + $dir_for_hierarchy = $extra_component; + } - @dir_contents = &glob_list("$dir/*$pattern*"); -# print "dir contents: @dir_contents\n"; + @dir_contents = &glob_list("$dir$extra_piece/*$pattern*"); + print "dir contents: @dir_contents\n"; if (!scalar(@dir_contents)) { - print "no $pattern directores were backed up in $dir.\n"; + print "no '$pattern' directores were backed up in $dir.\n"; } + foreach $item (@dir_contents) { if ( ($item =~ /$pattern.*snarf/) || ($item =~ /$pattern.*tar/) ) { next; } if ( ! -d "$item" ) { next; } - &backup_hierarchy($base, $number, $item, "."); + &backup_hierarchy($prefix, $number, $dir, "$dir_for_hierarchy" . "/" . &basename($item)); } } diff --git a/scripts/archival/snarf_feisty_meow.pl b/scripts/archival/snarf_feisty_meow.pl index f9e832a7..648f1572 100644 --- a/scripts/archival/snarf_feisty_meow.pl +++ b/scripts/archival/snarf_feisty_meow.pl @@ -24,41 +24,41 @@ require "shared_snarfer.pl"; local($number) = &retrieve_number("aa_backup"); # variables used throughout here. -local($base) = &snarf_prefix("feisty_meow"); -local($snarf_file) = &snarf_name($base, $number); +local($snarf_file_base) = &snarf_prefix("feisty_meow"); +local($snarf_file) = &snarf_name($snarf_file_base, $number); # store the archive number in the file for retrieval on the other side. -&backup_number("aa_backup", $base, $number); +&backup_number("aa_backup", $snarf_file_base, $number); # the top directory where everything we're grabbing lives. local($root) = &canonicalize("$HOME/feisty_meow"); # grab the top level stuff. -&backup_files($base, $number, $root, ".", ("*.txt", "make*", ".gitignore")); +&backup_files($snarf_file_base, $number, $root, ".", ("*.txt", "make*", ".gitignore")); # get the documentation directory. -&backup_hierarchy($base, $number, "$root", "docs"); +&backup_hierarchy($snarf_file_base, $number, "$root", "docs"); ### #oldversion -#&snarfer($base, $number, $root, "docs", ("-maxdepth", "1")); +#&snarfer($snarf_file_base, $number, $root, "docs", ("-maxdepth", "1")); # get an extra folder we like. -#&backup_hierarchy($base, $number, "$root", "docs/text_examples"); +#&backup_hierarchy($snarf_file_base, $number, "$root", "docs/text_examples"); ### # get our databases that we ship with the sources. -&backup_hierarchy($base, $number, $root, "database"); +&backup_hierarchy($snarf_file_base, $number, $root, "database"); # get all the yeti scripts hierarchy in there. -&backup_hierarchy($base, $number, $root, "scripts"); +&backup_hierarchy($snarf_file_base, $number, $root, "scripts"); # get all C++ code project hierarchies. -&backup_hierarchy($base, $number, "$root", "nucleus"); -&backup_hierarchy($base, $number, "$root", "octopi"); -&backup_hierarchy($base, $number, "$root", "graphiq"); +&backup_hierarchy($snarf_file_base, $number, "$root", "nucleus"); +&backup_hierarchy($snarf_file_base, $number, "$root", "octopi"); +&backup_hierarchy($snarf_file_base, $number, "$root", "graphiq"); # grab the production assets. -&backup_files($base, $number, $root, "production", ("*.ini", "make*")); -&backup_hierarchy($base, $number, "$root", "production/setup_src"); +&backup_files($snarf_file_base, $number, $root, "production", ("*.ini", "make*")); +&backup_hierarchy($snarf_file_base, $number, "$root", "production/setup_src"); # now rename the file so only the unpacker can access it. &rename_archive($snarf_file); diff --git a/scripts/archival/snarf_linux_config.pl b/scripts/archival/snarf_linux_config.pl index 71c3fa1a..7420c031 100644 --- a/scripts/archival/snarf_linux_config.pl +++ b/scripts/archival/snarf_linux_config.pl @@ -24,12 +24,12 @@ require "shared_snarfer.pl"; local($number) = &retrieve_number("aa_backup"); # variables used throughout. -local($base) = snarf_prefix("linux_config"); -local($snarf_file) = &snarf_name($base, $number); +local($snarf_file_base) = snarf_prefix("linux_config"); +local($snarf_file) = &snarf_name($snarf_file_base, $number); # store the current archive number in the file for retrieval on the # other side. -&backup_number("aa_backup", $base, $number); +&backup_number("aa_backup", $snarf_file_base, $number); # write a little file showing the disk status. local($infofile) = $HOME . "/disk_info.txt"; @@ -46,43 +46,43 @@ print INF "Current disk configuration:\n"; print INF "\n"; close(INF); system("fdisk -l >>$HOME/disk_info.txt"); -&backup_files($base, $number, $HOME, ".", ("disk_info.txt")); +&backup_files($snarf_file_base, $number, $HOME, ".", ("disk_info.txt")); unlink $infofile; # backup the dpkg info. -&backup_files($base, $number, "/", "var/lib/dpkg", ("status*")); +&backup_files($snarf_file_base, $number, "/", "var/lib/dpkg", ("status*")); # backup the crucial hierarchies in /var... -&backup_hierarchy($base, $number, "/", "var/named"); -###not good: &backup_hierarchy($base, $number, "/", "var/lib/mysql"); +&backup_hierarchy($snarf_file_base, $number, "/", "var/named"); +###not good: &backup_hierarchy($snarf_file_base, $number, "/", "var/lib/mysql"); ###the mysql snarf is not necessarily usable, since we really should be ###backing up the databases by another means than this. -&backup_hierarchy($base, $number, "/", "var/lib/named/master"); -&backup_hierarchy($base, $number, "/", "var/lib/webalizer"); +&backup_hierarchy($snarf_file_base, $number, "/", "var/lib/named/master"); +&backup_hierarchy($snarf_file_base, $number, "/", "var/lib/webalizer"); # snag the grub bootloader files. -&backup_hierarchy($base, $number, "/", "boot/grub"); +&backup_hierarchy($snarf_file_base, $number, "/", "boot/grub"); # now get the entire /etc hierarchy... -&backup_hierarchy($base, $number, "/", "etc"); +&backup_hierarchy($snarf_file_base, $number, "/", "etc"); # clean out extra files. -&remove_from_backup($base, $number, "etc/cups/ppds.dat*"); -&remove_from_backup($base, $number, "etc/httpd/conf/ssl.crt/ca-bundle.crt"); -&remove_from_backup($base, $number, "etc/locale/*"); -&remove_from_backup($base, $number, "etc/opt/kde3/share/services/ksycoca"); -&remove_from_backup($base, $number, "etc/preload.d/*"); -&remove_from_backup($base, $number, "etc/rmt"); -&remove_from_backup($base, $number, "etc/termcap"); -&remove_from_backup($base, $number, "etc/X11/X"); -&remove_from_backup($base, $number, "etc/X11/xkb/*"); -&remove_from_backup($base, $number, "*.bak"); -&remove_from_backup($base, $number, "*.cache"); -&remove_from_backup($base, $number, "*.crt"); -&remove_from_backup($base, $number, "*.old"); -&remove_from_backup($base, $number, "*.schemas"); -&remove_from_backup($base, $number, "*.so"); -&remove_from_backup($base, $number, "*.xml"); +&remove_from_backup($snarf_file_base, $number, "etc/cups/ppds.dat*"); +&remove_from_backup($snarf_file_base, $number, "etc/httpd/conf/ssl.crt/ca-bundle.crt"); +&remove_from_backup($snarf_file_base, $number, "etc/locale/*"); +&remove_from_backup($snarf_file_base, $number, "etc/opt/kde3/share/services/ksycoca"); +&remove_from_backup($snarf_file_base, $number, "etc/preload.d/*"); +&remove_from_backup($snarf_file_base, $number, "etc/rmt"); +&remove_from_backup($snarf_file_base, $number, "etc/termcap"); +&remove_from_backup($snarf_file_base, $number, "etc/X11/X"); +&remove_from_backup($snarf_file_base, $number, "etc/X11/xkb/*"); +&remove_from_backup($snarf_file_base, $number, "*.bak"); +&remove_from_backup($snarf_file_base, $number, "*.cache"); +&remove_from_backup($snarf_file_base, $number, "*.crt"); +&remove_from_backup($snarf_file_base, $number, "*.old"); +&remove_from_backup($snarf_file_base, $number, "*.schemas"); +&remove_from_backup($snarf_file_base, $number, "*.so"); +&remove_from_backup($snarf_file_base, $number, "*.xml"); # now rename the file so only the unpacker can access it. &rename_archive($snarf_file); diff --git a/scripts/archival/snarf_notes.pl b/scripts/archival/snarf_notes.pl index 8c994797..b8b3c9f1 100644 --- a/scripts/archival/snarf_notes.pl +++ b/scripts/archival/snarf_notes.pl @@ -28,27 +28,30 @@ local($number) = &retrieve_number("aa_backup"); # variables for directory location to backup and the file to dump it in. local($root) = "$HOME"; -local($base) = &snarf_prefix("notes"); -local($snarf_file) = &snarf_name($base, $number); +local($snarf_file_base) = &snarf_prefix("notes"); +local($snarf_file) = &snarf_name($snarf_file_base, $number); # store the archive number in the file for retrieval on the other side. -&backup_number("aa_backup", $base, $number); +&backup_number("aa_backup", $snarf_file_base, $number); ############################################################################ # get top level text files and other potentially important items... -&backup_files($base, $number, $root, ".", ("*.html", "*.txt")); +&backup_files($snarf_file_base, $number, $root, ".", ("*.html", "*.txt")); # backup all the hierarchies in our quartz directory. -&backup_hierarchy($base, $number, "$root", "quartz"); +&backup_hierarchy($snarf_file_base, $number, "$root", "quartz"); # gather any directories in our home that match these often recurring patterns. -&snarf_by_pattern("$root", "notes"); -&snarf_by_pattern("$root", "project"); -&snarf_by_pattern("$root", "issue"); -&snarf_by_pattern("$root", "idea"); -&snarf_by_pattern("$root", "crucial"); -&snarf_by_pattern("$root", "list"); -&snarf_by_pattern("$root", "task"); +&snarf_by_pattern($snarf_file_base, "$root", "notes"); +&snarf_by_pattern($snarf_file_base, "$root", "project"); +&snarf_by_pattern($snarf_file_base, "$root", "issue"); +&snarf_by_pattern($snarf_file_base, "$root", "idea"); +&snarf_by_pattern($snarf_file_base, "$root", "crucial"); +&snarf_by_pattern($snarf_file_base, "$root", "list"); +&snarf_by_pattern($snarf_file_base, "$root", "task"); + +# backup additional items from our Ubuntu One folder. +&snarf_by_pattern($snarf_file_base, "$root", "notes", "Ubuntu One"); ############################################################################ diff --git a/scripts/archival/snarf_opensim.pl b/scripts/archival/snarf_opensim.pl index a24dace2..94fd8bd7 100644 --- a/scripts/archival/snarf_opensim.pl +++ b/scripts/archival/snarf_opensim.pl @@ -27,30 +27,30 @@ require "shared_snarfer.pl"; local($number) = &retrieve_number("aa_backup"); # variables used throughout here. -local($base) = &snarf_prefix("opensim_config"); -local($snarf_file) = &snarf_name($base, $number); +local($snarf_file_base) = &snarf_prefix("opensim_config"); +local($snarf_file) = &snarf_name($snarf_file_base, $number); # store the archive number in the file for retrieval on the other side. -&backup_number("aa_backup", $base, $number); +&backup_number("aa_backup", $snarf_file_base, $number); # the top directory where everything we're grabbing lives. local($root) = &canonicalize(&glob_list("$HOME/opensim")); # grab the top level stuff. -#&backup_files($base, $number, $HOME, ".", +#&backup_files($snarf_file_base, $number, $HOME, ".", # ("*.sh")); -&backup_files($base, $number, $root, ".", +&backup_files($snarf_file_base, $number, $root, ".", ("*.sh")); # snag the main config files. -&backup_files($base, $number, $root, "bin", +&backup_files($snarf_file_base, $number, $root, "bin", ("OpenSim.ini", "Robust.ini", "OpenSim.exe.config", "Robust.exe.config")); # snag the configuration include file. -&backup_files($base, $number, $root, "bin/config-include", ("GridCommon.ini")); +&backup_files($snarf_file_base, $number, $root, "bin/config-include", ("GridCommon.ini")); # get the region definitions. -&backup_hierarchy($base, $number, "$root", "bin/Regions"); +&backup_hierarchy($snarf_file_base, $number, "$root", "bin/Regions"); # now rename the file so only the unpacker can access it. &rename_archive($snarf_file); diff --git a/scripts/archival/snarf_user.pl b/scripts/archival/snarf_user.pl index ce21b03a..7abd79d3 100644 --- a/scripts/archival/snarf_user.pl +++ b/scripts/archival/snarf_user.pl @@ -28,24 +28,24 @@ local($number) = &retrieve_number("aa_backup"); # variables for directory location to backup and the file to dump it in. local($root) = "$HOME"; -local($base) = snarf_prefix("$USER"); -local($snarf_file) = &snarf_name($base, $number); +local($snarf_file_base) = snarf_prefix("$USER"); +local($snarf_file) = &snarf_name($snarf_file_base, $number); # store the archive number in the file for retrieval on the other side. -&backup_number("aa_backup", $base, $number); +&backup_number("aa_backup", $snarf_file_base, $number); ############################################################################ # backup all the config info for kde. -&backup_hierarchy($base, $number, "$root", ".kde"); +&backup_hierarchy($snarf_file_base, $number, "$root", ".kde"); # get any dot files ending in "rc", or with "bash" or "profile" in them, or # that start with "x". -&backup_files($base, $number, $root, ".", +&backup_files($snarf_file_base, $number, $root, ".", ("*rc", ".*bash*", ".*profile*", ".x*", )); # get the ssh configuration files. -&backup_hierarchy($base, $number, "$root", ".ssh"); +&backup_hierarchy($snarf_file_base, $number, "$root", ".ssh"); # now rename the file so only the unpacker can access it. &rename_archive($snarf_file);