Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  Windows Batch Script for Updating to Latest Rockbox Build
« previous next »
  • Print
Pages: [1] 2

Author Topic: Windows Batch Script for Updating to Latest Rockbox Build  (Read 5645 times)

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Windows Batch Script for Updating to Latest Rockbox Build
« on: April 20, 2010, 04:08:42 AM »
This Windows batch script will download the current build for your player, and install it.  Note that this isn't the "stable" release version that Rockbox Installer defaults to, it's the current build which is updated daily with the latest changes.  It's pretty good at telling you what it's doing while it's doing it, like giving you the percent complete while it's downloading, and displaying the old version of Rockbox on your player, and the new version it's installing.  I set this script to run automatically each night so my player is always running the latest build. 

All you have to do is run it, and it will do the rest.  It will detect the drive letter and model of your player, and download the correct version for your model, then install it.  If you prefer, or if there's a problem with the player determining the location and player model, you can define these settings manually in the beginning of the script.

This script requires two utilities in order to run properly.  They may be on your system already (one of them should be included with Vista and Windows 7) but if they're not, the script will help you download them.

Sometimes Windows throws an error when the script tries to look for the DAP on a removable media drive that doesn't have media in it (like the memory expansion slot on the side of some players).  I can't figure out a way to trap that error, but it can be ignored by pressing the "Continue" button, which is what the script instructs you to do. 

The script makes a directory under c:\Program Files (or wherever your "Program Files" directory is located) called RockboxUpdate where it downloads Rockbox and unzips it before installing.

If anybody tries this script, I would be interested in hearing about any problems, comments, suggestions, or even if it just worked successfully for you.  I think I pushed myself and Windows Batch to the very limit of our respective abilities with this script.

You can copy the code below into a .bat file yourself, or download it from here: http://www.mediafire.com/file/ozoyzowdmrz/RockboxUpdate.bat

Code: [Select]
::
::     This Windows batch script will update your player to the most current build of Rockbox.
::
::     If desired, change the following "set" definitions to reflect your configuration.  If
::     left blank, the script will automatically determine the correct settings.

:: *** This script will automatically determine the correct URL for your model player unless it's specified here
set RockboxURL=

:: *** This script will automatically locate your player unless the drive letter is specified here
Set DAPLetter=

:: -------------------------------------------------------------------------------------------

@echo off
setlocal enableextensions

if exist %Systemroot%\System32\bitsadmin.exe GoTo FindDAPLetter
if exist %systemroot%\MPSReports\MSUS\bin\bitsadmin.exe GoTo FindDAPLetter
if exist %Systemroot%\bitsadmin.exe GoTo FindDAPLetter
GoTo BitsAdminNotFound

:FindDAPLetter
cls
if defined DAPLetter GoTo FindRockboxURL
echo Locating Your Player...
echo.
echo *****************************************************************************
echo ***                                                                       ***
echo ***  If a Windows error box pops up, simply choose "Continue". This will  ***
echo ***  not have a negative effect on locating or updating your player.      ***
echo ***                                                                       ***
echo *****************************************************************************
FOR %%g IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%g:\.rockbox\rockbox-info.txt SET DAPLetter=%%g
if (%DAPLetter%)==() GoTo DAPNotFound

:FindRockboxURL
cls
if defined RockboxURL GoTo CheckDir
for /f "delims=" %%h in ('qgrep -e "Target:" %DAPLetter%:\.rockbox\rockbox-info.txt') do @set TargetDefine=%%h
set PlayerType=%TargetDefine:~8%
Set RockboxURL=http://build.rockbox.org/data/rockbox-%PlayerType%.zip

:CheckDir
cls
echo Checking for RockboxUpdate Directory...
if exist "%programfiles%\RockboxUpdate" GoTo CheckForUnzip
mkdir "%programfiles%\RockboxUpdate"

:CheckForUnzip
set path=%path%;%systemroot%\MPSReports\MSUS\bin;%programfiles%\RockboxUpdate
cls
echo Checking For unzip.exe to Extract Rockbox Files...
if exist "%programfiles%\RockboxUpdate\unzip.exe" GoTo Begin

