Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#64083 closed submission (fixed)

New port -- m2vrequantiser

Reported by: RobK88 Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc:
Port: m2vrequantiser

Description (last modified by RobK88)

In the past, I often used "tcquant" to requantize MPEG-2 video streams. "tcquant" was part of the transcode port but is now considered obsolete and is no longer found in recent versions of transcode.

I found a replacement -- m2vrequantiser. It does not compile on modern C compiler. I needed to apply patches from Debian plus an additional typedef patch which I created to address types used in the program that do not exist in most modern C compilers. I also needed to patch the Makefile to make Macports work properly.

Attached please find the portfile and the four patch files.

The port does build fine and the resulting binary M2VRequantizer runs fine.

There is ONE big problem with he portfile. The portfile downloads a second file containing the manpage and fails at the extraction stage. The second file is compressed with xz whereas the main source file is compressed with gz.

How do you deal with this situation? I tried using tags (e.g. "use_xz yes:tagtwo") but that did not work.

Please note that the name of the binary and the worksrcdir uses both upper and lower case characters. As a result, I could not use ${name} in many places in the portfile since I used only lowercase letters for the portname (just like Debian did).

P.S. This is my second portfile so any feedback and encouragement would be appreciated!

Attachments (9)

Portfile (2.3 KB) - added by RobK88 3 years ago.
portfile with bug
1001-makefile.patch (1.0 KB) - added by RobK88 3 years ago.
First Patch
1002-argc_sigsegv.patch (422 bytes) - added by RobK88 3 years ago.
Second Patch
1003-makefile.patch (426 bytes) - added by RobK88 3 years ago.
Third Patch
1004-typedef.patch (1.3 KB) - added by RobK88 3 years ago.
Fourth Patch
Portfile.2 (2.5 KB) - added by RobK88 3 years ago.
Working Portfile
1003-typedef.patch (1.3 KB) - added by RobK88 3 years ago.
Renumbered Patch File -- Needed for working Portfile
m2vrequantiser.zip (6.4 KB) - added by RobK88 3 years ago.
Updated Portfile along with all the Patch files
Portfile-ryandesign (2.0 KB) - added by ryandesign (Ryan Carsten Schmidt) 3 years ago.

Download all attachments as: .zip

Change History (26)

Changed 3 years ago by RobK88

Attachment: Portfile added

portfile with bug

Changed 3 years ago by RobK88

Attachment: 1001-makefile.patch added

First Patch

Changed 3 years ago by RobK88

Attachment: 1002-argc_sigsegv.patch added

Second Patch

Changed 3 years ago by RobK88

Attachment: 1003-makefile.patch added

Third Patch

Changed 3 years ago by RobK88

Attachment: 1004-typedef.patch added

Fourth Patch

comment:1 Changed 3 years ago by RobK88

Description: modified (diff)

comment:2 in reply to:  description Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to RobK88:

There is ONE big problem with he portfile. The portfile downloads a second file containing the manpage and fails at the extraction stage. The second file is compressed with xz whereas the main source file is compressed with gz.

How do you deal with this situation? I tried using tags (e.g. "use_xz yes:tagtwo") but that did not work.

Although I would love to add this feature in the future and have some ideas about how to do it, unfortunately MacPorts doesn't currently support automatically extracting multiple distfiles when they need different extraction commands. But you can let MacPorts automatically extract one of the files, and do the other one manually.

For example, let MacPorts extract the tar.xz file and do the tar.gz file yourself: (This code is untested)

use_xz yes

extract.only ${name}_${version}-5.debian.tar.xz

post-extract {
    system -W ${workpath} "tar -xzf [shellescape ${distpath}/${name}_${version}.orig.tar.gz]"
}

The homepage appears to be wrong... shouldn't it be https://launchpad.net/m2vrequantiser?

Instead of downloading Debian's repackaged .orig.tar.gz file, could we download the original file from the developer's launchpad?

Last edited 3 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 in reply to:  description Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to RobK88:

I also needed to patch the Makefile to make Macports work properly.

Could you elaborate?

The first makefile patch, from Debian I guess, looks fine: it ensures that the Makefile doesn't overwrite CFLAGS that might be specified. It specifies optimization flags only if the user didn't specify CFLAGS, on the assumption that if the user is specifying CFLAGS they are including optimization flags.

