Compare commits
2 Commits
542f12b93a
...
2ff04dc407
Author | SHA1 | Date | |
---|---|---|---|
2ff04dc407 | |||
2c46e35d2a |
76
content/posts/2022/alpine-add-package-from-edge.md
Normal file
76
content/posts/2022/alpine-add-package-from-edge.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
title: "Установить пакет из edge в Alpine Linux"
|
||||||
|
date: 2022-07-31T15:38:09+03:00
|
||||||
|
draft: false
|
||||||
|
tags: [linux, tips, alpine linux]
|
||||||
|
---
|
||||||
|
|
||||||
|
## Пердисловие
|
||||||
|
|
||||||
|
Стало мне необходимо обновить язык программирования Crystal до версии 1.5.0.
|
||||||
|
|
||||||
|
Имеем версию дистрибутива **3.16**:
|
||||||
|
```sh
|
||||||
|
cat /etc/os-release
|
||||||
|
NAME="Alpine Linux"
|
||||||
|
ID=alpine
|
||||||
|
VERSION_ID=3.16.0
|
||||||
|
PRETTY_NAME="Alpine Linux v3.16"
|
||||||
|
HOME_URL="https://alpinelinux.org/"
|
||||||
|
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
|
||||||
|
```
|
||||||
|
|
||||||
|
[Crystal](https://crystal-lang.org/)
|
||||||
|
[1.5.0](https://pkgs.alpinelinux.org/package/edge/community/x86_64/crystal) лежит в edge,
|
||||||
|
а в Alpine Linux 3.16 на момент напиcания статьи версия пакета
|
||||||
|
[1.4.1](https://pkgs.alpinelinux.org/package/v3.16/community/x86_64/crystal).
|
||||||
|
|
||||||
|
## Добавляем новый репозиторий и устанавливаем (обновляем) пакет
|
||||||
|
|
||||||
|
Списки репозиториев хранятся в файле `/etc/apk/repositories`:
|
||||||
|
```sh
|
||||||
|
cat /etc/apk/repositories
|
||||||
|
https://dl-cdn.alpinelinux.org/alpine/v3.16/main
|
||||||
|
https://dl-cdn.alpinelinux.org/alpine/v3.16/community
|
||||||
|
```
|
||||||
|
|
||||||
|
Добавляем новый:
|
||||||
|
```sh
|
||||||
|
echo "@edge https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
|
||||||
|
```
|
||||||
|
|
||||||
|
Подробнее здесь - [Repository pinning](https://wiki.alpinelinux.org/wiki/Package_management#Repository_pinning).
|
||||||
|
|
||||||
|
Можно указать ссылку на репозиторий через параметр `--repository`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
apk add librdkafka --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
|
||||||
|
```
|
||||||
|
|
||||||
|
## Проблемы
|
||||||
|
|
||||||
|
В моём случае всё не так просто, потому что необходимо обновить ещё
|
||||||
|
[llvm14-libs](https://pkgs.alpinelinux.org/package/edge/main/aarch64/llvm14-libs).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
apk add crystal@edge
|
||||||
|
ERROR: unable to select packages:
|
||||||
|
so:libLLVM-14.so (no such package):
|
||||||
|
required by: crystal-1.5.0-r0[so:libLLVM-14.so]
|
||||||
|
```
|
||||||
|
|
||||||
|
Устанавливаем:
|
||||||
|
```sh
|
||||||
|
apk add llvm14-libs --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main
|
||||||
|
apk add crystal@edge
|
||||||
|
(1/2) Upgrading crystal@edge (1.4.1-r0 -> 1.5.0-r0)
|
||||||
|
(2/2) Purging llvm13-libs (13.0.1-r2)
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
crystal -v
|
||||||
|
Crystal 1.5.0 (2022-07-15)
|
||||||
|
|
||||||
|
LLVM: 14.0.6
|
||||||
|
Default target: x86_64-alpine-linux-musl
|
||||||
|
```
|
45
content/posts/2022/c/detect-musl.md
Normal file
45
content/posts/2022/c/detect-musl.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
title: "Detect Musl"
|
||||||
|
date: 2022-07-31T16:00:15+03:00
|
||||||
|
draft: false
|
||||||
|
tags: [linux, c, shell, musl]
|
||||||
|
---
|
||||||
|
|
||||||
|
Пост — чистейшая копипаста с [SoF](https://stackoverflow.com/questions/58177815/how-to-actually-detect-musl-libc).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
tmpf=/tmp/musl.log
|
||||||
|
|
||||||
|
# Detect Musl C library.
|
||||||
|
libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1)
|
||||||
|
if [ -z $libc ]; then
|
||||||
|
# This is not Musl.
|
||||||
|
rm -f ${tmpf}
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
$libc >${tmpf} 2>&1
|
||||||
|
vstr=$(cat ${tmpf} | grep "Version" | cut -d ' ' -f2)
|
||||||
|
|
||||||
|
v_major=$(echo $vstr | cut -d '.' -f1)
|
||||||
|
v_minor=$(echo $vstr | cut -d '.' -f2)
|
||||||
|
v_patch=$(echo $vstr | cut -d '.' -f3)
|
||||||
|
|
||||||
|
rm -f ${tmpf}
|
||||||
|
|
||||||
|
echo "-D__MUSL__ -D__MUSL_VER_MAJOR__=${v_major} -D__MUSL_VER_MINOR__=${v_minor} -D__MUSL_VER_PATCH__=${v_patch}"
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ./detect-musl.sh
|
||||||
|
-D__MUSL__ -D__MUSL_VER_MAJOR__=1 -D__MUSL_VER_MINOR__=1 -D__MUSL_VER_PATCH__=24
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ /lib/ld-musl-x86_64.so.1
|
||||||
|
musl libc (x86_64)
|
||||||
|
Version 1.2.3
|
||||||
|
Dynamic Program Loader
|
||||||
|
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname [args]
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user