Extract from DMG - macos

How to extract content of DMG without mounting it?
I want add autoupdate system to my application. It downloads DMG from website, then extract new version of application from it.

Some .dmg files can be extracted by using 7-zip.
$ 7z x your.dmg
$ ls
your.dmg
0.MBR
1.Primary GPT Header
2.Primary GPT Table
3.free
4.hfs
5.free
6.Backup GPT Table
7.Backup GPT Header
...and after extracted the 4.hfs file:
$ 7z x 4.hfs
...you'll get the content of the .dmg file.
You could also mount the .dmg in Mac OS X using hdiutil command (which is also used by Homebrew Cask).
Please refer to this Ask Ubuntu question for more use cases on Linux.

Dmg is just a format used for MacOS. It's a not compressed file format like zip or tar.gz
You have several choices to mount it. Here are some options.
Double click on it to mount it.
Use hdiutil attach your.dmg to mount the dmg file. After mounting on it,
operating your command line to extract the files you want out.

Doing that is working counter to the design of DMGs, so it's very painful. DMGs are designed to be mounted, that is their whole raison d'ĂȘtre. You would need to rely on experimental code if you wanted to do something like that. You are probably better served by using a non-DMG archive such as a zip file, or by making your automatic updating process download, mount, and unmount the DMG file you provide.

Related

Is it possible to change the Xcode's iOS DeviceSupport default folder location?

I want it to point to an external drive and save some memory on main drive.. please assist.. so far it seems that it's impossible to do so. Only Archive and DerivedData can be configured via Locations preference..
There is no such option. But you can symlink the destination with ln -s command. Something like this:
% ln -s /ExternalDrive/DeviceSupport/ ~/Library/Developer/Xcode/iOS\ DeviceSupport/
So,
Close the Xcode
Move the DeviceSupport directory to the destination where you want to store it
Symlink the new destination
Launch Xcode and check that everything works as expected
PS Check the How to Create Symbolic Links at Command Line of Mac OS X guide if you need more information about linking.

How to zip a folder in MacOS without creating an extra directory inside the zip file

I got a .zip file from my friend and it was compressed under windows, which contains three subfolders inside of it, and when I check the contents of it on my Mac terminal it looks like this:
Now I unzip this file and then zip it through terminal, and when I check the contents of that zip file it becomes like this:
I have googled how to zip on mac without creating a subfolder with same name but none of them solves the problem, my question is how to do the zip on Mac which makes the zip file looks exactly same with the initial one I got.
Thanks very very much
New edit:
I think I might did not do very well to summarize my problem, so the initial folder contains three sub-folders and all of them were created in windows environment and compressed on windows, when I tried to unzip it on my MacOS machine, the unzipped folder looks still good but when I do the compression on Mac and then view the .zip file through unzip -l xxxx.zip, it is giving me 6 files in which the three sub-folders are also treated as files. Based on my knowledge this is because in BSD systems all the folders are treated as files but in windows they are not, what I'm currently doing is to delete all these files that represent folders through "zip -d", which I know is very silly. I would be more than happy to talk about this from an operating system view with anybody who is interested in it. Thanks in advance.
For me this command works fine:
zip -j zippedFolder.zip myFolder/*
To unzip I used
unzip zippedFolder.zip
and I've got only the data from the folder.
Example: The folder I want to zip is on the desktop and he's called testFolder.
Open Terminal
cd /Users/yourUser/Desktop
zip -f myZip.zip testFolder/*

OSX One-step converting from ZIP to DMG via terminal?

Is there an elegant way of converting ZIP files to DMG?
I would avoid to expand the (many) files manually and then to repack'em to a DMG.
Could that be done via terminal, maybe in a single step?
There is an app called DropDMG that lets you convert between file types. The description on the website claims you go from .zip to a dmg file. The app is not free but they have a free trail available that may work for you.
A terminal command that might work is hdiutil.
hdiutil create -format UDZO -srcfolder folder_to_compress archive_name.dmg
I just tried this on a .zip file and it worked. But note that when I launch the .dmg file I just get the .zip file back.
You could also write a two line script. First line is to unzip the zip file and then use the hdiutil command to make a dmg from the expanded files.

How to download 2 files that have same file names but different capital letters to mac?

I have downloaded two files as a zip to my Mac. The file names are:
stack overflow.xml
Stack Overflow.xml
But when I unzip the file (Archive.zip), there's only one file unzipped (stack overflow.xml). How do I fix this issue?
Should I set the Mac system somewhere as case sensitive or something?
Thank you so much!
It should be present. If both the filenames are same then you have (1) at the end of the filename. The file names are case-sensitive. So, there should be no problem with the files you have mentioned. BTW, even if your files have same name, then as I mentioned above it should have (1) at the end of the file name.
Just copy those zip's into a new folder and try to unzip it again.You might be missing something.
P.S: If possible provide the link.
This will work:
Using Disk Utility create a new blank disk image selecting OS X
Extended (Case-sensitive, Journaled) as the format.
Copy your ZIP archive to this disk image.
Unzip.
Rename files which differ only in case.
Copy files to wherever you want them.
Trash the disk image.
[Note: When testing this we found Disk Utility sometimes failed to create a case-sensitive volume. If this happens you can select the disk in Disk Utility, then the Partition tab, and erase the partition again specifying OS X Extended (Case-sensitive, Journaled) as the format.]
HTH

Is it possible to create multiple references to a file on Macintosh?

What I mean is that I want the same file to exist in 2 different locations, so that when I save it in 1 location it updates in the other location. I'm running OSX Yosemite, btw. Is this possible?
If you're looking to have the file on the same computer, a symlink will do the trick:
Fire up terminal
Navigate to the directory you want to have the symlink in cd /path/to/your/file
do ln -s /any/file/on/the/disk linked-file where "linked-file" will be the name of the file you want
If you're looking to have the file on a separate computer or on a network drive, you should probably look into rsync.

Resources