123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- #!/bin/bash
- # Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- arguments() {
- local project=$1
- if [ -z "$project" ]
- then
- ls -A "$root/$PROJECTS/" | while read project
- do
- echo "$project"
- done
- else
- shift
- project_action_helper "arguments" "$project" "$@"
- fi
- }
- usage() {
- tool_usage_actions "$tool" "verify"
- tool_usage_arguments "$tool" "$@"
- }
- update() {
- local tool_path=$( tool_path "$tool" )
- local sources_path=$( tool_sources_path "$tool" )
- local deblob_check_path="$sources_path/deblob-check"
- local patches_path="$tool_path/$PATCHES/$WILDDOTPATCH"
- wget "https://www.fsfla.org/svn/fsfla/software/linux-libre/scripts/deblob-check" -O "$deblob_check_path"
- perl -0777 -i -pe "s/ blobna \(\) \{[^\}]*\}/ blobna () \{\n true\n \}/" "$deblob_check_path"
- perl -0777 -i -pe "s/ blobname \(\) \{[^\}]*\}/ blobname () \{\n true\n \}/" "$deblob_check_path"
- chmod a+x "$deblob_check_path"
- cd "$sources_path"
- path_wildcard_expand "$patches_path" | while read patch_path
- do
- if ! [ -f "$patch_path" ]
- then
- continue
- fi
- patch -p1 < "$patch_path"
- done
- }
- verify() {
- local project=$1
- shift
- local project_path=$( project_path "$project" )
- local project_sources_path=$( project_sources_path "$project" "$repository" "$@" )
- local project_blobs_path=$( project_blobs_path "$project" "$@" )
- local project_blobs_ignore_path=$( project_blobs_ignore_path "$project" "$@" )
- local project_blobs_discover_path
- local ifs_save
- local file
- local choice
- requirements "sort"
- if ! [ -z "$project_blobs_path" ]
- then
- project_blobs_discover_path="$( dirname $project_blobs_path )/$BLOBS_DISCOVER"
- else
- project_blobs_discover_path="$project_path/$CONFIGS/$BLOBS_DISCOVER"
- fi
- file_exists_check "$project_blobs_discover_path"
- # This it to allow space characters in arguments.
- ifs_save=$IFS
- IFS=$'\n'
- for file in $( cat "$project_blobs_discover_path" )
- do
- (
- IFS=$ifs_save
- printf "\nDiscovered blob: $file\n"
- $EDITOR "$project_sources_path/$file"
- printf "Type \"blob\" to keep or press enter to discard: "
- read choice
- if [ "$choice" = "blob" ]
- then
- echo "$file" >> "$project_blobs_path"
- else
- echo "$file" >> "$project_blobs_ignore_path"
- fi
- sed "\|^$file$|d" -i "$project_blobs_discover_path"
- ) < /dev/tty
- done
- IFS=$ifs_save
- rm "$project_blobs_discover_path"
- sort -o "$project_blobs_path" "$project_blobs_path"
- sort -o "$project_blobs_ignore_path" "$project_blobs_ignore_path"
- }
- execute() {
- local project=$1
- shift
- local repository=$project
- local repository_path=$( git_project_repository_path "$repository" )
- # This assumes that the repository is the project, which is not always the case.
- project_sources_directory_missing_empty_error "$project" "$repository"
- local sources_path=$( tool_sources_path "$tool" )
- local project_path=$( project_path "$project" )
- local project_sources_path=$( project_sources_path "$project" "$repository" "$@" )
- local project_blobs_path=$( project_blobs_path "$project" "$@" )
- local project_blobs_ignore_path=$( project_blobs_ignore_path "$project" "$@" )
- local project_blobs_directory_path
- if ! [ -z "$project_blobs_path" ]
- then
- project_blobs_discover_path="$( dirname $project_blobs_path )/$BLOBS_DISCOVER"
- else
- project_blobs_discover_path="$project_path/$CONFIGS/$BLOBS_DISCOVER"
- fi
- local deblob_check_path="$sources_path/deblob-check"
- if git_project_check "$repository"
- then
- git_project_checkout "$project" "$repository" "$@"
- git_clean "$repository_path"
- fi
- printf "\nDiscovering new blobs, this may take a while...\n"
- files=$( find "$project_sources_path" -type f | grep -vP "\.git/|\.tar|\.patch" )
- touch "$project_blobs_discover_path"
- echo "$files" | while read file
- do
- if ! [ -z "$project_blobs_ignore_path" ]
- then
- match=$( grep "$file" "$project_blobs_ignore_path" || true)
- if [ ! -z "$match" ]
- then
- continue
- fi
- fi
- match=$( "$deblob_check_path" -l -i "" "$file" || true )
- if ! [ -z "$match" ]
- then
- echo "$match" >> "$project_blobs_discover_path"
- fi
- done
- printf "\nDiscovered blobs were stored in $project_blobs_discover_path\n"
- }
- execute_check() {
- local project=$1
- shift
- local project_path=$( project_path "$project" )
- local project_blobs_path=$( project_blobs_path "$project" "$@" )
- local project_blobs_ignore_path=$( project_blobs_ignore_path "$project" "$@" )
- local project_blobs_discover_path
- if ! [ -z "$project_blobs_path" ]
- then
- project_blobs_discover_path="$( dirname $project_blobs_path )/$BLOBS_DISCOVER"
- else
- project_blobs_discover_path="$project_path/$CONFIGS/$BLOBS_DISCOVER"
- fi
- file_exists_check "$project_blobs_discover_path"
- }
|