cls
bitsadmin /RawReturn /Reset
bitsadmin /RawReturn /Create DownloadUnzip
bitsadmin /RawReturn /AddFile DownloadUnzip http://stahlworks.com/dev/unzip.exe "%programfiles%\RockboxUpdate\unzip.exe"
bitsadmin /RawReturn /Resume DownloadUnzip

:StatusLoop1
for /f "delims=" %%d in ('bitsadmin /RawReturn /GetState DownloadUnzip') do @set DownloadUnzipStatus=%%d
for /f "delims=" %%e in ('bitsadmin /RawReturn /GetBytesTotal DownloadUnzip') do @set DownloadUnzipBytesTotal=%%e
for /f "delims=" %%f in ('bitsadmin /RawReturn /GetBytesTransferred DownloadUnzip') do @set DownloadUnzipBytesTransferred=%%f
Set /A DownloadUnzipPercentDone = (%DownloadUnzipBytesTransferred% * 100) / %DownloadUnzipBytesTotal%

cls
echo Downloading unzip.exe to Extract Rockbox Files
echo Status: %DownloadUnzipStatus%
echo File Transfer is %DownloadUnzipPercentDone%%% Complete

ping 224.0.0.0 -n 1 -w 500 > NUL
if %DownloadUnzipStatus% EQU TRANSIENT_ERROR GoTo ErrorDownloadingUnzip
if %DownloadUnzipStatus% NEQ TRANSFERRED GoTo StatusLoop1
bitsadmin /Complete DownloadUnzip

:Begin

cls
echo Deleting Old Rockbox Files...
del /F /Q "%programfiles%\RockboxUpdate\Rockbox_Current.zip"
rd /S /Q "%programfiles%\RockboxUpdate\.rockbox"

cls
echo Starting Transfer of Latest Rockbox Build For: %PlayerType%
bitsadmin /RawReturn /Reset
bitsadmin /RawReturn /Create rockbox
bitsadmin /RawReturn /AddFile rockbox %RockboxURL% "%programfiles%\RockboxUpdate\Rockbox_Current.zip"
bitsadmin /RawReturn /Resume rockbox

:StatusLoop2
for /f "delims=" %%a in ('bitsadmin /RawReturn /GetState rockbox') do @set status=%%a
for /f "delims=" %%b in ('bitsadmin /RawReturn /GetBytesTotal rockbox') do @set BytesTotal=%%b
for /f "delims=" %%c in ('bitsadmin /RawReturn /GetBytesTransferred rockbox') do @set BytesTransferred=%%c
Set /A PercentDone = (%BytesTransferred% * 100) / %BytesTotal%

cls
echo Downloading Latest Rockbox Build For: %PlayerType%
echo Status: %status%
echo File Transfer is %PercentDone%%% Complete

ping 224.0.0.0 -n 1 -w 500 > NUL
if %Status% EQU TRANSIENT_ERROR GoTo ErrorDownloadingRockbox
if %status% NEQ TRANSFERRED GoTo StatusLoop2
bitsadmin /Complete rockbox

:unzip
cls
echo Unzipping Latest Rockbox Build...
unzip -o -qq "%programfiles%\RockboxUpdate\Rockbox_Current.zip" -d "%programfiles%\RockboxUpdate"

::Determine Old Version
for /f "delims=" %%i in ('qgrep -e "Version:" %DAPLetter%:\.rockbox\rockbox-info.txt') do @set OldVersion=%%i
set OldVersion=%OldVersion:~9,-7%

::Determine New Version
for /f "delims=" %%j in ('qgrep -e "Version:" "%programfiles%\RockboxUpdate\.rockbox\rockbox-info.txt"') do @set NewVersion=%%j
set NewVersion=%NewVersion:~9,-7%

cls
echo Updating Your Player with the Latest Rockbox Build For: %PlayerType%
echo.
echo Old Rockbox Version: %OldVersion%
echo New Rockbox Version: %NewVersion%
echo.
echo Please Wait...
xcopy "%programfiles%\RockboxUpdate\.rockbox" %DAPLetter%:\.rockbox /C /E /H /I /R /Y /Q

bitsadmin /Reset
cls

