The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,876 other followers

Archive for the ‘Apple’ Category

python – How do I install pip on macOS or OS X? – Stack Overflow

Posted by jpluimers on 2020/03/25

On Mac OS X with stock Python:

All you need to do is

sudo easy_install pip

After this, you might want to upgrade pip:

sudo pip install --upgrade pip

Source: [WayBackpython – How do I install pip on macOS or OS X? – Stack Overflow

You could go the homebrew way, but that means your system will have two Python installations usually causing a nightmare of path dependency orders. In addition, homebrew puts you on the wrong foot, so:

DO NOT DO THIS!

# brew install pip
Error: No available formula with the name "pip" 
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
  https://pip.readthedocs.io/en/stable/installing/

–jeroen

Posted in Apple, Development, Mac OS X / OS X / MacOS, macOS 10.12 Sierra, macOS 10.13 High Sierra, Power User, Python, Scripting, Software Development | Leave a Comment »

macos – Upgrade all the casks installed via Homebrew Cask – Stack Overflow

Posted by jpluimers on 2020/03/23

I missed that this was merged to master a few months ago: [WayBack] macos – Upgrade all the casks installed via Homebrew Cask – Stack Overflow:

December 2017 Update

I thought it would never happen, but there is now finally an official upgrade mechanism for Homebrew Cask (see [WayBack] Issue 3396 for the implementation)! To use it, simply run this command:

brew cask upgrade

However this will not update casks that do not have versioning information (version :latest) or applications that have a built-in upgrade mechanism (auto_updates true). To reinstall these casks (and consequently upgrade them if upgrades are available), run the upgrade command with the --greedy flag like this:

brew cask upgrade --greedy

It means you do not need manual scripts any more. So you can do without this workaround: [WayBack] GitHub – buo/homebrew-cask-upgrade: A command line tool for upgrading every outdated app installed by Homebrew Cask.

More information at [WayBack] homebrew-cask/USAGE.md at master · caskroom/homebrew-cask · GitHub: Updating/Upgrading Casks

–jeroen

Posted in Apple, Home brew / homebrew, Mac OS X / OS X / MacOS, Power User | Leave a Comment »

Mounting a Time Machine backup under Linux so you can send it to Backblaze using Restic…

Posted by jpluimers on 2020/03/16

[WayBack1/WayBack2] Memo to self: Ich will ein Time Machine Backup unter Linux mounten, um das “Latest” Verzeichnis mit Restic an Backblaze senden zu können. Schritt 1: Sp… – Kristian Köhntopp – Google+:

Memo to self: Ich will ein Time Machine Backup unter Linux mounten, um das “Latest” Verzeichnis mit Restic an Backblaze senden zu können.

Schritt 1: Sparsebundle mounten

# ls -l /export/tm_kk/
total 8
drwx—— 3 kris users 4096 Oct 21 16:24 KK.sparsebundle

Geht mit

# git clone git://github.com/torarnv/sparsebundlefs.git
# cd sparsebundlefs; make
# mkdir -p /bundles/tm_kk
# sparsebundlefs /export/tm_kk/KK.sparsebundle /bundles/tm_kk
# ls -lh /bundles/tm_kk
total 0
-r——– 1 root nogroup 1.5T Oct 21 16:24 sparsebundle.dmg

Schritt 2: DMG loopmounten

# fdisk -l /bundles/tm_kk/sparsebundle.dmg
Disk /bundles/tm_kk/sparsebundle.dmg: 1.5 TiB, 1648462135296 bytes, 3219652608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 15FCCBBD-49E4-42BB-B359-EF662F9916CF

Device Start End Sectors Size Type
/bundles/tm_kk/sparsebundle.dmg1 40 409639 409600 200M EFI System
/bundles/tm_kk/sparsebundle.dmg2 409640 3219390423 3218980784 1.5T Apple HFS/HFS+

# kpartx -a -v /bundles/tm_kk/sparsebundle.dmg
add map loop8p1 (253:1): 0 409600 linear 7:8 40
add map loop8p2 (253:19): 0 3218980784 linear 7:8 409640

# mkdir -p /hfs/tm_kk
# mount -o ro -t hfsplus /dev/mapper/loop8p2 /hfs/tm_kk
# b=$(readlink /hfs/tm_kk/Backups.backupdb/KK/Latest)
# ls -l /hfs/tm_kk/Backups.backupdb/KK/$b
total 0
drwxr-xr-x 1 root root 30 Oct 21 14:26 ‘Macintosh HD’

Schritt 3: tmfs mount

Ein Time Machine Backup enthält doofe Hardlinks auf Verzeichnisse. Das kann Linux so nicht, und man muß das noch einmal mit tmfs fusemounten. Seufz.

# apt-get install tmfs
# mkdir -p /tmfs/tm_kk
# tmfs /hfs/tm_kk /tmfs/tm_kk
# ls -l /tmfs/tm_kk/KK/Latest/
total 0
drwxr-xr-x 1 root root 30 Oct 21 14:26 ‘Macintosh HD’

Das durchzulesen ist nicht mal langsam.

Schritt 4: Abbauen

# umount /tmfs/tm_kk
# umount /hfs/tm_kk/
# kpartx -d -v /bundles/tm_kk/sparsebundle.dmg
del devmap : loop8p1
del devmap : loop8p2
loop deleted : /dev/loop8
# umount /bundles/tm_kk

Schritt 5: Den Mist scripten

A few important comments from the WayBack2 link:

Jeroen Wiert Pluimers:

So your time machine data is on a Linux disk that you export from Linux to MacOS? (as otherwise, I don’t understand what /export/tm_kk/KK.sparsebundle is for)

Kristian Köhntopp:

Yes, I am running netatalk, SMB and NFS on an Ubuntu 18.04.

Jeroen Wiert Pluimers:

+Kristian Köhntopp Thanks. What do you envision as steps to restore a complete time machine?

Kristian Köhntopp:

We will see. I do not see that as normally necessary. Mostly I do not want to lose the work on my laptop, and am just to lazy to restrict the backup to that. In general, it should be possible to create this as a writeable setup so that I get the data back. I will probably never recreate a full runnable mac setup from this emergency offsite backup.

Tools used:

–jeroen

Posted in *nix, *nix-tools, Apple, Backup, Mac, Mac OS X / OS X / MacOS, MacBook, Power User | Leave a Comment »

MacOS: Checking a disk for bad blocks

Posted by jpluimers on 2020/03/13

Hardware fails, but most disk tools on MacOS only check logical disk structures, not bad blocks.

Luckily, fsck_hfs can, though Apple is a bit secretive on it: [WayBack] Page Not Found – Apple Developer: ManPages/man8/fsck_hfs.8.html is empty, but there is [WayBack] man page fsck_hfs section 8 and the gist below.

Disk volumes on MacOS use a successor of HFS called HFS Plus – Wikipedia, but the tooling never changed names.

I got at the below parameters through [

This is the disk check command:

# sudo fsck_hfs -dylS /dev/disk3s1
** /dev/rdisk3s1 (NO WRITE)
    Using cacheBlockSize=32K cacheTotalBlock=65536 cacheSize=2097152K.
Scanning entire disk for bad blocks
   Executing fsck_hfs (version hfs-407.50.6).
** Performing live verification.
** Checking Journaled HFS Plus volume.
   The volume name is SanDisk400GB
** Checking extents overflow file.
** Checking catalog file.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume SanDisk400GB appears to be OK.
    CheckHFS returned 0, fsmodified = 0

The italic part is the bad block scanning. The normal part the hfs scanning, which will continue even after finding bad blocks.

If bad blocks are found, output looks more like on the right. If it looks like that, basically you know a disk is toast.

It can be slow, as I did not specify a cache, so it defaults to 32 Kibibyte. You can increase that by adding for instance -c 512m  for 512 Mebibyte cache, just read the short help or man page below.

This tremendously helps checking volumes containing many files, for instance [WayBack] Checking Very Large Time Machine Volumes – Mac OS X Hints

Read the rest of this entry »

Posted in Apple, Mac, Mac OS X / OS X / MacOS, Power User | Leave a Comment »

MacOS: converting a man page to markdown

Posted by jpluimers on 2020/03/09

Converting a man page to markdown is a three step process:

  1. installing a tool that can convert the source of a man page to markdown
  2. finding the location of the man page source
  3. doing the actual conversion

Tool to convert man to markdown

The source format of man pages is troff, which is usually converted by man using groff, or a set of macros.

My initial thought for the first problem was to use pandoc, but as I found earlier in pandoc oneliner from reStructuredText to html, on MacOS, the pandoc can write groff format, but not read it.

Luckily doing a pandoc from groff to markdown – Google Search, I bumped into [WayBack] Convert groff to markdown · Issue #8 · neomutt/neomutt-docs · GitHub which lead to mandoc – Wikipedia.

Since I already had homebrew installed, getting mandoc was simple: brew install mandoc.

Finding the man page source

Earlier in the process when searching for pandoc based conversions, I found the solution for the second problem too: [WayBack] Man page with preserved text decorations, proportional text and fixed-width code – Unix & Linux Stack Exchange taught me about the -w option, but there is actually a -W option that works better if you have multiple pages for a keyword:

-w or --path
Don’t actually display the man pages, but do print the location(s) of the files that would be formatted or displayed. If no argument is given: display (on stdout) the list of directories that is searched by man for man pages. If manpath is a link to man, then “manpath” is equivalent to “man --path“.

-W Like -w, but print file names one per line, without additional information. This is useful in shell commands like man -aW man | xargs ls -l

Actual conversion for fsck_hfs

It all came down to a one-liner:

mandoc -T markdown `man -w fsck_hfs` > /tmp/fsck_hfs.8.md

Note the order here is important this will fail with an error:

mandoc `man -w fsck_hfs` -T markdown > /tmp/fsck_hfs.8.md

mandoc: -T: ERROR: No such file or directory
mandoc: markdown: ERROR: No such file or directory

–jeroen

Read the rest of this entry »

Posted in Apple, Mac, Mac OS X / OS X / MacOS, Power User | Leave a Comment »

 
%d bloggers like this: