diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 00:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 00:06:44 +0000 |
commit | 44cf8ec67278bd1ab6c7f83a9993f7a5686a9541 (patch) | |
tree | 5eec4b0d1a3f163d279c3c27c03324ba49fa235a /iphone/bin | |
parent | Initial commit. (diff) | |
download | zbar-44cf8ec67278bd1ab6c7f83a9993f7a5686a9541.tar.xz zbar-44cf8ec67278bd1ab6c7f83a9993f7a5686a9541.zip |
Adding upstream version 0.23.93.upstream/0.23.93upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iphone/bin')
-rwxr-xr-x | iphone/bin/BuildUniversal.sh | 23 | ||||
-rwxr-xr-x | iphone/bin/CreateDMG.sh | 44 | ||||
-rwxr-xr-x | iphone/bin/CreateDSStore.pl | 72 | ||||
-rwxr-xr-x | iphone/bin/Mac/Finder/AliasRecord.pm | 169 |
4 files changed, 308 insertions, 0 deletions
diff --git a/iphone/bin/BuildUniversal.sh b/iphone/bin/BuildUniversal.sh new file mode 100755 index 0000000..658c633 --- /dev/null +++ b/iphone/bin/BuildUniversal.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -ux +SUBTARGET=${1:?} +OUTDIR=${2:-$TARGET_BUILD_DIR} + +# build library for device and simulator +xcodebuild -target $SUBTARGET -configuration $CONFIGURATION -sdk iphoneos BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT\ + || exit 1 +xcodebuild -target $SUBTARGET -configuration $CONFIGURATION -sdk iphonesimulator BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT\ + || exit 1 + +mkdir -p $OUTDIR + +# combine device and simulator libs into single fat lib. +# others have indicated that this approach is "wrong", but for us +# the ease of including the universal lib in a project without complicated +# changes to build settings outweighs any lack of purity in the approach +# ...we can always fix things later, if necessary +lipo -create \ + $BUILD_ROOT/$CONFIGURATION-iphoneos/$SUBTARGET.a \ + $BUILD_ROOT/$CONFIGURATION-iphonesimulator/$SUBTARGET.a \ + -output $OUTDIR/$SUBTARGET.a \ + || exit 1 diff --git a/iphone/bin/CreateDMG.sh b/iphone/bin/CreateDMG.sh new file mode 100755 index 0000000..0290471 --- /dev/null +++ b/iphone/bin/CreateDMG.sh @@ -0,0 +1,44 @@ +#!/bin/sh +set -ux +VOLNAME=${1:?} +shift +RES=$SOURCE_ROOT/res +BUDDY=/usr/libexec/PlistBuddy +if [ ! -x "$BUDDY" ]; then + BUDDY=$(xcrun -find PlistBuddy) \ + || exit 1 +fi +VERSION=$($BUDDY -c 'Print :CFBundleVersion' $RES/$VOLNAME-Info.plist) \ + || exit 1 +DMG=$VOLNAME-$VERSION + +mkdir -p $TARGET_BUILD_DIR/.background \ + || exit 1 +cp -af $RES/$VOLNAME.DS_Store $TARGET_BUILD_DIR/.DS_Store +cp -af $RES/$VOLNAME-bg.png $TARGET_BUILD_DIR/.background/ + +# copy remaining arguments to image directly +for content +do + cp -af $content $TARGET_BUILD_DIR/ \ + || exit 1 +done + +# prepare examples for distribution +for example in $(find $TARGET_BUILD_DIR/Examples -depth 1 -not -name '.*') +do + rm -rf $example/{build,*.xcodeproj/{*.{mode1v3,pbxuser},project.xcworkspace,xcuserdata},ZBarSDK} + cp -af $BUILT_PRODUCTS_DIR/ZBarSDK $example/ +done + +# override subdir .DS_Stores +for dir in $(find $TARGET_BUILD_DIR -type d -depth 1) +do + cp -af $RES/Columns.DS_Store $dir/.DS_Store +done + +hdiutil create -ov -fs HFS+ -format UDZO -imagekey zlib-level=9 \ + -volname $VOLNAME \ + -srcdir $TARGET_BUILD_DIR \ + $BUILT_PRODUCTS_DIR/$DMG.dmg \ + || exit 1 diff --git a/iphone/bin/CreateDSStore.pl b/iphone/bin/CreateDSStore.pl new file mode 100755 index 0000000..e6bc7df --- /dev/null +++ b/iphone/bin/CreateDSStore.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +# Quick hack script to generate the .DS_Store for the DMG, which +# * allows us to precisely position the window and icons +# * is more usefully versioned +# * avoids references to my local HD(!?) + +use warnings; +use strict; + +BEGIN { + use File::Spec::Functions qw(rel2abs splitpath); + use lib (splitpath(rel2abs($0)))[1]; +} + +use Data::Plist::BinaryWriter; +use Mac::Finder::DSStore qw(writeDSDBEntries makeEntries); +use Mac::Finder::AliasRecord; + +$Mac::Finder::DSStore::Entry::types{bwsp} = 'blob'; +$Mac::Finder::DSStore::Entry::types{icvp} = 'blob'; + +writeDSDBEntries($ARGV[0] || "DS_Store", + makeEntries(".", + bwsp => Data::Plist::BinaryWriter->new(serialize => 0)->write([ + dict => { + WindowBounds => [ + string => sprintf('{{%d, %d}, {%d, %d}}', + 512, 128, 512, 608 + 22) + ], + SidebarWidth => [integer => 0], + ShowToolbar => [false => 0], + ShowSidebar => [false => 0], + ShowPathbar => [false => 0], + ShowStatusBar => [false => 0], + } + ]), + icvp => Data::Plist::BinaryWriter->new(serialize => 0)->write([ + dict => { + viewOptionsVersion => [integer => 0], + arrangeBy => [string => "none"], + iconSize => [real => 64], + textSize => [real => 12], + labelOnBottom => [true => 1], + gridSpacing => [real => 100], + gridOffsetX => [real => 0], + gridOffsetY => [real => 0], + showItemInfo => [false => 0], + showIconPreview => [false => 0], + backgroundType => [integer => 2], + backgroundColorRed => [real => 0], + backgroundColorGreen => [real => 0], + backgroundColorBlue => [real => .5], + backgroundImageAlias => [ + data => Mac::Finder::AliasRecord->new( + path => 'ZBarSDK:.background:ZBarSDK-bg.png', + volumeFS => 'HFS+')->write() + ], + }, + ]), + vstl => "icnv", + ), + makeEntries("README", Iloc_xy => [ 4.5 * 32, 2.5 * 32 ]), + makeEntries("ZBarSDK", Iloc_xy => [ 4.5 * 32, 7.5 * 32 ]), + makeEntries("ChangeLog", Iloc_xy => [ 4 * 32, 12.5 * 32 ]), + makeEntries("Documentation.html", + Iloc_xy => [ 8 * 32, 12.5 * 32 ]), + makeEntries("Examples", Iloc_xy => [ 12 * 32, 12.5 * 32 ]), + makeEntries("COPYING", Iloc_xy => [ 4 * 32, 16 * 32 ]), + makeEntries("LICENSE.md", Iloc_xy => [ 8 * 32, 16 * 32 ]), + makeEntries("Documentation",Iloc_xy => [ 12 * 32, 16 * 32 ]), +); diff --git a/iphone/bin/Mac/Finder/AliasRecord.pm b/iphone/bin/Mac/Finder/AliasRecord.pm new file mode 100755 index 0000000..06f68f6 --- /dev/null +++ b/iphone/bin/Mac/Finder/AliasRecord.pm @@ -0,0 +1,169 @@ +package Mac::Finder::AliasRecord; + +# Generate(/Parse) a Mac "alias record" binary string/file. +# +# Currently just enough is implemented to satisfy immediate requirements +# (ie, write backgroundImageAlias to .DS_Store for DMG) +# +# based on these documents: +# http://www.geocities.com/xhelmboyx/quicktime/formats/alias-layout.txt +# http://sebastien.kirche.free.fr/python_stuff/MacOS-aliases.txt +# +# FIXME interface is very poor... + +use warnings; +use strict; +use DateTime; +use File::Spec; +use File::Spec::Mac; +use Encode qw(encode); +require Exporter; + +our $VERSION = '0.1'; +our @ISA = qw(Exporter); + +my %FSEncodings = ( + MacFS => ['RW', ''], + MFS => ['RW', ''], + HFS => ['BD', ''], + 'HFS+' => ['H+', ''], + + AudioCD => ['', 'JH'], + ISO9660 => ['', 'AG'], + FAT => ['', 'IS'], + Joliet => ['', 'Jo'], + 'ISO9660+Joliet' => ['', 'Jo'], +); + +my %DiskEncodings = ( + HD => 0, + FixedHD => 0, + Network => 1, + NetworkDisk => 1, + Floppy => 4, + Floppy1440 => 4, + Other => 5, + OtherDisk => 5, +); + +my %RecordEncodings = ( + parentDir => 0x00, + absolutePath => 0x02, + unicodeFile => 0x0e, + unicodeVolume => 0x0f, + volumePath => 0x12, +); + +sub new { + my $class = shift || __PACKAGE__; + my $self = { + aliasCreator => '', + aliasVersion => 2, + aliasType => 'file', + volume => '', + volumeCreated => 0, + volumeFS => 'HFS', + volumeDisk => undef, + volumeAttrs => 0, + directoryID => 0, + file => '', + fileID => 0, + fileCreated => 0, + fileType => '', + fileCreator => '', + nlvlFrom => -1, + nlvlTo => -1, + records => { }, + @_ + }; + if(exists($self->{path})) { + my $path = $self->{path}; + my ($vol, $dir, $file) = File::Spec::Mac->splitpath($path); + $vol =~ s/:$//; + my @dir = File::Spec::Mac->splitdir($dir); + while(@dir && !$dir[0]) { + shift(@dir); + } + while(@dir && !$dir[-1]) { + pop(@dir); + } + $self->{volume} ||= $vol; + $self->{records}{unicodeVolume} ||= + pack('na*', length($vol), encode('utf-16be', $vol)); + + $self->{file} ||= $file; + $self->{records}{parentDir} ||= $dir[-1] + if(@dir); + $self->{records}{absolutePath} ||= $path; + $self->{records}{volumePath} ||= File::Spec->catfile('', @dir, $file); + $self->{records}{unicodeFile} ||= + pack('na*', length($file), encode('utf-16be', $file)); + } + return(bless($self, ref($class) || $class)); +} + +sub toFSTime { + my $val = shift; + if(ref($val) && $val->isa("DateTime")) { + $val = $val->epoch - DateTime->new(year => 1904)->epoch(); + } + return($val); +} + +sub write { + my ($self, $out) = @_; + + my $aliasType = $self->{aliasType}; + $aliasType = (($aliasType =~ /^d(ir(ectory)?)?$/i && 1) || + ($aliasType !~ /^f(ile)?$/ && $aliasType) || 0); + + my $volumeCreated = toFSTime($self->{volumeCreated}); + my $volumeFS = $self->{volumeFS}; + if(ref($volumeFS) ne 'ARRAY') { + $volumeFS = $FSEncodings{$volumeFS} || ['', '']; + } + + my $volumeDisk = $self->{volumeDisk}; + if(!defined($volumeDisk)) { + if($volumeFS->[0] eq 'H+') { + $volumeDisk = 'Floppy'; + } + elsif($volumeFS->[0]) { + $volumeDisk = 'HD'; + } + else { + $volumeDisk = 'Other'; + } + } + $volumeDisk = (exists($DiskEncodings{$volumeDisk}) + ? $DiskEncodings{$volumeDisk} + : $volumeDisk); + + my $fileCreated = toFSTime($self->{fileCreated}); + + my $buf = + pack('nn (C/a @28)Na2n N(C/a @64)NNa4a4 n!n!Na2 x10 (n!n/ax!2)*', + $self->{aliasVersion}, $aliasType, + $self->{volume}, $volumeCreated, $volumeFS->[0], $volumeDisk, + $self->{directoryID}, $self->{file}, $self->{fileID}, $fileCreated, + $self->{fileType}, $self->{fileCreator}, $self->{nlvlFrom}, + $self->{nlvlTo}, $self->{volumeAttrs}, $volumeFS->[1], + map(((exists($RecordEncodings{$_}) ? $RecordEncodings{$_} : $_) + => $self->{records}{$_}), + keys(%{$self->{records}})), + (-1, '')); + $buf = pack('a4n', $self->{aliasCreator}, length($buf) + 6) . $buf; + + if(!$out) { + return($buf); + } + elsif(ref($out) eq 'GLOB') { + print $out $buf; + } + else { + open(my $outfh, '>', $out) || die; + print $outfh $buf; + } +} + +1; |