But your second makefile patch appears to remove -funroll-loops -frename-registers if CFLAGS are specified by the user, and I don't understand why.

comment:4 Changed 3 years ago by RobK88

Thanks Ryan. I will update the portfile and manually extract the main source file.

And yes, https://launchpad.net/m2vrequantiser looks like the main developer's website. My first portfile (not uploaded here) downloaded the source from this website. I will revert to using it.

And yes, the second Makfile patch file is really not needed. I was playing around with the flags and uploaded the wrong patch file. To make things easier, I will drop it and just use the Makefile patch file from debian.

P.S. The two debian patch file are also in the second download but I didin't bother trying to use them after extraction. One would also need to change -p0 to -p1 etc.

I will update the portfile etc and post it when I get a chance.

Last edited 3 years ago by RobK88 (previous) (diff)

comment:5 Changed 3 years ago by RobK88

Ryan -- I first tried your suggested approach of letting Macports extract the tar.xz file and then manually extracting the tar.gz. Unfortunately, that did not work. Macports insisted in creating a symlink between the worksrcdir and the extracted directory (from the xz archive). Then when I tried to manually extract the tar.gz file into the worksrcdir, Macports rightfully complained -- "M2VRequantiser-v1.1/LICENSE.txt: Cannot extract through symlink M2VRequantiser-v1.1" etc. The "use_xz yes" keyword appears to do something strange.

In any event, I was able to get the two files extracted properly by letting Macports extract the tar.gz file and manually extracting the tar.xz file. I avoided using the "use_xz yes" keyword. To ensure that the two files were properly extracted, I added "depends_extract port:gnutar port:xz".

Attached please find an updated portfile that works and an renamed patchfile. (I fixed the numbering of the patchfiles after I deleted the second Makefile.patch file). Only three patch files are needed now.

As per your request, I changed the homepage and directed Macports to download the main source file from the developers website. I had to add a second master_site to master_sites and had to use tags! Finally, I get to use tags!

It all works just fine now:

bash-3.2$ port lint --nitpick m2vrequantiser
--->  Verifying Portfile for m2vrequantiser
--->  0 errors and 0 warnings found.
bash-3.2$ 
bash-3.2$ port info  m2vrequantiser
m2vrequantiser @1.1 (multimedia)
Variants:             universal

Description:          M2VRequantiser accepts the raw MPEG2 video data (not VOB) from the standard input and writes the recompressed frames to the standard output. M2VRequantiser represents a good replacement for
                      tcrequant, an obsolete utility provided by some versions of the transcode suite.
Homepage:             https://launchpad.net/m2vrequantiser

Extract Dependencies: gnutar, xz
Platforms:            darwin
License:              GPL-2+
Maintainers:          Email: amtor@hotmail.com, GitHub: RobK88
                      Policy: openmaintainer
bash-3.2$ 
bash-3.2$ sudo port -v install m2vrequantiser
--->  Computing dependencies for m2vrequantiser.
--->  Fetching distfiles for m2vrequantiser
--->  Verifying checksums for m2vrequantiser
--->  Checksumming M2VRequantiser-v1.1.tar.gz
--->  Checksumming m2vrequantiser_1.1-5.debian.tar.xz
--->  Extracting m2vrequantiser
--->  Extracting M2VRequantiser-v1.1.tar.gz
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/m2vrequantiser/M2VRequantiser-v1.1.tar.gz' | /usr/bin/gnutar --no-same-owner -xf - 
--->  Extracting m2vrequantiser_1.1-5.debian.tar.xz
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/m2vrequantiser/m2vrequantiser_1.1-5.debian.tar.xz' | /usr/bin/gnutar --no-same-owner -xf - 

