Friday, 31 January 2020

pkgbuild basics - Creating a basic pkg installer on OSX


pkguild is a command-line tool used to create installers, there are easier tools for creating installers such as Packages which uses a graphical user interface.

The way pkgbuild works is that you create a folder structure that acts as the root directory of the target machine, then you move the files for the installer into this fake root folder with the desired folder structure. 
When you run the pkgbuild command you tell it what the root folder is and pkbuild essentially trims off that part of the file path to figure out where to install your files.
The result will be an installer (.pkg file) that will install your files and look something like this:
Image of an installer dialog for example project myapp

In this example I've created a directory called "instroot" in my documents. 
I want "myApp" to be installed at /Applications/myApp so I've copied it to the new folder:
~/Documents/instroot/Applications/MyApp

I also want some text files to be installed at /Library/Application Support/myApp so I've copied them into the new folder too:
~/Documents/instroot/Library/Application Support/myApp/myAppFile1.txt





once all the files for the installer are in the correct place, we just need to call this command:

pkgbuild --root --identifier --version packagename

root: the install root
identifier: an ID for your installer (used only by the operating system and can be anything you want but so try to make it meaningful and unique)
version: the version of your project
packagename: the name for the output installer, the name is also used in the installer dialog

for my example project the command is:

pkgbuild --root ~/Documents/instroot --identifier com.myapp.test --version 1.0 myapp.pkg


We can also use the pkgutil --payload-files command to list the installer files and sanity check the contents.

Now we have an installer called myapp.pkg! Double clicking it will start the installer.





Friday, 19 July 2019

Chuck DirectSound error fix


I'm learning dsp and following a tutorial that uses chuck, I install it, try it, and it falls over instantly with this error:

[chuck]: (DirectSound) error (Generic error) creating input buffer (Default Device)!



Solution:
  1. Go to Start Settings Privacy Settings → Microphone
  2. Turn on "Allow apps to access your microphone"
Now you'll never see this error again!

Microphone settings window shows "Allow apps to access your microphone" turned on.

Tuesday, 2 July 2019

Fix for Jenkins on Mac getting stuck on overnight builds




Every night my dutiful Jenkins build servers build their jobs and every morning I come in to find that a job on OSX has gotten stuck on 'git fetch' all night. The job's console output looks something like this:

[EnvInject] - Loading node environment variables.
Building in workspace /Users/me/Projects/MyProject
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
using credential xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Cloning the remote Git repository
Cloning repository ssh://myname@website.org/repo.git
 > /usr/local/bin/git init /Users/me/Projects/MyProject# timeout=10
Fetching upstream changes from ssh://myname@website.org/repo.git
 > /usr/local/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > /usr/local/bin/git fetch --tags --progress ssh://myname@website.org/repo.git +refs/heads/*:refs/remotes/origin/*

Sometimes it starts again while you're looking at it, as if embarrassed to be caught slacking off all night.


Resolution:

This is because I turn off the display in the evening and the OSX build server server decides to go into sleep mode. Here's how to turn that feature off:


  1. Go the the Apple menu, select System Preferences then Energy Saver
  2. Check the box that says "Prevent computer from sleeping automatically when the display is off"

Monday, 20 May 2019

Building visual studio solutions on Jenkins


These are instructions on how to set up and use the MSBuild plugin for jenkins.

Adding MSBuild settings


  1. Go to the jenkins Global Tool Configuration and scroll to find the MSBuild section.
  2. Click "MSBuild Installations..." then "Add MSBuild", now you should see 3 fields to fill in.
  3. Name: Your identifier for these settings, this can be whatever you like but I suggest describing the settings e.g. "vs2019 Release settings"
  4. Path to MSBuild: The path to the Visual Studio compiler.
    Gotcha: In my experience to use the visual studio 2015 compiler I had to include the compiler in the path otherwise the plugin complains about not finding the compiler. Jenkins shows a warning when you do this but it works.
    • For Visual Studio 2015 use MSBuild 14 at:
      C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe
    • For Visual Studio 2017 use MSBuild 15 at:
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
    • For Visual Studio 2019 use MSBuild 16 at:
      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
  5. Default parameters: Write here what parameters you wish to give the compiler.
    e.g.:
    -t:Clean,Build -p:Configuration="Release" -p:Platform="x64"
    MSBuild 16 uses hyphens for parameters but MSBuild 14 and 15 use a forward slash instead "/t:Clean,Build /p:Configuration="Release" /p:Platform="x64""
    If you're unsure open a command prompt and run MSBuild.exe --help or MSBuild.exe /help
  6. Click Save


