I was writing a short shell script this morning and accidentally typed in
#! /bin/bach
and wondered why nothing worked…
Maybe it’s time to switch to the New Adventure Shell?
I was writing a short shell script this morning and accidentally typed in
#! /bin/bach
and wondered why nothing worked…
Maybe it’s time to switch to the New Adventure Shell?
Just a quick rant.
I [censored] hate WordPress’ “I am smarter then stoopid user” attitude, esp attempts to close what it thinks to be HTML tag. #include <foo.h> in between <pre> and </pre> does NOT mean that it needs to change the code to #include <foo .h> (see space?), and add </foo> at the end of the post for me. Aaaaarrggh!
Why the [censored] does software assume that user is stupider then it is? Why isn’t there a way to turn off input sanitization? Case in point with HTML: <p> tag doesn’t need </p> at the end of the paragraph. Never did. And in my world never will. I just want a paragraph break, dammit!!! Same idea with <br> tag. I just want a newline, not <br> to close it off (and WTF is <br> any way?)
Oh, and if I add < s in the body, next time around editing, they get replaced by <s, which upon next save end up tripping Word Press’ input sanitization insanity. Why why oh why?
Aaaaarrgggh! /me bangs head on the wall
We obviously overengineered. Maybe it’s time to EMP every computer on earth and start all over again.
Platform independent endinanness check:
#include <stdio.h> union foo { char p[4]; int k; }; int main() { int j; union foo bar; printf("$Id: endianness.c,v 1.1 2006/07/09 17:48:14 stany Exp stany $nChecks endianness of your platformn"); printf("Bigendian platform (ie Mac OS X PPC) would return "abcd"n"); printf("Littleendian platform (ie Linux x86) would return "dcba"n"); printf("Your platform returned "); bar.k = 0x61626364; for(j=0; j<4 ; j++) { printf("%c",bar.p[j]); } printf("n"); return 0; }
Platform dependent tell me everything check:
/* * $Id: cpuid.c,v 1.2 2002/08/03 23:38:39 stany Exp stany $ */ #include <mach-o/arch.h> #include <stdio.h> const char *byte_order_strings[] = { "Unknown", "Little Endian", "Big Endian", }; int main() { const NXArchInfo *p=NXGetLocalArchInfo(); printf("$Id: cpuid.c,v 1.2 2002/08/03 23:38:39 stany Exp stany $ n"); printf("Identifies Darwin CPU typen"); printf("Name: %sn", p->name); printf("Description: %sn", p->description); printf("ByteOrder: %sn", byte_order_strings[p->byteorder]); printf("CPUtype: %dn", p->cputype); printf("CPUSubtype: %dnn", p->cpusubtype); printf("nFor scary explanation of what CPUSubtype and CPUtype stand for, nlook into /usr/include/mach/machine.hnn ppc750t-tG3nppc7400t-tslower G4nppc7450t-tfaster G4nppc970t-tG5n"); return 0;
Purposefully oblique description, I know.
Basically there are two ways of not supporting a platform.
One way is to not support the architecture. If I compile something as ppc64, noone on a G3 or G4 CPU will be able to run it natively, nor will x86 folks be able to run it under Rosetta. I can try to be cute, and compile something for x86 arch, cutting off all PPC folks. I can compile something optimized for PPC7400 CPU (G4). G5 and G4 systems will run it and G3s will not (This is exactly what Apple did with iMovie and iDVD in iLife ’06). Lastly, I can compile something in one of the “depreciated” formats, potentially for Classic, and cut off x86 folks, and annoy all PPC folks who would now have to start Classic to run my creation. Oh, the choices.
The other way is to restrict things by the configuration, and check during runtime.
Procedure for checking that the architecture you are using is supported by the application.
bash$ cd Example_App.app/Contents/MacOS bash$ file Example_App Example_App: Mach-O fat file with 2 architectures Example_App (for architecture ppc): Mach-O executable ppc Example_App (for architecture i386): Mach-O executable i386
or
bash$ cd Other_Example/Contents/MacOS bash$ file Other_Example Other_Example: header for PowerPC PEF executable
Step 2a) If application is Mach-O, then you can use lipo to see if it’s compiled as a generic or as a platform specific:
bash$ lipo -detailed_info Example_App Fat header in: Example_App fat_magic 0xcafebabe nfat_arch 2 architecture ppc cputype CPU_TYPE_POWERPC cpusubtype CPU_SUBTYPE_POWERPC_ALL offset 4096 size 23388 align 2^12 (4096) architecture i386 cputype CPU_TYPE_I386 cpusubtype CPU_SUBTYPE_I386_ALL offset 28672 size 26976 align 2^12 (4096)
If you see CPU_SUBTYPE_POWERPC_ALL, application is compiled for all PowerPC platforms, from G3 to G5.
What you do not want to see on a G3 or G4 system is:
bash$ lipo -detailed_info Example_App Fat header in: Example_App fat_magic 0xcafebabe nfat_arch 1 architecture ppc64 cputype CPU_TYPE_POWERPC64 cpusubtype CPU_SUBTYPE_POWERPC_ALL offset 28672 size 8488 align 2^12 (4096)
Then you need a 64 bit platform, which amounts to G5 of various speeds.
It is possible that the application is in Mach-o format, but not in fat format.
otool -h -v will decode the mach header, and tell you what cpu is required:
Step 2b) If application is PEF (Preferred Executable Format) or CFM (Code Fragment Manager) things might be harder. I've not yet encountered a CFM or PEF app that would not run on PPC platform in one way or another, so this section needs further expantion. In case of a runtime check, most commonly it is the platform architecture that is checked. Some Apple professional software has something like this in AppleSampleProApp.app/Contents/Info.plist
AELMinimumOSVersion 10.4.4 AELMinimumProKitVersion 576 AELMinimumQuickTimeVersion 7.0.4 ALEPlatform_PPC AELRequiredCPUType G4 CFBundleDevelopmentRegion English
Getting rid of
ALEPlatform_PPC AELRequiredCPUType G4
tends to get the app to run under G3.
Lastly, if application says something similar to “Platform POWERBOOK4,1 Unsupported”, maybe running strings on SampleApplication/Contents/MacOS/SampleApplication combined with grep -i powerbook can reveal something.
bash$ strings SampleApplication | grep POWER POWERBOOK5 POWERBOOK6 - POWERBOOK6,3 POWERMAC7 POWERMAC9,1 POWERMAC3,6 POWERMAC11,2 - POWERMAC11,1
So if you want to run this application on 500Mhz iBook G3 for some reason (hi, dAVE), it might make sense to fire up a hexeditor, and change one of the “allowed” arches to match yours.
For example to this:
bash$ strings SampleApplication | grep POWER POWERBOOK4 POWERBOOK6 - POWERBOOK6,3 POWERMAC7 POWERMAC9,1 POWERMAC3,6 POWERMAC11,2 - POWERMAC11,1
But don’t mind me. I am just rambling.
If you did a clean install of MacOS X 10.4, part of out of box experience is filling out a bunch of things about what your name and address is, where you work, what your e-mail is, etc.
CMD-Q bypasses that screen, and continues as normal without asking for irrelevant information.
Thanks to Jon Rentzsch for the hint.
Spent a good chunk of today fighting with DVD creation. My previous attempt was using iMovie HD 6 and iDVD 6. Now, I have some issues with iDVD:
Suppose your projects are saved on an external drive, both iMovie and iDVD. You’d think that when you are rendeering the final DVD, it would still keep all the bits and pieces on the external drive, where the data is saved. Oh, no. iDVD is different. iDVD is smarter then the user, and will try to save the intermediate audio track (before the muxing) in /tmp If you have PCM audio track (and all of my previous projects did, because I didn’t know any better. Me Ogg. Ogg stoopid, remember?). Now, imagine that you are running out of disk space on your internal drive as it is, and then out of nowhere another 1.5 – 2 gigs of stuff show up in /tmp. Of course iDVD would die at this point.
iDVD 6 is also temperamental about DVD mastering, and was refusing to even think about creating a dual layer DVD (ie something longer then 4.7 gigs in size) if I didn’t have a dual layer burner plugged into the iBook. Fiar enough, I gave it the drive.
Then after running all night, it would die with a numerical error code (I’ve googled for it, noone saw it before). I tried three times, as originally I thought that I might have exceeded the “TV safe” area on the menu (another famous was of getting iDVD to die) with DVD title, or somesuch. But no, it just wouldn’t work.
So I got access to a machine with Final Cut Studio installed on it.
Oh, what a joy.
Software actuallly uses the location you tell it to use, without arbitrarily using what it should not. Software tells you what it thinks you should do, but lets you overrule it if you think you know better. Sane software.
I’ve plugged in my external hard drive, and imported into DVD Studio Pro DV streams which I used in iMovie and iDVD without much success before. It happily dealt with them.
Quickly I created a timeline. I’ve had everything pretty much pre-rendered, so it was as simple as setting a bunch of chapter breaks, creating a menu and linking the buttons to actions (ie Play chapter 1).
System I was using is an elderly G4 1.5 Ghz which was kind of skipping frames when dealing with large streams, and thus creating chapters was a bit of an excercise in patience. I’ve opened the iMovie project, and looked at places where I’ve placed chapter breaks before. In DVD studio I’ve created a bunch of chapter breaks arbitrarily, and then adjusted the times, so they would match more or less what I had in iMovie.
Worked as it was supposed to. Beautiful.
DVD Studio was telling me that my project would compress down to 5.1 gigs. At this point I thought that I should just do it, and then run it through DVD2OneX or somesuch, and shrink it down to 4.7 gigs, and told it to go ahead and just do it. It happily rendered to hard drive (it also asked me where I want to set layer breaks in dual layer disk, which was really nice too).
Eventually I realized that there is such a thing as Compressor, that can take a component of a multiplexed stream, and convert it to a different format.
After taking two 12 gig DV streams, and running them through Compressor, I’ve converted the audio tracks on both streams from PCM audio to Dolby 2.0 AC3.
Once I’ve imported the AC3 streams into DVD Studio Pro project, deleted the PCM audio from the timeline, and added in ac3 audio, projected project size dropped from 5.1 gigs to 4.1 gigs, and actual project size (once assets were rendered) dropped from 4.9 gigs to 3.6 gigs (I’ve used crappy video as DV source, from video tapes that were sitting in storage for god knows how long, so they compressed a fair bit).
So overall, I am really really happy with DVD Studio, although I’ve not used even 1/10’s of it’s capabilities. It can create HD DVDs. It can embed web links in mpeg files. It can edit existing menus. Now I need to save up my shekels to buy it (899 CAD for student license for Final Cut Studio).