gzip: /opt/local/var/macports/distfiles/m2vrequantiser/m2vrequantiser_1.1-5.debian.tar.xz: not in gzip format
--->  Applying patches to m2vrequantiser
--->  Applying 1001-makefile.patch
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1" && /usr/bin/patch -p0 < '/Users/grinch/Macports/ports/multimedia/m2vrequantiser/files/1001-makefile.patch'
patching file Makefile
--->  Applying 1002-argc_sigsegv.patch
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1" && /usr/bin/patch -p0 < '/Users/grinch/Macports/ports/multimedia/m2vrequantiser/files/1002-argc_sigsegv.patch'
patching file main.c
--->  Applying 1003-typedef.patch
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1" && /usr/bin/patch -p0 < '/Users/grinch/Macports/ports/multimedia/m2vrequantiser/files/1003-typedef.patch'
patching file main.c
--->  Configuring m2vrequantiser
--->  Building m2vrequantiser
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc/usr
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc/usr/bin
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cxx
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cxx/usr
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cxx/usr/bin
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objc
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objc/usr
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objc/usr/bin
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objcxx
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objcxx/usr
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objcxx/usr/bin
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1" && /usr/bin/make -j4 -w all CC="/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc/usr/bin/clang" CXX="/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cxx/usr/bin/clang++" OBJC="/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objc/usr/bin/clang" OBJCXX="/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/objcxx/usr/bin/clang++" INSTALL="/usr/bin/install -c" 
make: Entering directory `/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1'
/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc/usr/bin/clang -I/opt/local/include -Os -arch x86_64 -funroll-loops -frename-registers -D_LARGEFILE_SOURCE -DLARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -Wall -c main.c
clang: warning: argument unused during compilation: '-frename-registers'
/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/compwrap/cc/usr/bin/clang -Os -arch x86_64 -funroll-loops -frename-registers -D_LARGEFILE_SOURCE -DLARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_REENTRANT -Wall main.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -s -lm -o M2VRequantiser
ld: warning: option -s is obsolete and being ignored
make: Leaving directory `/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1'
--->  Staging m2vrequantiser into destroot
. changed
	gid expected 0 found 80 modified
./usr missing (created)
. missing (directory not created: File exists)
./Applications missing (created)
./Developer missing (created)
./Library missing (created)
. changed
	gid expected 80 found 0 modified
./bin missing (created)
./etc missing (created)
./include missing (created)
./lib missing (created)
./lib/pkgconfig missing (created)
./libexec missing (created)
./sbin missing (created)
./share missing (created)
./share/doc missing (created)
./share/info missing (created)
./share/man missing (created)
./share/man/cat1 missing (created)
./share/man/cat2 missing (created)
./share/man/cat3 missing (created)
./share/man/cat4 missing (created)
./share/man/cat5 missing (created)
./share/man/cat6 missing (created)
./share/man/cat7 missing (created)
./share/man/cat8 missing (created)
./share/man/cat9 missing (created)
./share/man/catl missing (created)
./share/man/catn missing (created)
./share/man/man1 missing (created)
./share/man/man2 missing (created)
./share/man/man3 missing (created)
./share/man/man4 missing (created)
./share/man/man5 missing (created)
./share/man/man6 missing (created)
./share/man/man7 missing (created)
./share/man/man8 missing (created)
./share/man/man9 missing (created)
./share/man/manl missing (created)
./share/man/mann missing (created)
./share/nls missing (created)
./share/nls/C missing (created)
./share/nls/af_ZA.ISO8859-1 missing (created)
./share/nls/af_ZA.ISO8859-15 missing (created)
./share/nls/bg_BG.CP1251 missing (created)
./share/nls/cs_CZ.ISO8859-2 missing (created)
./share/nls/da_DK.ISO8859-1 missing (created)
./share/nls/da_DK.ISO8859-15 missing (created)
./share/nls/de_AT.ISO8859-1 missing (created)
./share/nls/de_AT.ISO8859-15 missing (created)
./share/nls/de_CH.ISO8859-1 missing (created)
./share/nls/de_CH.ISO8859-15 missing (created)
./share/nls/de_DE.ISO8859-1 missing (created)
./share/nls/de_DE.ISO8859-15 missing (created)
./share/nls/el_GR.ISO8859-7 missing (created)
./share/nls/en_AU.ISO8859-1 missing (created)
./share/nls/en_AU.ISO8859-15 missing (created)
./share/nls/en_AU.US-ASCII missing (created)
./share/nls/en_CA.ISO8859-1 missing (created)
./share/nls/en_CA.ISO8859-15 missing (created)
./share/nls/en_CA.US-ASCII missing (created)
./share/nls/en_GB.ISO8859-1 missing (created)
./share/nls/en_GB.ISO8859-15 missing (created)
./share/nls/en_GB.US-ASCII missing (created)
./share/nls/en_NZ.ISO8859-1 missing (created)
./share/nls/en_NZ.ISO8859-15 missing (created)
./share/nls/en_NZ.US-ASCII missing (created)
./share/nls/en_US.ISO8859-1 missing (created)
./share/nls/en_US.ISO8859-15 missing (created)
./share/nls/es_ES.ISO8859-1 missing (created)
./share/nls/es_ES.ISO8859-15 missing (created)
./share/nls/et_EE.ISO8859-15 missing (created)
./share/nls/fi_FI.ISO8859-1 missing (created)
./share/nls/fi_FI.ISO8859-15 missing (created)
./share/nls/fr_BE.ISO8859-1 missing (created)
./share/nls/fr_BE.ISO8859-15 missing (created)
./share/nls/fr_CA.ISO8859-1 missing (created)
./share/nls/fr_CA.ISO8859-15 missing (created)
./share/nls/fr_CH.ISO8859-1 missing (created)
./share/nls/fr_CH.ISO8859-15 missing (created)
./share/nls/fr_FR.ISO8859-1 missing (created)
./share/nls/fr_FR.ISO8859-15 missing (created)
./share/nls/hi_IN.ISCII-DEV missing (created)
./share/nls/hr_HR.ISO8859-2 missing (created)
./share/nls/hu_HU.ISO8859-2 missing (created)
./share/nls/is_IS.ISO8859-1 missing (created)
./share/nls/is_IS.ISO8859-15 missing (created)
./share/nls/it_CH.ISO8859-1 missing (created)
./share/nls/it_CH.ISO8859-15 missing (created)
./share/nls/it_IT.ISO8859-1 missing (created)
./share/nls/it_IT.ISO8859-15 missing (created)
./share/nls/ja_JP.SJIS missing (created)
./share/nls/ja_JP.eucJP missing (created)
./share/nls/ko_KR.eucKR missing (created)
./share/nls/la_LN.ISO8859-1 missing (created)
./share/nls/la_LN.ISO8859-15 missing (created)
./share/nls/la_LN.ISO8859-2 missing (created)
./share/nls/la_LN.ISO8859-4 missing (created)
./share/nls/la_LN.US-ASCII missing (created)
./share/nls/lt_LT.ISO8859-4 missing (created)
./share/nls/nl_BE.ISO8859-1 missing (created)
./share/nls/nl_BE.ISO8859-15 missing (created)
./share/nls/nl_NL.ISO8859-1 missing (created)
./share/nls/nl_NL.ISO8859-15 missing (created)
./share/nls/no_NO.ISO8859-1 missing (created)
./share/nls/no_NO.ISO8859-15 missing (created)
./share/nls/pl_PL.ISO8859-2 missing (created)
./share/nls/pt_BR.ISO8859-1 missing (created)
./share/nls/pt_PT.ISO8859-1 missing (created)
./share/nls/pt_PT.ISO8859-15 missing (created)
./share/nls/ro_RO.ISO8859-2 missing (created)
./share/nls/ru_RU.CP866 missing (created)
./share/nls/ru_RU.ISO8859-5 missing (created)
./share/nls/ru_RU.KOI8-R missing (created)
./share/nls/sk_SK.ISO8859-2 missing (created)
./share/nls/sl_SI.ISO8859-2 missing (created)
./share/nls/sv_SE.ISO8859-1 missing (created)
./share/nls/sv_SE.ISO8859-15 missing (created)
./share/nls/tr_TR.ISO8859-9 missing (created)
./share/nls/uk_UA.ISO8859-5 missing (created)
./share/nls/uk_UA.KOI8-U missing (created)
./share/nls/zh_CN.eucCN missing (created)
./share/nls/zh_TW.Big5 missing (created)
./share/skel missing (created)
./var missing (created)
./var/cache missing (created)
./var/db missing (created)
./var/log missing (created)
./var/run missing (created)
./var/spool missing (created)
./www missing (created)
xinstall: /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1/M2VRequantiser -> /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/destroot/opt/local/bin/M2VRequantiser
xinstall: /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/debian/manpage/m2vrequantiser.1 -> /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/destroot/opt/local/share/man/man1/m2vrequantiser.1
xinstall: mkdir /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/destroot/opt/local/share/doc/m2vrequantiser
xinstall: /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/M2VRequantiser-v1.1/README.txt -> /opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/destroot/opt/local/share/doc/m2vrequantiser/README.txt
--->  Compressing man pages for m2vrequantiser
man1/m2vrequantiser.1:	 54.4% -- replaced with man1/m2vrequantiser.1.gz
man1/m2vrequantiser.1.gz: changing permissions from 00755 to 00444
--->  Installing m2vrequantiser @1.1_0
Executing:  cd "/opt/local/var/macports/build/_Users_grinch_Macports_ports_multimedia_m2vrequantiser/m2vrequantiser/work/destroot" && /usr/bin/tar -cvf - . | /usr/bin/bzip2 -c9 > /opt/local/var/macports/software/m2vrequantiser/m2vrequantiser-1.1_0.darwin_11.x86_64.tbz2 
a .
a ./+COMMENT
a ./+CONTENTS
a ./+DESC
a ./+PORTFILE
a ./+STATE
a ./opt
a ./opt/local
a ./opt/local/bin
a ./opt/local/share
a ./opt/local/share/doc
a ./opt/local/share/man
a ./opt/local/share/man/man1
a ./opt/local/share/man/man1/m2vrequantiser.1.gz
a ./opt/local/share/doc/m2vrequantiser
a ./opt/local/share/doc/m2vrequantiser/README.txt
a ./opt/local/bin/M2VRequantiser
--->  Activating m2vrequantiser @1.1_0
x ./
x ./+COMMENT
x ./+CONTENTS
x ./+DESC
x ./+PORTFILE
x ./+STATE
x ./opt/
x ./opt/local/
x ./opt/local/bin/
x ./opt/local/share/
x ./opt/local/share/doc/
x ./opt/local/share/man/
x ./opt/local/share/man/man1/
x ./opt/local/share/man/man1/m2vrequantiser.1.gz
x ./opt/local/share/doc/m2vrequantiser/
x ./opt/local/share/doc/m2vrequantiser/README.txt
x ./opt/local/bin/M2VRequantiser
--->  Cleaning m2vrequantiser
--->  Removing work directory for m2vrequantiser
--->  Scanning binaries for linking errors
--->  No broken files found.                             
--->  No broken ports found.
bash-3.2$ 
bash-3.2$ M2VRequantiser