Adding MSBuild to a job


  1. Go to the job configuration and scroll to find the Build section 
  2. Click Add build step and choose "Build a Visual Studio project or solution using MSBuild"
  3. In the MSBuild Version list select the setting you saved earlier.
  4. In the MSBuild Build File enter the path for the solution
    e.g. "
    $WORKSPACE\Builds\VisualStudio2019\MyProject.sln"
    (Conviently, you can use the jenkins environment variables here)
  5. Optional Additional parameters may be added to Command Line Arguments text box.
  6. Click Save



Monday, 18 February 2019

Script to remove all local git branches that have been merged


This is a bash script that removes all local git branches if:
- they have been merged
- they are not called develop
- they are not called master

It lists the branches and prompts me to confirm the list before the deleting starts.

deleting my local branches using the script

The script:

function remove_branches {
  echo "Removing all merged local branches!!!"
  for k in $(git branch --merged  | sed /\*/d); do 
    if [ -z $(echo $k | grep -i 'master\|develop') ]; then
      git branch -D $k
    fi
  done
exit
}


# Print branches to be deleted
for k in $(git branch --merged | sed /\*/d); do 
  if [ -z $(echo $k | grep -i 'master\|develop') ]; then
      echo $k
  fi
done


# Prompt user to delete branches
while true; do
read -p "Do you wish to remove these branches?" yn
case $yn in
[Yy]* ) remove_branches;;
[Nn]* ) echo "okay."; exit;;
* ) echo "Please answer yes or no."
esac
done

Friday, 1 February 2019

Bash command batch for renaming files without prefix


This line renames all files in a directory to remove the front of their names up to and including the first underscore character.
e.g.:
1242_file.txt
1209_another_file.txt
99_red balloons.wav

~becomes~

file.txt
another_file.txt
red balloons.wav


for i in *; do mv "$i" "`echo "$i" | sed 's/^[^_]*_//'`"; done

Monday, 13 August 2018

Setting JUCE global paths for Jenkins (Windows)



My problem: Jenkins build jobs were failing due to being unable to generate projects form jucer files. JUCE complained that the global paths were incorrect. ROLI user and license details didn't appear to be being saved either.

Solution: Okay the projucer settings on the PC don't get passed over to Jenkins builds, this is because the projucer settings are saved in your user details and Jenkins runs runs jobs as a special kind of user.

To solve this open up Projucer and log in, set up all the global paths you’ll need and save. 
Then copy the following file:
C:\Users\<Username>\AppData\Roaming\Projucer\Projucer.settings

to the location where Jenkins can find and use it:
C:\Windows\System32\config\systemprofile\AppData\Roaming\Projucer\Projucer.settings

AppData is a hidden folder so be sure to turn those on if you cannot see it by going to the View tab in windows explorer and checking the 'Hidden items' checkbox.

If your Jenkins is only using JUCE 5 you're probably good to go, but my Jenkins is building other projects using JUCE 4 and my settings get overwritten and lost every time a JUCE 4 project is built. So I have copied my good settings file to a safe folder in my Documents and copy it over before every JUCE 5 build using this batch command

copy /Y "C:\Users\<Username>\Documents\Projucer5\Projucer.settings" C:\Windows\System32\config\systemprofile\AppData\Roaming\Projucer\Projucer.settings

Now when you use JUCE from Jenkins everything should be fine.

  Azure Trusted Signing Signtool Error SignTool Error: An unexpected internal error has occurred. Error information: "Error: SignerSign...