Changeset 3833
- Timestamp:
- 07/31/08 13:33:59 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
madwifi/branches/madwifi-0.9.4/scripts/make-release.bash
r3340 r3833 4 4 # for it. 5 5 6 # check_dir_prereq: 7 # ensures that a given directory name exist and is writeable 8 # note: $1 is expected to be set to the name of the variable that contains 9 # the name of the directory that is to be tested (indirect reference) 10 function check_dir_prereq { 11 eval d="\$$1" 12 n="$1" 13 14 if [[ ! -d "$d" || ! -w "$d" ]]; then 15 echo 16 echo "ERROR:" 17 echo -n "$n, currently set to $d, " 18 [[ ! -d "$d" ]] && echo "does not exist" || echo "is not writable" 19 echo 20 exit 1 21 fi 22 } 23 24 25 26 6 27 # check if the script has been called directly 7 28 if [[ "$(basename $(pwd))" == "scripts" ]]; then 8 echo9 echo "ERROR:"10 echo "Call this script via \"make release\" in the top-level directory of your"11 echo "working copy."12 echo13 exit 129 echo 30 echo "ERROR:" 31 echo "Call this script via \"make release\" in the top-level directory of your" 32 echo "working copy." 33 echo 34 exit 1 14 35 fi 15 36 … … 17 38 # Makefile.inc) 18 39 if [[ "$RELEASE_TMP" == "" || "$RELEASE_STORE" == "" ]]; then 19 echo 20 echo "ERROR:" 21 echo "RELEASE_TMP and/or RELEASE_STORE are not set. Check Makefile.inc and try again." 22 echo 23 exit 1 24 fi 40 echo 41 echo "ERROR:" 42 echo "RELEASE_TMP and/or RELEASE_STORE are not set. Check Makefile.inc and try again." 43 echo 44 exit 1 45 fi 46 47 # make sure that the directories passed in RELEASE_TMP and RELEASE_STORE 48 # actually exist and are writable for the caller 49 check_dir_prereq "RELEASE_TMP" 50 check_dir_prereq "RELEASE_STORE" 25 51 26 52 # caller must have write access to the madwifi.org repository … … 28 54 repos=$(svn info | grep "Repository Root" | cut -d" " -f3) 29 55 for f in ~/.subversion/auth/svn.simple/*; do 30 if [[ "$(grep -c "$repos" $f)" != "0" ]]; then 31 valid=1 32 break 33 fi 56 [ -f $f ] || continue 57 58 if [[ "$(grep -c "$repos" $f)" != "0" ]]; then 59 valid=1 60 break 61 fi 34 62 done 35 63 36 64 if [[ "$valid" != "1" ]]; then 37 echo 38 echo "WARNING:" 39 echo "Write access to the repository is needed in order to successfully run this" 40 echo "script." 41 42 read -n1 -p "Do you want to continue? [yN] " choice 43 if [[ "$choice" != "y" && "$choice" != "Y" ]]; then 44 echo 45 echo "Aborted." 46 exit 1 47 fi 48 fi 49 50 51 if [[ ! -d "$RELEASE_TMP" ]]; then 52 echo 53 echo "ERROR:" 54 echo "RELEASE_TMP seems to be wrong. $RELEASE_TMP: no such directory" 55 echo 56 exit 1 57 fi 65 echo 66 echo "WARNING:" 67 echo "Write access to the repository is needed in order to successfully run this" 68 echo "script." 69 70 read -n1 -p "Do you want to continue? [yN] " choice 71 if [[ "$choice" != "y" && "$choice" != "Y" ]]; then 72 echo 73 echo "Aborted." 74 exit 1 75 fi 76 fi 77 58 78 59 79 # check if we're in the top-level directory of the snapshot 60 80 if [[ ! -f ./release.h ]]; then 61 echo62 echo "ERROR:"63 echo "It seems that the script has not been called with the top-level directory"64 echo "of the working copy as current working directory. This should not happen"65 echo "if you run \"make release\" in the top-level directory of the working"66 echo "copy."67 echo68 exit 181 echo 82 echo "ERROR:" 83 echo "It seems that the script has not been called with the top-level directory" 84 echo "of the working copy as current working directory. This should not happen" 85 echo "if you run \"make release\" in the top-level directory of the working" 86 echo "copy." 87 echo 88 exit 1 69 89 fi 70 90 71 91 # this script does not work for tarball snapshots 72 92 svn info > /dev/null 2>&1 || { 73 echo74 echo "ERROR:"75 echo "It seems this is no Subversion working copy of MadWifi. This script does"76 echo "not work in such cases."77 echo78 exit 193 echo 94 echo "ERROR:" 95 echo "It seems this is no Subversion working copy of MadWifi. This script does" 96 echo "not work in such cases." 97 echo 98 exit 1 79 99 } 80 100 81 101 # check if local working copy has uncommitted changes 82 if [[ ! -z "$(svn status)" ]]; then 83 echo 84 echo "ERROR:" 85 echo "Your working copy has changes which are not yet committed." 86 echo "Either commit or revert them before you continue to make a release." 87 echo "Aborting for now." 88 echo 89 exit 1 102 changes="$(svn status | sed -e "/^X/d" -e "/^$/d" -e "/external item/d")" 103 if [[ ! -z "$changes" ]]; then 104 echo 105 echo "ERROR:" 106 echo "Your working copy has changes which are not yet committed." 107 echo "Either commit or revert them before you continue to make a release." 108 echo "Aborting for now." 109 echo 110 exit 1 90 111 fi 91 112 … … 96 117 97 118 if [[ "$localrev" != "$remoterev" ]]; then 98 echo99 echo "ERROR:"100 echo "Your working copy is not in sync with the repository. Please update your"101 echo "working copy, then restart the release process."102 echo103 exit 1119 echo 120 echo "ERROR:" 121 echo "Your working copy is not in sync with the repository. Please update your" 122 echo "working copy, then restart the release process." 123 echo 124 exit 1 104 125 fi 105 126 … … 113 134 echo 114 135 if [[ ! -z "$latest" ]]; then 115 major=$(echo $latest | cut -d"." -f1)116 minor=$(echo $latest | cut -d"." -f2)117 point=$(echo $latest | cut -d"." -f3)118 micro=$(echo $latest | cut -d"." -f4)119 120 if [ -n "$micro" ]; then121 echo "The latest release is: $major.$minor.$point.$micro"122 else123 micro="0"124 echo "The latest release is: $major.$minor.$point"125 fi136 major=$(echo $latest | cut -d"." -f1) 137 minor=$(echo $latest | cut -d"." -f2) 138 point=$(echo $latest | cut -d"." -f3) 139 micro=$(echo $latest | cut -d"." -f4) 140 141 if [ -n "$micro" ]; then 142 echo "The latest release is: $major.$minor.$point.$micro" 143 else 144 micro="0" 145 echo "The latest release is: $major.$minor.$point" 146 fi 126 147 else 127 latest="0.0.0"128 major="0"; minor="0"; point="0"; micro="0"129 130 echo "No releases yet."148 latest="0.0.0" 149 major="0"; minor="0"; point="0"; micro="0" 150 151 echo "No releases yet." 131 152 fi 132 153 133 154 valid=0 134 155 while ! ((valid)); do 135 echo 136 echo "Please choose the release type:" 137 echo " 1: major release (new version will be $((major+1)).0.0)" 138 echo " 2: minor release (new version will be $major.$((minor+1)).0)" 139 echo " 3: point release (new version will be $major.$minor.$((point+1)))" 140 echo " 4: micro release (new version will be $major.$minor.$point.$((micro+1))" 141 echo " 5: other (enter new version manually)" 142 echo " 0: abort" 143 echo 144 145 read -n1 -p "Your choice: " choice 146 case "$choice" in 147 1) newmajor=$((major+1)); newminor=0; newpoint=0; newmicro=0; valid=1 ;; 148 2) newmajor=$major; newminor=$((minor+1)); newpoint=0; newmicro=0; valid=1 ;; 149 3) newmajor=$major; newminor=$minor; newpoint=$((point+1)); newmicro=0; valid=1 ;; 150 4) newmajor=$major; newminor=$minor; newpoint=$point; newmicro=$((micro+1)); valid=1 ;; 151 5) 152 echo 153 read -p "Enter release number (a.b.c.d): " newrelease 154 if [[ "$(echo $newrelease | grep -c '^[0-9]*\.[0-9]*\.[0-9]*\(\.[0-9]\)\?$')" == "1" ]]; then 155 newmajor=$(echo $newrelease | cut -d"." -f1) 156 newminor=$(echo $newrelease | cut -d"." -f2) 157 newpoint=$(echo $newrelease | cut -d"." -f3) 158 newmicro=$(echo $newrelease | cut -d"." -f4) 156 echo 157 echo "Please choose the release type:" 158 echo " 1: major release (new version will be $((major+1)).0.0)" 159 echo " 2: minor release (new version will be $major.$((minor+1)).0)" 160 echo " 3: point release (new version will be $major.$minor.$((point+1)))" 161 echo " 4: micro release (new version will be $major.$minor.$point.$((micro+1))" 162 echo " 5: other (enter new version manually)" 163 echo " 0: abort" 164 echo 159 165 160 if [ -n "$newmicro" ]; then 161 newversion="$newmajor.$newminor.$newpoint.$newmicro" 162 else 163 newversion="$newmajor.$newminor.$newpoint" 164 newmicro="0" 165 fi 166 167 if [[ "$(svn list $reproot/tags | grep -c ^release-$newversion)" != "0" ]]; then 168 echo "Release $newversion already exists. Try again." 169 else 170 valid=1 171 fi 172 else 173 echo "Invalid release number." 174 fi 175 ;; 176 0) 177 echo 178 echo "Aborted." 179 exit 0 180 ;; 181 182 *) 183 echo "Invalid." 184 ;; 185 esac 166 read -n1 -p "Your choice: " choice 167 case "$choice" in 168 1) newmajor=$((major+1)); newminor=0; newpoint=0; newmicro=0; valid=1 ;; 169 2) newmajor=$major; newminor=$((minor+1)); newpoint=0; newmicro=0; valid=1 ;; 170 3) newmajor=$major; newminor=$minor; newpoint=$((point+1)); newmicro=0; valid=1 ;; 171 4) newmajor=$major; newminor=$minor; newpoint=$point; newmicro=$((micro+1)); valid=1 ;; 172 5) 173 echo 174 read -p "Enter release number (a.b.c.d): " newrelease 175 if [[ "$(echo $newrelease | grep -c '^[0-9]*\.[0-9]*\.[0-9]*\(\.[0-9]\)\?$')" == "1" ]]; then 176 newmajor=$(echo $newrelease | cut -d"." -f1) 177 newminor=$(echo $newrelease | cut -d"." -f2) 178 newpoint=$(echo $newrelease | cut -d"." -f3) 179 newmicro=$(echo $newrelease | cut -d"." -f4) 180 181 if [ -n "$newmicro" ]; then 182 newversion="$newmajor.$newminor.$newpoint.$newmicro" 183 else 184 newversion="$newmajor.$newminor.$newpoint" 185 newmicro="0" 186 fi 187 188 if [[ "$(svn list $reproot/tags | grep -c ^release-$newversion)" != "0" ]]; then 189 echo "Release $newversion already exists. Try again." 190 else 191 valid=1 192 fi 193 else 194 echo "Invalid release number." 195 fi 196 ;; 197 0) 198 echo 199 echo "Aborted." 200 exit 0 201 ;; 202 203 *) 204 echo "Invalid." 205 ;; 206 esac 186 207 done 187 208 188 209 # reassure that everything is correct 189 210 if [[ "$micro" != "0" ]]; then 190 oldrelease="$major.$minor.$point.$micro"211 oldrelease="$major.$minor.$point.$micro" 191 212 else 192 oldrelease="$major.$minor.$point"213 oldrelease="$major.$minor.$point" 193 214 fi 194 215 195 216 if [[ "$newmicro" != "0" ]]; then 196 newrelease="$newmajor.$newminor.$newpoint.$newmicro"217 newrelease="$newmajor.$newminor.$newpoint.$newmicro" 197 218 else 198 newrelease="$newmajor.$newminor.$newpoint"219 newrelease="$newmajor.$newminor.$newpoint" 199 220 fi 200 221 … … 206 227 read -n1 -p "Is this correct? [yN] " choice 207 228 if [[ "$choice" != "y" && "$choice" != "Y" ]]; then 208 echo209 echo "Aborted."210 exit 0229 echo 230 echo "Aborted." 231 exit 0 211 232 fi 212 233 … … 221 242 mv release.h release.h.old 222 243 sed -e "/svnversion.h/d" \ 223 -e "/RELEASE_TYPE/ s/\".*\"/\"RELEASE\"/" \224 -e "/RELEASE_VERSION/ s/\".*\"/\"$newrelease\"/" release.h.old > release.h244 -e "/RELEASE_TYPE/ s/\".*\"/\"RELEASE\"/" \ 245 -e "/RELEASE_VERSION/ s/\".*\"/\"$newrelease\"/" release.h.old > release.h 225 246 rm -f release.h.old 226 247 … … 254 275 255 276 [[ -d $tmp/madwifi-release ]] || { 256 echo "creating packaging directory..."257 mkdir $tmp/madwifi-release || exit 1277 echo "creating packaging directory..." 278 mkdir $tmp/madwifi-release || exit 1 258 279 } 259 280
