## Reference: https://github.com/terrapkg/packages/blob/f794351643eed3dbf89441c1c335f7e6734d40ba/anda/langs/d/btdu/btdu.spec ## Difference 1) Not using pkgconfig(ncurses) 2) Offline dependencies 3) code.dlang.org SOURCE %global _version 0.6.0 ## find-debuginfo: gdb-add-index -> ../../gdb/utils.c:671: internal-error: virtual memory exhausted. %global debug_package %nil %global _buildtype release Name: btdu Version: %{gsub %{_version} - ~} Release: %autorelease Summary: sampling disk usage profiler for btrfs License: GPL-2.0-only URL: https://github.com/CyberShadow/btdu ExclusiveArch: %{ldc_arches} # Reference: https://github.com/dlang/dub/blob/0030b9af02481fb518419bb4e13dd18731a9fd4f/source/dub/packagesuppliers/registry.d#L65 # or https://codemirror.dlang.org %define __dub_url https://code.dlang.org/packages/ %define dub_source() %{lua: local package = rpm.expand('%1') local version = rpm.expand('%2') local url = rpm.expand('%__dub_url') -- first argument missing if package == '%1' then package = rpm.expand('%name') end if version == '%2' then version = rpm.expand('%version') end -- replace '~' with '-' for backwards compatibility version = version:gsub('~', '-') print(url .. package .. '/' .. version .. '.zip#/' .. package .. '-' .. version .. '.zip') } Source0: %{dub_source %name %version} ## todo save packages to like /usr/share/dub/packages/xxxx.zip like rust ## use generate_requres -> read dub.selections.json and --> create something like dub(xxxx) # dub build --registry=file://<> --skip-registery=..... ## from dub.selections.json Source: %{dub_source ae 0.0.3461} Source: %{dub_source btrfs 0.0.21} Source: %{dub_source ncurses 1.0.0} Source: %{dub_source emsi_containers 0.9.0} BuildRequires: dub BuildRequires: ldc # https://github.com/CyberShadow/btdu/blob/master/README.md#building BuildRequires: ncurses-devel %global _description %{expand: %{summary} } %description %_description %prep ## RPM lua's global value `sources` `source_nums` `patches` `patch_nums` ## Reference: https://rpm-software-management.github.io/rpm/man/rpm-lua.7#SPEC_FILES ## use FileSystemProvider ## Reference: https://github.com/dlang/dub/pull/1616 ## https://github.com/dlang/dub/blob/0030b9af02481fb518419bb4e13dd18731a9fd4f/source/dub/dub.d#L111 ## https://github.com/dlang/dub/blob/0030b9af02481fb518419bb4e13dd18731a9fd4f/source/dub/packagesuppliers/filesystem.d ## This package supplier searches a certain directory for files with names of the form "[package name]-[version].zip". ## Dont try to mimic ~/.dub/packages , since dub fetch will modify package dub.json/dub.sdl here by adding version field and converting dub.sdl to dub.json ## TODO: Make this a helper for all D lang libraries %{lua: print(rpm.expand('mkdir %{_buildrootdir}/packages \n')) for i, p in ipairs(source_nums) do if p ~= 0 then print(rpm.expand('cp ' .. sources[i] .. ' %{_buildrootdir}/packages\n')) end end } # dcd's dubhash is located in common/ folder, so when building, DUB_PACKAGING_DIR will be dcd-version/common (since it is a dcb:common package) so , the dir.dirName is dcd-version. Situation is not the same as d-scanner, dfmt , their dubhash is located under root folder, so -C -n %{_version}/%{name}-%{_version} is a must. (-C strip root under archive file, -n create with nested folder) ## use /- for all dubhash versioing d pacakge. %setup -C -n %{_version}/%{name}-%{_version} #TODO make this a %{dub_build} with --skip-registry=all --registry=file://%{_buildrootdir}/packages %build ## -f force rebuild ## -n non-interactive ## --arch ## --cache local -> set to /.dub user -> set to ~/.dub system /var/lib/dub/ see also $DUB_HOME ## --parallel ## TODO ## --deep (for target=static_libary to build all) ## --combined (will fail) ## --nodeps (will fail) ## --build-mode=separate (default), allAtOnce, singleFile dub --skip-registry=all --registry=file://%{_buildrootdir}/packages --cache local build --parallel -f -n --compiler=ldc2 --build=%{_buildtype} %install install -Dpm0755 -t %{buildroot}%{_bindir} %{name} ## or #install -m 0755 -vd %{buildroot}%{_bindir} #install -m 0755 -vp %{name} %{buildroot}%{_bindir} install -Dpm0644 -t %{buildroot}%{_mandir}/man1 %{name}.1 %check %files %license COPYING %doc README.md %{_bindir}/%{name} ## man file will be compressed to .gz %{_mandir}/man1/%{name}.1* %changelog %autochangelog