#!/usr/bin/make -f # Dart Sass is built twice: # # * as a self-contained native executable, installed as /usr/bin/dart-sass # by the dart-sass binary package; # * with dart2js, as the JavaScript module for Node.js consumers, installed # as "sass" under /usr/share/nodejs by the node-sass binary package. # # Nothing is fetched from the network. Debian ships the Dart packages that # Dart Sass depends on as sources under /usr/share/dart/packages/; the Dart # tools need a package_config.json to resolve "package:/..." imports, so # debian/gen-package-config.py builds one from those directories. # # The JavaScript module is not used as dart2js emits it: upstream wraps the # output with a loader that inlines the node_preamble and injects the # require()s the Dart code performs (that wrapper is normally written by # cli_pkg, which cannot run in a Debian build because it drives npm). # debian/make-node-module.py reproduces it. # dpkg does not export the package version to debian/rules, so take it from the # changelog the supported way (lintian: debian-rules-parses-dpkg-parsechangelog). include /usr/share/dpkg/pkg-info.mk %: dh $@ override_dh_auto_build: mkdir -p .dart_tool build python3 debian/gen-package-config.py > .dart_tool/package_config.json dart compile exe -Dversion=$(DEB_VERSION_UPSTREAM) bin/sass.dart -o build/dart-sass dart compile js -O4 --no-minify --no-source-maps --fast-startup \ -Dversion=$(DEB_VERSION_UPSTREAM) lib/src/js.dart -o build/sass-raw.js python3 debian/make-node-module.py build/sass-raw.js build/npm # pubspec.lock is not part of the upstream archive: the Dart tool writes it # when it resolves packages. It must not be left behind, because # dpkg-source -b runs before the build and refuses to add a new upstream # file to a 3.0 (quilt) source package. override_dh_auto_clean: rm -rf build .dart_tool pubspec.lock dh_auto_clean # strip(1) removes the ELF section that carries the AOT snapshot of a # `dart compile exe` executable: the result is 5 MB smaller and behaves like # plain dartaotruntime instead of the compiled program (measured: 10687408 -> # 5453960 bytes, and `dart-sass --version` then prints the Dart SDK version). # The compiler therefore must not be stripped. override_dh_strip: dh_strip --exclude=dart-sass # Upstream's pub.dev archives record every directory entry with an epoch (0) # timestamp, and dh_install preserves the mtime of the directories it copies, # which lintian reports as package-contains-ancient-file. Stamp installed # directories with the source date instead (dh exports SOURCE_DATE_EPOCH from # debian/changelog, so builds stay reproducible). No file content is affected. # dh_installman installs the manual page as dart-sass.1; sass.1 is an alias for # it, so that "man sass" works for the generic command name. The alias cannot # live in debian/dart-sass.links: dh_link runs before dh_compress and refuses to # link to a file that is not there yet (the page is still uncompressed at that # point). Naming the link sass.1.gz makes it resolve once the real page has # been packed, and dh_compress leaves symlinks alone. The directory is only # there in an arch-dependent build, hence the guard. override_dh_installman: dh_installman if [ -d debian/dart-sass/usr/share/man/man1 ]; then \ ln -sf dart-sass.1.gz debian/dart-sass/usr/share/man/man1/sass.1.gz; \ fi override_dh_install: dh_install for d in debian/dart-sass debian/node-sass; do \ if [ -d "$$d" ]; then \ find "$$d" -type d -exec touch -d "@$${SOURCE_DATE_EPOCH}" {} +; \ fi; \ done