- Explore tap structure
- Check if the installed formula in the Cellar belongs to appropriate tap while performing migrations
- Metadata for tap formula migrations
- Dependencies on taps
- What if several formulae installed to the same directory
- Skip if multiple taps formulae installed???
- What to do with INSTALL_RECEIPT? The path to the formula is wrong after the migration.
- user and repo
.downcase
(No need) - don't treat tap_formula_renames.rb like a formula
- INSTALL_RECEIPT.json isn't changed after tap migratioins! issue/bug/feature?
- Change INSTALL_RECEIPT after formula renames and migrations
- Update
cmd/migrator
!!! - π₯ What if formula was installed using its path??? Everything that uses
Formulary.from_rack
fails. We haveINSTALL_RECEIPT.json
for each keg and can find path to the formula, maybe it worth doing so? SOLUTION: rescue exceptions inuninstall
everything else behaves same as it was. - π₯ Check everywhere what tap the formula belongs to or add Exception? (Check if installed formula belongs to tap or to core formula) SOLUTION: The same as previous.
- Probably worth adding a test for
brew uninstall <formula>
, where<formula>
doesn't belong to any tap? - ??? Ignore if tap isn't specified???
- if tap is nil, then treat package like a core formula.
- π₯ π₯ π₯ If we install from tap and then it moves to in that tap
brew migrate <formula>
doesn't work, because it can't find the formula among core formulae with oldname. TODO: probably try to search through taps. However,brew migrate user/repo/<formula>
works.
(SOLVED) If multiple formulae from taps with given oldname available, TapFormulaWithOldnameAmbiguityError
is raised.
- π₯ π₯ π₯ Same is true for dependencies on oldname. If something depends on formula from tap and there is no such a formula in among core formulae, then we try to find appropriate formula among taps. However, if the formula in tap is renamed, we won't find it. It's because from_oldname method in Formulary doesn't serach through tap renames.
- rebase onto origin/master
- write script for testing update
- test structure
- MiniTest framework
testing_env.rb
- temporary files e.g. for tests
test_ARGV.rb
Confusing pitfall π₯ (SOLVED)
ln -s /private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs/other
works fine
irb(main):027:0> other
=> #<Pathname:/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs/other>
irb(main):028:0> other.make_relative_symlink Pathname.new "/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5"
=> 0
works fine
irb(main):029:0> other.make_relative_symlink Pathname.new "/private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cella
=> 0
broken
def make_relative_symlink(src)
dirname.mkpath
File.symlink(src.relative_path_from(dirname), self)
end
relative_path_from doesn't accept symlinks. link
β vlad:Homebrew$ cd /private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs
β vlad:PinnedKegs$ readlink other
../../../../../../../../../private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
β vlad:PinnedKegs$ cd /var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs
β vlad:PinnedKegs$ readlink other
../../../../../../../../../private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
β vlad:PinnedKegs$ cd ../../../../../../../../../private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
β vlad:2.5$ cd /private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs
β vlad:PinnedKegs$ pwd
/private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/prefix/Library/PinnedKegs
β vlad:PinnedKegs$ cd ../../../../../../../../../private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
cd: no such file or directory: ../../../../../../../../../private/var/folders/ng/7d7b3z697tq28vn6j28b0hl80000gn/T/homebrew-tests/cellar/oldname/2.5
β vlad:PinnedKegs$
The problem is in relative symlinks, when symlink is passed SOLUTION: in short: can't pass one link with realpath and another without realpath.
-
write script for testing migrate
-
get familiar with existing unit tests
-
unit tests for migrator
-
test keg-only with
otool -L
β vlad:Homebrew$ mv ../Formula/openssl.rb ../Formula/newopenssl.rb
β vlad:Homebrew$ vim ../Formula/newopenssl.rb formula-renames β
β vlad:Homebrew$ vim formula_renames.rb formula-renames β
β vlad:Homebrew$ brew migrate openssl formula-renames β
==> Migrating openssl to newopenssl
Copying to: /usr/local/Cellar/newopenssl
==> Uninstalling and unlinking openssl
==> Linking newopenssl
β vlad:Homebrew$ otool -L ../../Cellar/openssl/1.0.2c/bin/openssl
../../Cellar/openssl/1.0.2c/bin/openssl:
/usr/local/Cellar/openssl/1.0.2c/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/Cellar/openssl/1.0.2c/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
- check uninstall for bugs with
realpath
- script for testing
migrator
- check update/uninstall
- ??? fixing all existing INSTALL_RECEIPT? (can be broken for tap migrations)
- unit tests for formulary (no tests at all)
-
What sequence to use in Dependency#to_formula
- from name
- from oldname
- from tap
- ftom tap oldname
-
Cleanup
- Fix Exceptions for unavailable oldname
-
π₯
brew reinstall
. Example: if coreack
->newack
and we haveack
in some tap, thenbrew reinstall ack
reinstalls ack.(DON'T DO ANYTHING IF Cellar/f.name is a symlink.
? Formula#installed -- says something installed even if it's a symlink. ? Tests for oldname unavailable errors.
- Add Formulary#to_rack and change ARGV#kegs behaviour.
- Remove from_oldname and all stuff depending on it.
Cleanup and test
- Migrate core formula
- Migrate tap formula (canonical/fully-qualified)
β vlad:Homebrew$ brew install libpng formula-renames β
==> Installing libpng from vladshablinsky/homebrew-taptest
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.17.yosemite.bottle
Already downloaded: /Library/Caches/Homebrew/libpng-1.6.17.yosemite.bottle.tar.gz
==> Pouring libpng-1.6.17.yosemite.bottle.tar.gz
πΊ /usr/local/Cellar/libpng/1.6.17: 17 files, 1.2M
β vlad:Homebrew$ brew migrate libpng formula-renames β
Error: No available formula with oldname libpng
π₯ π₯ π₯
- Migrate core formula when the same tap formula exists
- Migrate tap formula when same core one exists
- Migrate tap formula using canonical name
- Migrate tap formula using canonical name, when multiple taps have this formula
- Install formula from path and try to migrate it (MigratorDifferentTapsError is raised)
- Migrate formula, that depends on another
- Migrate library some formula depends on (tested on zint and libpng, itstool and libxml2)
- The same for library formulae
- Dependency on tap oldname
- Dependency on core formula oldname (reinstall zint after renaming libpng)
- Uninstall using oldname (canonical/fully-qualified)
- Uninstall usinga newname (canonical/fully-qualified)
-
libpng -> newlibpng
,libpng
installed -
libpng -> newlibpng
,user/repo/libpng
installed -
user/repo/libpng -> user/repo/newlibpng
,libpng
installed -
user1/repo1/linpng -> user1/repo1/newlibpng
,user/repo/libpng
installed -
libpng -> newlibpng
&user/repo/libpng -> user/repo/newlibpng
,libpng
installed -
libpng -> newlibpng
&user/repo/libpng -> user/repo/newlibpng
,user/repo/libpng
installed -
libpng -> newlibpng
&user/repo/libpng -> user/repo/newlibpng
,user1/repo1/libpng
installed
- Add migrate command.
uninstall
doesn't uninstallname
if Cellar/name is a symlink.uninstall
uninstalls package with its oldname symlinks.update
perform formula migrations and tap formula migrations for renamed formulae.update
changesTab
if formula migrates to a tap.Formula#oldname
returns oldname for formula.Formulary.from_oldname(ref)
returns formula instance for formula with ref as oldname.FormulaWithOldnameUnavailableError < FormulaUnavailableError
exception if no formula with oldname available.TapFormulaWithOldnameUnavailableError < TapFormulaUnavailableError
same for tap formulae.Dependency#to_formula(name)
tries to load formula with that oldname and if it can't, it loads formula with that name- Add
renamed_formulae
toextend/ARGV.rb
to instantiate new formulae from old name. ARGV.kegs
raises NotAKegError if passed name is a symlink.update
skipstap_formula_renames.rb
and doesn't treat it like a formula.- Don't treat
tap_formula_renames.rb
like a formula inTap#formula_files
. - Add
Tap#tap_formula_renames
loadstap_formula_renames.rb
file.
Initial uninstall command was divided into two behaviours: with --force
and without it.
-
brew uninstall --force <formula>
before:
- get ARGV.named
- get canonical name
- get rack directory
- remove each subdir as a keg
- remove pin
-
brew uninstall <formula>
before:
- get ARGV.kegs:
1. get canonical name and rack 2. get rack subdirs 3. init linked_keg_ref, opt_prefix 4. `if opt_prefix.symlink? && opt_prefix.directory?` => keg from opt_prefix.real_path 5. same for `linked_keg_ref` 6. else if number of subdirs is 1, then keg from the subdir. 7. else if prefix for formula tap formula (`Formulary.factory(name)`) or for core formula (`Formulary.from_rack(rack)`) isn't empty, then keg from this prefix 8. else raise `MultipleVersionsInstalledError`
- remove one keg for each given name
brew uninstall [--force] ack
andbrew uninstall [ --force] user/repo/ack
uninstall any installedack
now both with --force and withou it:
- make a formula instance for rack
- remove symlinks for oldname
-
Each tap with renamed formulae has
tap_formula_renames.rb
hasTAP_FORMULA_RENAMES
hash, which store information about renames in the following format:# tap_formula_renames.rb TAP_FORMULA_RENAMES = { "ack" => "newack" }