echo Your %PlayerType% Has Been Updated With Rockbox Version %NewVersion%
echo.
echo This Window Will Close Momentarily...
ping 224.0.0.0 -n 1 -w 5000 > NUL

endlocal
exit


::------------------
::Error Handling
::------------------

:ErrorDownloadingUnzip
cls
echo.
echo The following error occurred while downloading unzip.exe:
echo.
bitsadmin /GetError DownloadUnzip
echo.
echo Please restart this script, or try again later.
echo.
pause
bitsadmin /Reset
endlocal
exit

:ErrorDownloadingRockbox
cls
echo.
echo The following error occurred while downloading Rockbox:
echo.
bitsadmin /GetError Rockbox
echo.
echo Please restart this script, or try again later.
echo.
pause
bitsadmin /Reset
endlocal
exit

:DAPNotFound
cls
echo.
echo The script could not locate your player. Make sure it's plugged in and run
echo this script again. If it is plugged in, then manually edit script and modify
echo "Set DAPLetter= " to reflect your player's drive letter.
echo.
pause
bitsadmin /Reset
endlocal
exit

:BitsAdminNotFound
cls
echo.
echo This script requires the Microsoft BITS Administration utility in order to
echo download files. This utility could not be found on your system. You will now
echo be forwarded to a Microsoft URL to download the MS Support Services Reporting
echo Tool, which includes the needed BitsAdmin utility. Run this script again after
echo you have downloaded and installed it.
echo.
pause
cmd /c start http://download.microsoft.com/download/b/b/1/bb139fcb-4aac-4fe5-a579-30b0bd915706/MPSRPT_SUS.EXE
endlocal
exit
« Last Edit: April 30, 2010, 02:58:43 AM by Shiftlock »
Logged

Offline evilnick

  • Rockbox Expert
  • Member
  • *
  • Posts: 431
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #1 on: April 20, 2010, 07:57:08 AM »
I guess that this would be more useful in the Wiki rather than on the forums.
Logged

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #2 on: April 20, 2010, 02:29:03 PM »
Oh, okay.  It didn't occur to me to put it in the wiki.  I've never contributed to it.  I'll look into that tonight.  For now, if anyone wants the companion executables (bitsadmin.exe, sleep,exe, and unzip.exe) I zipped them together with this batch file and it can be downloaded here:

Edit: I removed the link because someone suggested it may be a licensing violation.  Sorry.
« Last Edit: April 20, 2010, 04:42:29 PM by Shiftlock »
Logged

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #3 on: April 20, 2010, 02:30:39 PM »
What are the licenses on those?
Logged

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #4 on: April 20, 2010, 03:35:06 PM »
Quote from: Llorean on April 20, 2010, 02:30:39 PM
What are the licenses on those?

unzip.exe - "Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely."

bitsadmin.exe - This is already part of Vista and Windows 7, and is included with XP Service Pack 2 Support Tools, which can be downloaded from MS.  I can't find any specific licensing information, but I think anyone running Windows will already have a copy of this somewhere on their system.

sleep.exe - I don't know where this came from.  It's such a simple program, there are quite a few different programs called "sleep.exe" floating around the net that all do the same thing.  I suppose I could just re-write this myself.

If it's an issue, I'll remove the link, or just delete the info in this thread entirely.  I certainly didn't intend to steal anyone's software.
Logged

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #5 on: April 20, 2010, 03:50:12 PM »
If you don't have permission to redistribute them (which you seem not to for the latter two) you shouldn't, so the link should at least be removed.
Logged

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #6 on: April 20, 2010, 06:12:43 PM »
Link removed.  Try Google, or PM me if you need help finding these files, and I'll point you in the right direction.  They can all be legally downloaded from the owners' sites without violating any copyrights.
« Last Edit: April 20, 2010, 06:16:11 PM by Shiftlock »
Logged

Offline torne

  • Developer
  • Member
  • *
  • Posts: 994
  • arf arf
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #7 on: April 21, 2010, 05:41:49 AM »
You could just link to the authors' sites, that's a perfectly legitimate thing to do...
Logged
some kind of ARM guy. ipodvideo/gigabeat-s/h120/clipv2. to save time let's assume i know everything.

Offline pondlife

  • Developer
  • Member
  • *
  • Posts: 248
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #8 on: April 21, 2010, 06:20:15 AM »
A hacky way to wait for one second, assuming that's what "sleep 1" does:

Code: [Select]
ping 224.0.0.0 -n 1 -w 1000
Logged

Offline gulak

  • Member
  • *
  • Posts: 26
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #9 on: April 21, 2010, 02:48:02 PM »
Quote from: Shiftlock on April 20, 2010, 06:12:43 PM
Link removed.  Try Google, or PM me if you need help finding these files, and I'll point you in the right direction.  They can all be legally downloaded from the owners' sites without violating any copyrights.
A link never violates a copyright.
Logged

Offline torne

  • Developer
  • Member
  • *
  • Posts: 994
  • arf arf
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #10 on: April 21, 2010, 03:08:03 PM »
Indeed, but we don't want people to link to copyright-infringing files. Linking to a site which has *permission* to distribute something is fine, as I already said.
Logged
some kind of ARM guy. ipodvideo/gigabeat-s/h120/clipv2. to save time let's assume i know everything.

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #11 on: April 22, 2010, 04:08:17 AM »
I edited the original post in this thread.  I modified the script to use the "ping" trick suggested by pondlife, so sleep.exe is no longer necessary.  I also added download links for the other two files.  These links point to the authors' own sites, so there is no copyright violation.

Again, I'm sorry for creating a potential copyright issue.  It wasn't intentional.
« Last Edit: April 22, 2010, 04:41:45 AM by Shiftlock »
Logged

Offline torne

  • Developer
  • Member
  • *
  • Posts: 994
  • arf arf
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #12 on: April 22, 2010, 05:29:35 AM »
A much simpler replacement for BitsAdmin, which is using the complex MS background downloader service, is wget, which is available for pretty much any OS and works in the foreground, so you don't need the status polling loop. wget is GPLed and thus you can redistribute it if you wish.
Logged
some kind of ARM guy. ipodvideo/gigabeat-s/h120/clipv2. to save time let's assume i know everything.

Offline Shiftlock

  • Member
  • *
  • Posts: 20
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #13 on: April 24, 2010, 05:32:02 AM »
I made some major changes to this batch script, so I edited the original post in this thread with the updated code and info.  Is anybody interested in testing it?  It's quite a bit more complex now. I'm sure there are better ways to do a lot of this, seeing that this is the first programming I've messed with since BASIC on the Commodore 64 over 25 years ago, so please, no laughter if my routines and syntax are backasswards. <grin>

The script will now:

  • Create a directory under Program Files called RockboxUpdate, if it doesn't already exist, where it will download and unzip the Rockbox files.
  • Check to see if the BITSAdmin utility exists on the system, and if not, opens a download of it in a browser window.
  • Check to see if unzip.exe exists, and if not, it will download it and keep running.
  • Automatically locate the drive letter of the player.

The only variable that needs to be manually defined is the URL for the player's Rockbox build.  I haven't figured out a way to determine that yet, although looking in the .rockbox/rockbox-info.txt file might be the answer.

Question: The only DAP I've installed Rockbox on is the Sansa Fuze V1 and V2.  Is the process of installing a new compiled build the same on other players (i.e. copy the .rockbox folder)?
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Windows Batch Script for Updating to Latest Rockbox Build
« Reply #14 on: April 24, 2010, 05:47:11 AM »
Quote from: Shiftlock on April 24, 2010, 05:32:02 AM
The only variable that needs to be manually defined is the URL for the player's Rockbox build.  I haven't figured out a way to determine that yet, although looking in the .rockbox/rockbox-info.txt file might be the answer.

Yes, that's a possible way. Rockbox Utility uses this file (amonst other measures) to detect the player, and if that file is found the detection is unique (various other methods used for detecting the player are not).

Quote
Question: The only DAP I've installed Rockbox on is the Sansa Fuze V1 and V2.  Is the process of installing a new compiled build the same on other players (i.e. copy the .rockbox folder)?

yes.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

  • Print
Pages: [1] 2
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  Windows Batch Script for Updating to Latest Rockbox Build
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.12 seconds with 15 queries.