diff --git a/bcmkernel/scripts/bcm_git_ignore.sh b/bcmkernel/scripts/bcm_git_ignore.sh index 964c21927f79d9eade82792dfe1f6085903cf4fa..9599617886f2f21631ffcd8a42e38d161a138f99 100755 --- a/bcmkernel/scripts/bcm_git_ignore.sh +++ b/bcmkernel/scripts/bcm_git_ignore.sh @@ -3,43 +3,55 @@ usage () { cat <<EOF -ex: - bcm_git_ignore.sh -c bcm_5.04L.02test4 -p "963158BGWV 963138BGWV 947622GW" -r bcmcreator_pre -i gitignore +NAME + bcm_git_ignore - creates a .gitignore in the directory bcm963xx + +SYNOPSIS + bcm_git_ignore [OPTION]... +DESCRIPTION +Run this script to create a single bcm963xx/.gitignore for all the listed profiles. + +ex: +./bcm_git_ignore.sh -c iopsys_5.04L.04 -p "96846GOV96856GWO_WL21D2GA 96858GWO_WL21D2GA 96888GWO_WL21D2GA" -r /home/user/bcm963xx-bsp + -c, --commitref + branch-name, tag-name, commit-hash, ... + -h, --help + display help theme, exit + -p, ---profiles + profiles used to generate .gitignore for + -r, --repo + path to the git repository to use EOF } # Convert long opts to short opts for arg in "$@"; do shift case "$arg" in - "--help") set -- "$@" "-h" ;; - "--repo") set -- "$@" "-r" ;; - "--commit") set -- "$@" "-c" ;; - "--profiles") set -- "$@" "-p" ;; - "--ignorefile") set -- "$@" "-i" ;; - *) set -- "$@" "$arg" + "--commit") set -- "$@" "-c" ;; + "--help") set -- "$@" "-h" ;; + "--profiles") set -- "$@" "-p" ;; + "--repo") set -- "$@" "-r" ;; + *) set -- "$@" "$arg" esac done # parse short opts -while getopts "hc:r:p:i:" opt; do +while getopts "hc:p:r:" opt; do case ${opt} in + c ) + commit=$OPTARG + ;; h ) usage exit 0 ;; - c ) - commit=$OPTARG - ;; p ) profiles=$OPTARG ;; r ) repo_name=$OPTARG ;; - i ) - ignorefile=$OPTARG - ;; esac done shift $((OPTIND -1)) @@ -50,51 +62,46 @@ then exit 1 fi -if [ ! -f "$ignorefile" ] -then - echo "Need some top level ignore file -i xxxxx/.gitignore" - exit 1 -fi - if [ -z "$profiles" ] then - echo "Need some broadcom SDK PROFILES to compile -p \"963158BGWV 963138BGWV\"" + echo "Need some broadcom SDK PROFILES to compile -p \"96858GWO_WL21D2GA 96888GWO_WL21D2GA\"" exit 1 fi -if [ ! -d "$repo_name" ] +if [ -z "$repo_name" ] then - echo "Need some repo to work in" + echo "The directory for the git repository needs to be specified. ex -r /home/user/bcm963xx-bsp" exit 1 fi new_gitignore=$(mktemp) -echo "# this is an autognerated gitignore. from bcm_git_ignore.sh script" >>$new_gitignore -echo "# Manually add files to ../.gitignore instead." >>$new_gitignore -echo "# or to ../Makefile" >>$new_gitignore +cat << EOF > $new_gitignore +# Files below are autogenerated using bcm_git_ignore.sh script. +# Profile(s) used: $profiles +EOF for profile in $profiles do echo "Compiling target $profile" # checkout and make sure everything is clean. - git -C ${repo_name} reset --hard - git -C ${repo_name} clean -ffxd - git -C ${repo_name} checkout $commit - git -C ${repo_name} reset --hard - git -C ${repo_name} clean -ffxd + git -C "$repo_name" reset --hard -q + git -C "$repo_name" clean -ffxd + git -C "$repo_name" checkout -q $commit + git -C "$repo_name" reset --hard -q + git -C "$repo_name" clean -ffxd ( cd $repo_name/bcm963xx - make PROFILE=$profile + make PROFILE=$profile ) - cp $ignorefile ${repo_name}/.gitignore - git -C ${repo_name}/bcm963xx status -s | cut -c4- >>$new_gitignore + rm -f $repo_name/bcm963xx/.gitignore + git -C "$repo_name"/bcm963xx ls-files --others --exclude-standard --directory --no-empty-directory >>$new_gitignore done -sort $new_gitignore | uniq > ${repo_name}/bcm963xx/.gitignore +sort $new_gitignore | uniq > $repo_name/bcm963xx/.gitignore rm $new_gitignore -echo "done! new git ignore in ${repo_name}/bcm963xx/.gitignore" +echo "done! new .gitignore in $repo_name/bcm963xx/.gitignore"