Usage is :
	M2VRequantiser recompression_factor inputM2Vsize

bash-3.2$
Last edited 3 years ago by RobK88 (previous) (diff)

Changed 3 years ago by RobK88

Attachment: Portfile.2 added

Working Portfile

Changed 3 years ago by RobK88

Attachment: 1003-typedef.patch added

Renumbered Patch File -- Needed for working Portfile

comment:6 Changed 3 years ago by RobK88

I built the port with the +universal variant. The port was built without an error but it does not look like a universal binary. In Macports, does universal mean a PPC/Intel binary? Or 32-bit/64-bit Intel binary?

Please note that the Makefile has "CC = gcc". Perhaps, it need too be changed to "CC ?= gcc".

bash-3.2$ sudo port install M2VRequantiser +universal
--->  Computing dependencies for m2vrequantiser
--->  Fetching distfiles for m2vrequantiser
--->  Verifying checksums for m2vrequantiser
--->  Extracting m2vrequantiser
--->  Applying patches to m2vrequantiser
--->  Configuring m2vrequantiser
--->  Building m2vrequantiser
--->  Staging m2vrequantiser into destroot               
--->  Installing m2vrequantiser @1.1_0+universal
--->  Activating m2vrequantiser @1.1_0+universal
--->  Cleaning m2vrequantiser
--->  Scanning binaries for linking errors
--->  No broken files found.                             
--->  No broken ports found.

bash-3.2$ otool -L /opt/local/bin/M2VRequantiser
/opt/local/bin/M2VRequantiser:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

P.S. I changed the long description for the port. I will attach an updated portfile.

Last edited 3 years ago by RobK88 (previous) (diff)

comment:7 Changed 3 years ago by RobK88

Please ignore my last post. With the +universal variant, Macports is building a 32-bit/64-bit Intel binary. But one must use the "file" command on the binary to verify this.

So the proposed port is working as expected. But I am still wondering if it is a good idea to change "CC = gcc" to "CC ?= gcc" in the Makefile via an additional patch.

bash-3.2$ m2vrequantiser

Usage is :
	m2vrequantiser recompression_factor inputM2Vsize

bash-3.2$
bash-3.2$ otool -L /opt/local/bin/m2vrequantiser
/opt/local/bin/m2vrequantiser:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
bash-3.2$
bash-3.2$ file /opt/local/bin/m2vrequantiser
/opt/local/bin/m2vrequantiser: Mach-O universal binary with 2 architectures
/opt/local/bin/m2vrequantiser (for architecture x86_64):	Mach-O 64-bit executable x86_64
/opt/local/bin/m2vrequantiser (for architecture i386):	Mach-O executable i386
Last edited 3 years ago by RobK88 (previous) (diff)

Changed 3 years ago by RobK88

Attachment: m2vrequantiser.zip added

Updated Portfile along with all the Patch files

comment:8 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Status: newaccepted

"Universal" in MacPorts means multiple architectures. Which specific architectures depends on the universal_archs setting in macports.conf. The default value of that setting varies by OS version.

use_xz yes doesn't do anything strange. It sets the extract.suffix to .tar.xz, changes extract.cmd to xz, and adds the xz extract dependency.

MacPorts base does as of recently contain code that automatically creates a symlink to your source directory, to assist you if you have neglected to set worksrcdir correctly. I do not recall how this code is intended to behave if you have multiple distfiles. (If you have just one distfile that extracts to just one directory, then it's obvious what the symlink should point to, otherwise it's not so obvious.)

The Portfile doesn't work for me. It fails to download the debian file.

Is the debian file still needed at all? Your latest zip file has a files directory containing three patchfiles which is all that the Portfile references. Isn't that all we need? It seems to build fine if I remove the debian distfile stuff.

If we were using the second distfile, then you should have listed extract.only, specifying which distfile MacPorts should extract, but since I don't think we need the second distfile it's moot.

Yes, the Makefile should probably set CC only if the user hasn't already set it as an environment variable. You should suggest that to the developer. In MacPorts when using the makefile 1.0 portgroup it doesn't matter since the makefile 1.0 portgroup specifies CC as an argument (which overrides variables set by the Makefile) rather than as an environment variable (which would be overridden by the Makefile).

Yes, you can verify whether a file is universal by using file, or lipo -info.

...Oh I see, in the destroot phase you install a manpage which comes from the debian distfile. Is that the only thing from the debian distfile that we need? If so, let's just put it in the files directory too. (By the way, manpages don't need to be installed with the execute bit.)

I'll attach my new proposed Portfile.

Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: Portfile-ryandesign added

comment:9 Changed 3 years ago by RobK88

Thanks Ryan. The terminology for fat or universal binaries can be confusing because it can mean different things. Sometimes it means PPC/i386 and sometimes it means i386/x64. But I believe Apple called PPC/i386 binaries "fat" binaries and 1386/x64 binaries "universal" binaries. And I do not know what Apple now calls x86/ARM-Silicon binaries.

That is strange. I was able to download the second file from the debian site using the proposed portfile.

And yes, the only thing needed from the second distfile is the man page. You proposed solution to just copy the man page to the files/ directory makes a lot of sense and will make the portfile a lot easier to read and maintain!

I just discovered lipo --info. When determining whether a binary is fat or universal, lipo --info appears to be more useful than file.

And thank you for your suggestion that I should have used extract.only to extract the second file. But I doubt that would worked because the two files downloaded used two different compression schemes (gz vs.xz). As you noted, Macports does not handle this situation very well. In future releases of Macports, the developers should consider using tags to handle this. (e.g. use_xz yes:tagtwo).

Your proposed portfile looks just fine! Thanks for all your work and feedback. It is greatly appreciated!

P.S. I am also working on a portfile for the sister companion CLI application -- m2vdownsizer. The commercial app DVDRemaster gave the user the choice of using either M2VRequantiser or M2VDownsizer to shrink DVD's from DVD9 to DVD5. Both were released under the GPL because some of the code used (including mpeg2dec) was also GPL'd. Isn't the GPL wonderful!

M2VDownsizer re-encodes the mpeg-2 video files (instead of transcoding) which is a lot slower but yields better quality after the compression. The source code for M2VDownsizer was very hard to find. But I was able to download it from the original developer's website for DVDRemaster using the internet archive. (The developer for DVDRemaster is no longer around).

I suspect it would be easier (for the portfile) that I set up a Githiub repo for the M2VDownsizer source. I have patched the source code and cleaned it up a bit so it will run on 64-bit Macs. (The original source code was written for PPC/x86 fat binaries in mind).

Unfortunately, it was set up as an xcode project. I suspect that will make the portfile a little tricky (since I do not know how to change different compiler flags for different architectures in a xcode project portfile. Different flags are needed if one want to compile the source for a PPC Mac. Or maybe I should abandon PPC support). I will see if I can create a Makefile instead.

When I am further along, I will open a new ticket for the M2VDownsizer portfile.

comment:10 in reply to:  9 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to RobK88:

Thanks Ryan. The terminology for fat or universal binaries can be confusing because it can mean different things. Sometimes it means PPC/i386 and sometimes it means i386/x64. But I believe Apple called PPC/i386 binaries "fat" binaries and 1386/x64 binaries "universal" binaries. And I do not know what Apple now calls x86/ARM-Silicon binaries.

"Fat binary" refers to a classic Mac OS executable containing both PowerPC and 68K code. "Universal binary" refers to a Mach-O binary or library having multiple architectures. Originally that was ppc and i386, though you could also see 3- or 4-way universal binaries also having ppc7400 (G4) or ppc64 (G5) code. Once Intel Macs appeared, x86_64 started being added, and ppc64 started disappearing since Rosetta didn't support ppc64. Once Rosetta disappeared, universal binaries were just x86_64 i386. Now that macOS no longer supports i386 and arm64 exists, universal is x86_64 arm64. I've seen Apple refer to this combination as "universal 2" just as they now refer to the x86_64-on-arm64 emulator as "Rosetta 2".

That is strange. I was able to download the second file from the debian site using the proposed portfile.

--->  Fetching distfiles for m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from https://distfiles.macports.org/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.us.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.is.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.uk.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.fr.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.ie.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.nl.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.bg.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.es.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.ee.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.sk.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.si.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.cl.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp2.de.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.de.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.no.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.pl.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.it.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.ru.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.cz.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.se.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.fi.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.hr.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.hk.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.wa.au.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.au.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.hu.debian.org/debian/pool/main/d/m2vrequantiser
--->  Attempting to fetch m2vrequantiser_1.1-5.debian.tar.xz from http://ftp.jp.debian.org/debian/pool/main/d/m2vrequantiser
Error: Failed to fetch m2vrequantiser: The requested URL returned error: 404 Not Found

But I found the file elsewhere and will fix up the port and commit it.

And thank you for your suggestion that I should have used extract.only to extract the second file. But I doubt that would worked because the two files downloaded used two different compression schemes (gz vs.xz). As you noted, Macports does not handle this situation very well.

If you do not use extract.only to specify which of the distfiles to extract, MacPorts will try to extract all distfiles using the same method. On OS X 10.9 and later, it just so happens that Apple enhanced the tar command to accept gzip, bzip2, and xz input without the user needing to specify which it is, so this will work by coincidence. However, MacPorts was designed prior to OS X 10.9, and on OS X 10.8 and earlier, you must use the correct command for each compression format, otherwise the port will fail with an error at extract time.

In future releases of Macports, the developers should consider using tags to handle this. (e.g. use_xz yes:tagtwo).

