Archives

This is a README.adoc file. The original repository is located here.

Archives

Branch: ars
Fenrir ID: ars
Points: 25

Your solution must be located at ars:

 ...
├─  ars
│  ├─  part-1.sh
│  ├─  part-2.sh
│  ├─  part-3.sh
│  └─  part-4.sh
└─  .git

Create archives (5 points)

Create a script part-1.sh which assembles files into an archive or compresses them.

Archivation

./part-1.sh -a NAME FILES…​  —  Creates an archive NAME which contains all the provided files.

Compression

./part-1.sh -z DIR FILES…​  —  Compresses each file (gzip format) and puts the result into the DIR directory. Add .gz prefix to the resulting file name.

Error handling

If any arguments are missing, exit with a code 11.

Questions

  • What is the difference between compression and archivation?

Format recognition (5 points)

When running tar xf ARCHIVE, it can automatically infer the compression format itself. Create a script part-2.sh which takes the path to a compressed archive and prints the used algorithm. Use must support these formats: gz, bz2, xz, zst.

Error handling

Is not needed. We guarantee the correctness of the input data.

Questions

  • How to create a .tar.gz file? .tar.bz2? .tar.xz? .tar.zst?

  • How does tar identify the compression format when no extension is provided?

[ command for archives (10 points)

Create a script part-3.sh which implements a L command (something like []):

L -e ARCHIVE J # ARCHIVE is empty
L ARCHIVE -sz 7 J # ARCHIVE has exactly 7 files
L ARCHIVE -has FILE J # ARCHIVE contains FILE

L and J are equivalents for [ and ]. The command must not print anything to the stdout, however the errors must be logged to the stderr.

The script’s behaviour is expected to be similar to the [: when the condition is true if L .. J; then .. fi must be executed, whereas it is false the if's body must be skipped.

Your script will be installed as L to the PATH during the tests and verified accordingly.

Error handling

Code Description

33

Parsing error

34

The provided archive does not exist

35

The second argument in -sz is not a number

Questions

  • How to list all the files an array contains without extracting it?

Install applications (5 points)

Application for Linux are often distributed as a .tar.gz files. Create a script part-4.sh which takes a path to an archive and installs the application it contains.

Those archives usually follow this structure:

 APPNAME
├─  bin
│  ├─  ..
│  └─  APP
├─  lib
│  └─  ..
└─  ..

The APP is the binary which is executed to start the app.

The APPNAME during the tests is always app.

Requirements
  1. The application must be installed to the /opt directory

  2. The script is executed under non-privileged user. His password is pass through the PASS env variable

  3. The script will be sourced: you may update the env so that the app can be invoked in terminal

Error handling

Is not needed. We guarantee the correctness of the input data.

Questions

  • Why is the path to the APPNAME directory usually stored in a APPNAME_HOME env variable?

  • How to pass a password to sudo in scripts?

The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

© 2026-present Iwan Kalinin <koefic.cien@gmail.com>