Skip to content
devtools-coursePublic

About

Devtools. Task archives

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Archives

Branch: ars
Fenrir ID: ars
Points: 25

Your solution must be located at ars:

[folder] ...
├─ [folder] ars
│  ├─ [file code] part-1.sh
│  ├─ [file code] part-2.sh
│  ├─ [file code] part-3.sh
│  └─ [file code] part-4.sh
└─ [folder] .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 suffix 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:

[folder] APPNAME
├─ [folder] bin
│  ├─ [file code] ..
│  └─ [file code] APP
├─ [folder] lib
│  └─ [file code] ..
└─ [folder] ..

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

When the provided archive does not exist, exit with code 44.

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>

About

Devtools. Task archives

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages