1

Тема: Kernel Linux Documentation файлом pdf

Кожен дистрибутив Лінукс має можливість завантаження офіційної документації від розробників Лінукс. У цьому випадку мова піде про Убунту.
Щоб встановити офіційну документацію Лінукс:

sudo apt install linux-doc

Цю документацію буде встановлено в теку: /usr/share/doc/linux-doc/

Далі скопіюйте linux-doc до окремої теки (в «Документи», наприклад), бо ми будемо змінювати її вміст.

Документацію Лінукс побудовано в форматі reStructuredText (файли із розширенням .rst) і щоб зібрати все це в один файл формату pdf потрібно встановити такі програми як Sphinx i Latex:

sudo apt install texlive-latex-base texlive-latex-recommended \ 
texlive-latex-extra texlive-fonts-recommended

sudo apt install latexmk.

Тепер треба відкрити теку з копією документації в терміналі та
ввести таку команду:

find . -name "*.gz" | xargs gunzip

Ця команда розархівує всі заархівовані файли в поточній теці та всіх вкладених теках. Це потрібно зробити, бо програма, що збиратиме pdf файл, не бачить архівовані файли.

Далі в терміналі набираємо таку команду:

sphinx-quickstart назва вашої цільової теки

Ця команда створить основу для роботи Sphinx, створить вказану вами теку та помістить всі необхідні файли в неї. Там буде потрібно відповісти на кілька питань для створення конфігурації. Якщо не вказати теку, усе буде розміщено відповідно до шляху вказаного в терміналі.

А тепер треба зайти до теки з документацією та поглянути файл index.rst. Тут є перелік великих розділів документації. Звісно, можна створити одним величезним файлом pdf, але вийде десь 9000 сторінок. Прилад для читання електронних книг вас прокляне:). Тому краще вирізати зайві розділи, які вас наразі не цікавлять, з index.srt (окрім того, що формує індекси Indices and tables) та створити якийсь один розділ на вибір.

Далі копіюємо теки, вказані у відредагованому файлі index.srt, та власне файл index.srt до теки, створеної Sphinx. У теці створеній Sphinx буде свій index.srt, просто замінюємо його.

Відкриваємо теку, створену Sphinx, у терміналі та вводимо команду:

make latexpdf

Згенерований файл pdf буде в теці _build/latex/

Звісно, у файлі документації Linux є Makefile, який мав би командою make pdfdocs збирати pdf файл, але в мене він не бачить один із файлів Sphinx (шлях до файлу вказано неправильно в Makefile, не знаю як виправити), окрім того, такий файл буде завеликий для читання в електронних книгах.

Подякували: leofun01, HetmanNet2

2 Востаннє редагувалося Teg Miles (27.04.2025 16:35:17)

Re: Kernel Linux Documentation файлом pdf

Нарешті зрозумів, чому не збирався файл командою make latexdocs в окремій теці linux-doc.
Виявляється цей Makefile розрахований на теку із сирцевим кодом.
Тобто треба з kernel.org завантажити архів з потрібним ядром.
Розархівувати його та виконати відповідну команду в терміналі.
Ось що видає make help для ядра 6.1.25:

Cleaning targets:
  clean          - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper      - Remove all generated files + config + various backup files
  distclean      - mrproper + remove editor backup and patch files

Configuration targets:
  config      - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based program
  menuconfig      - Update current config utilising a menu based program
  xconfig      - Update current config utilising a Qt based front-end
  gconfig      - Update current config utilising a GTK+ based front-end
  oldconfig      - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
                    except those preserved by LMC_KEEP environment variable
  localyesconfig  - Update current config converting local mods to core
                    except those preserved by LMC_KEEP environment variable
  defconfig      - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)
  allnoconfig      - New config where all options are answered with no
  allyesconfig      - New config where all options are accepted with yes
  allmodconfig      - New config selecting modules when possible
  alldefconfig    - New config with all symbols set to default
  randconfig      - New config with random answer to all options
  yes2modconfig      - Change answers from yes to mod if possible
  mod2yesconfig      - Change answers from mod to yes if possible
  mod2noconfig      - Change answers from mod to no if possible
  listnewconfig   - List new options
  helpnewconfig   - List new options and help text
  olddefconfig      - Same as oldconfig but sets new symbols to their
                    default value without prompting
  tinyconfig      - Configure the tiniest possible kernel
  testconfig      - Run Kconfig unit tests (requires python3 and pytest)

Other generic targets:
  all          - Build all targets marked with [*]
* vmlinux      - Build the bare kernel
* modules      - Build all modules
  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
  dir/            - Build all files in dir and below
  dir/file.[ois]  - Build specified target only
  dir/file.ll     - Build the LLVM assembly file
                    (requires compiler support for LLVM assembly generation)
  dir/file.lst    - Build specified mixed source/assembly target only
                    (requires a recent binutils and recent build (System.map))
  dir/file.ko     - Build module including final link
  modules_prepare - Set up for building external modules
  tags/TAGS      - Generate tags file for editors
  cscope      - Generate cscope index
  gtags           - Generate GNU GLOBAL index
  kernelrelease      - Output the release version string (use with make -s)
  kernelversion      - Output the version stored in Makefile (use with make -s)
  image_name      - Output the image name (use with make -s)
  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
                    (default: ./usr)

Static analysers:
  checkstack      - Generate a list of stack hogs
  versioncheck    - Sanity check on version.h usage
  includecheck    - Check for duplicate included header files
  export_report   - List the usages of all exported symbols
  headerdep       - Detect inclusion cycles in headers
  coccicheck      - Check with Coccinelle
  clang-analyzer  - Check with clang static analyzer
  clang-tidy      - Check with clang-tidy

Tools:
  nsdeps          - Generate missing symbol namespace dependencies

Kernel selftest:
  kselftest         - Build and run kernel selftest
                      Build, install, and boot kernel before
                      running kselftest on it
                      Run as root for full coverage
  kselftest-all     - Build kernel selftest
  kselftest-install - Build and install kernel selftest
  kselftest-clean   - Remove all generated kselftest files
  kselftest-merge   - Merge all the config dependencies of
              kselftest to existing .config.

Rust targets:
  rustavailable   - Checks whether the Rust toolchain is
            available and, if not, explains why.
  rustfmt      - Reformat all the Rust code in the kernel
  rustfmtcheck      - Checks if all the Rust code in the kernel
            is formatted, printing a diff otherwise.
  rustdoc      - Generate Rust documentation
            (requires kernel .config)
  rusttest        - Runs the Rust tests
                    (requires kernel .config; downloads external repos)
  rust-analyzer      - Generate rust-project.json rust-analyzer support file
            (requires kernel .config)
  dir/file.[os]   - Build specified target only
  dir/file.rsi    - Build macro expanded source, similar to C preprocessing.
                    Run with RUSTFMT=n to skip reformatting if needed.
                    The output is not intended to be compilable.
  dir/file.ll     - Build the LLVM assembly file

Userspace tools targets:
  use "make tools/help"
  or  "cd tools; make help"

Kernel packaging:
  rpm-pkg             - Build both source and binary RPM kernel packages
  binrpm-pkg          - Build only the binary kernel RPM package
  deb-pkg             - Build both source and binary deb kernel packages
  bindeb-pkg          - Build only the binary kernel deb package
  snap-pkg            - Build only the binary kernel snap package
                        (will connect to external hosts)
  dir-pkg             - Build the kernel as a plain directory structure
  tar-pkg             - Build the kernel as an uncompressed tarball
  targz-pkg           - Build the kernel as a gzip compressed tarball
  tarbz2-pkg          - Build the kernel as a bzip2 compressed tarball
  tarxz-pkg           - Build the kernel as a xz compressed tarball
  tarzst-pkg          - Build the kernel as a zstd compressed tarball
  perf-tar-src-pkg    - Build perf-6.1.25.tar source tarball
  perf-targz-src-pkg  - Build perf-6.1.25.tar.gz source tarball
  perf-tarbz2-src-pkg - Build perf-6.1.25.tar.bz2 source tarball
  perf-tarxz-src-pkg  - Build perf-6.1.25.tar.xz source tarball
  perf-tarzst-src-pkg - Build perf-6.1.25.tar.zst source tarball

Documentation targets:
 Linux kernel internal documentation in different formats from ReST:
  htmldocs        - HTML
  latexdocs       - LaTeX
  pdfdocs         - PDF
  epubdocs        - EPUB
  xmldocs         - XML
  linkcheckdocs   - check for broken external links
                    (will connect to external hosts)
  refcheckdocs    - check for references to non-existing files under
                    Documentation
  cleandocs       - clean all generated files

  make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2
  valid values for SPHINXDIRS are: PCI RCU accounting admin-guide arc arm arm64 block bpf cdrom core-api cpu-freq crypto dev-tools devicetree doc-guide driver-api fault-injection fb filesystems firmware-guide fpga gpu hid hwmon i2c ia64 iio infiniband input isdn kbuild kernel-hacking leds livepatch locking loongarch m68k maintainer mhi mips misc-devices mm netlabel networking nios2 openrisc parisc pcmcia peci power powerpc process riscv rust s390 scheduler scsi security sh sound sparc spi staging target timers tools trace translations usb userspace-api virt w1 watchdog x86 xtensa

  make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build
  configuration. This is e.g. useful to build with nit-picking config.

  make DOCS_THEME={sphinx-theme} selects a different Sphinx theme.

  make DOCS_CSS={a .css file} adds a DOCS_CSS override file for html/epub output.

  Default location for the generated documents is Documentation/output

Architecture specific targets (x86):
* bzImage        - Compressed kernel image (arch/x86/boot/bzImage)
  install        - Install kernel using (your) ~/bin/installkernel or
              (distribution) /sbin/installkernel or install to 
              $(INSTALL_PATH) and run lilo

  fdimage        - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
  fdimage144        - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
  fdimage288        - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)
  hdimage        - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)
  isoimage        - Create a boot CD-ROM image (arch/x86/boot/image.iso)
              bzdisk/fdimage*/hdimage/isoimage also accept:
              FDARGS="..."  arguments for the booted kernel
              FDINITRD=file initrd for the booted kernel

  kvm_guest.config    - Enable Kconfig items for running this kernel as a KVM guest
  xen.config        - Enable Kconfig items for running this kernel as a Xen guest
  x86_debug.config    - Enable tip tree debugging options for testing

  i386_defconfig              - Build for i386
  x86_64_defconfig            - Build for x86_64

  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
  make V=2   [targets] 2 => give reason for rebuild of target
  make O=dir [targets] Locate all output files in "dir", including .config
  make C=1   [targets] Check re-compiled c source with $CHECK
                       (sparse by default)
  make C=2   [targets] Force check of all c source with $CHECK
  make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections
  make W=n   [targets] Enable extra build checks, n=1,2,3 where
        1: warnings which may be relevant and do not occur too often
        2: warnings which occur quite often but may still be relevant
        3: more obscure warnings, can most likely be ignored
        e: warnings are being treated as errors
        Multiple levels can be combined with W=12 or W=123

Execute "make" or "make all" to build all targets marked with [*] 
For further info see the ./README file

Там можна побачити всі команди для збірки документації.
Зібрав собі epub файл із усією документацією включно з перекладами.
На пристрої для читання електронних книг працює доволі добре, не висне.

Подякували: leofun011