I do not plan to do it that way; instead, I plan to have the extract phase automatically recognize the compression format of each distfile (possibly by using the file command to analyze the distfile's contents, or just by looking at its filename extension) and use the correct decompression command. #50969 is not exactly the ticket for this issue but is related.

M2VDownsizer re-encodes the mpeg-2 video files (instead of transcoding) which is a lot slower but yields better quality after the compression. The source code for M2VDownsizer was very hard to find. But I was able to download it from the original developer's website for DVDRemaster using the internet archive. (The developer for DVDRemaster is no longer around).

I suspect it would be easier (for the portfile) that I set up a Githiub repo for the M2VDownsizer source. I have patched the source code and cleaned it up a bit so it will run on 64-bit Macs. (The original source code was written for PPC/x86 fat binaries in mind).

If you'd like to continue development of the project, then sure, setting up your own GitHub project for it makes sense. But if you just want to fetch the last code that existed, it's fine to program the portfile to fetch from archive.org. We have tons of ports that already do that, as many projects have disappeared over the years.

Unfortunately, it was set up as an xcode project. I suspect that will make the portfile a little tricky (since I do not know how to change different compiler flags for different architectures in a xcode project portfile. Different flags are needed if one want to compile the source for a PPC Mac. Or maybe I should abandon PPC support). I will see if I can create a Makefile instead.

The xcode 1.0 portgroup is designed to simplify creating portfiles for software that builds using xcode projects.

If you need to supply different flags for different architectures, the muniversal 1.0 portgroup can help with that.

comment:11 in reply to:  description Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to RobK88:

Please note that the name of the binary and the worksrcdir uses both upper and lower case characters. As a result, I could not use ${name} in many places in the portfile since I used only lowercase letters for the portname (just like Debian did).

Is there a good reason why we shouldn't just capitalize the port name "M2VRequantiser"? MacPorts has no aversion to capital letters in port names, and especially in this case wouldn't it be clearer since the executable name is already capitalized that way?

comment:12 Changed 3 years ago by RobK88

There is no good reason, other than most CLI apps just use all lowercase letters for their name.

For this port, I was not sure what to do about the portname. I noticed that debian just used all lowercase letters for its port. So I used all lowercase letters for the Macport.

Please read the man page. The authors of the man page used "M2VRequantiser" in the text. So go ahead and use both upper and lower case letters for the portname. That is probably the best way to go.

P.S. I am not sure if you also need to do anything to the man page. Right now, you must use all lowercase letters (m2vrequantiser) to bring the man page up. You may need to change the file name for the man page.

comment:13 in reply to:  12 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to RobK88:

There is no good reason, other than most CLI apps just use all lowercase letters for their name.

Right, but this CLI app already uses mixed case for its command name and manpage. Even for ports that don't, we sometimes use the project's preferred capitalization for the port name (like ImageMagick and GraphicsMagick).

P.S. I am not sure if you also need to do anything to the man page. Right now, you must use all lowercase letters (m2vrequantiser) to bring the man page up. You may need to change the file name for the man page.

Yes what caused me to ask was when I noticed this error in the Portfile: the manpage name is M2VRequantiser.1 but you refer to it in the Portfile by ${name} when you install it. On a case-insensitive filesystem, that'll work and end up installing it as m2vrequantiser.1. On a case-sensitive filesystem like on our buildbot workers, that'll fail, saying m2vrequantiser.1 doesn't exist.

comment:14 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: acceptedclosed

In 34614230fafb69b702035ce4f202f69a803c5cbe/macports-ports (master):

M2VRequantiser: New port, version 1.1

Closes: #64083

comment:15 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

I made a few edits to the manpage and also made the Portfile install the license file.

comment:16 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

In 8d7e3b53a2bb779907599cfa5c1f21bcf1506d39/macports-ports (master):

M2VRequantiser: Remove -frename-registers flag

New versions of clang (e.g. on macOS 11) say:

clang: warning: optimization flag '-frename-registers' is not supported

Old versions of clang (e.g. on OS X 10.9) say:

clang: error: unknown argument: '-frename-registers'

See: #64083

comment:17 Changed 3 years ago by RobK88

Fantastic! I was wondering how to handle the license file. As you know, normally when one distributes GPL software, you include a copy of of the GPL license.

Again thanks for all your help!

P.S. I have successfully developed patches for the source code for the sister CLI app -- M2VDownsizer. M2VDownsizer now runs well on Intel i386/x64 Macs. When I get a chance, I will try to make a working Makefile for it (so I can avoid using the XCode in the portfile). Worst case scenario, I will just make an XCode portfile. But I really want to avoid that.

Note: See TracTickets for help on using tickets.