karnel-termux 4.17.0 → 4.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/install.sh CHANGED
@@ -79,7 +79,9 @@ _INSTALL_KARNEL_SYMLINK_CHANGED=false
79
79
  _INSTALL_PREVIOUS_KARNEL_SYMLINK=""
80
80
 
81
81
  _cleanup_failed() {
82
- echo -e "\n ${P_FAIL}✖${P_NC} Installation failed at step ${CURRENT_STEP}. Cleaning up..."
82
+ set +e
83
+ trap - ERR
84
+ echo -e "\n ${P_FAIL}✖${P_NC} Installation failed at step ${CURRENT_STEP}. Cleaning up..."
83
85
  if $_INSTALL_KARNEL_SYMLINK_CHANGED; then
84
86
  if [[ -n "$_INSTALL_PREVIOUS_KARNEL_SYMLINK" ]]; then
85
87
  local rollback_link_dir
@@ -287,7 +289,23 @@ clone_repo() {
287
289
  log_fail "Failed to clone repository"
288
290
  return 1
289
291
  fi
290
- if [[ -n "$RELEASE_REF" ]]; then
292
+ if [[ -n "$RELEASE_COMMIT" ]]; then
293
+ if ! git -C "$candidate_repo" fetch --depth=1 origin "$RELEASE_COMMIT" &>/dev/null; then
294
+ log_fail "Failed to fetch release commit $RELEASE_COMMIT"
295
+ return 1
296
+ fi
297
+ if ! git -C "$candidate_repo" checkout --quiet --detach "$RELEASE_COMMIT" &>/dev/null; then
298
+ log_fail "Failed to checkout release commit $RELEASE_COMMIT"
299
+ return 1
300
+ fi
301
+ local candidate_commit
302
+ candidate_commit=$(git -C "$candidate_repo" rev-parse HEAD 2>/dev/null) || return 1
303
+ if [[ "$candidate_commit" != "$RELEASE_COMMIT" ]]; then
304
+ log_fail "Release commit mismatch"
305
+ log_info "Expected $RELEASE_COMMIT, got $candidate_commit"
306
+ return 1
307
+ fi
308
+ elif [[ -n "$RELEASE_REF" ]]; then
291
309
  local candidate_commit
292
310
  candidate_commit=$(git -C "$candidate_repo" rev-parse HEAD 2>/dev/null) || return 1
293
311
  if [[ "$candidate_commit" != "$RELEASE_COMMIT" ]]; then
@@ -1 +1 @@
1
- 57a1aa3e5401b6ba9b37965d8680bcb543b0fc00
1
+ c9797260b1affd17127bf2b1e5c22c1cf184adb1
package/karnel/bin/karnel CHANGED
@@ -30,7 +30,8 @@ import "@/utils/env"
30
30
 
31
31
  # ===== SEMVER COMPARISON =====
32
32
  _semver_gt() {
33
- [[ "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -1)" == "$1" ]] && [[ "$1" != "$2" ]]
33
+ local a="${1#v}" b="${2#v}"
34
+ [[ "$(printf '%s\n%s' "$a" "$b" | sort -V | tail -1)" == "$a" ]] && [[ "$a" != "$b" ]]
34
35
  }
35
36
 
36
37
  _valid_semver() {
@@ -292,7 +292,7 @@ _fix_locale() {
292
292
  if [[ ! -f "$config" ]] && [[ -f "$HOME/.bashrc" ]]; then
293
293
  config="$HOME/.bashrc"
294
294
  fi
295
- echo 'export LANG=en_US.UTF-8' >> "$config" 2>/dev/null
295
+ grep -qxF 'export LANG=en_US.UTF-8' "$config" 2>/dev/null || echo 'export LANG=en_US.UTF-8' >> "$config" 2>/dev/null
296
296
  }
297
297
 
298
298
 
@@ -425,6 +425,6 @@ _fix_keyring() {
425
425
  }
426
426
 
427
427
  _fix_apt_cache() {
428
- rm -rf "$PREFIX/var/apt/lists"/* 2>/dev/null
428
+ rm -rf "${PREFIX:?}/var/apt/lists"/* 2>/dev/null
429
429
  pkg update -y &>/dev/null
430
430
  }
@@ -1078,33 +1078,33 @@ configure_rust() {
1078
1078
 
1079
1079
  # Append dependencies to Cargo.toml
1080
1080
  if [[ -f "Cargo.toml" ]]; then
1081
- # Append after [dependencies] or add it
1082
- if grep -q '^\[dependencies\]' Cargo.toml; then
1083
- cat >>Cargo.toml <<EOF
1084
- EOF
1085
- else
1086
- echo -e "\n[dependencies]" >> Cargo.toml
1081
+ if ! grep -q '^\[dependencies\]' Cargo.toml; then
1082
+ printf '\n[dependencies]\n' >> Cargo.toml
1087
1083
  fi
1088
- cat >>Cargo.toml <<EOF
1089
- tokio = { version = "1.0", features = ["full"] }
1090
- serde = { version = "1.0", features = ["derive"] }
1091
- serde_json = "1.0"
1092
- dotenvy = "0.15"
1093
- EOF
1084
+ local dep name spec
1085
+ local -a deps=(
1086
+ 'tokio = { version = "1.0", features = ["full"] }'
1087
+ 'serde = { version = "1.0", features = ["derive"] }'
1088
+ 'serde_json = "1.0"'
1089
+ 'dotenvy = "0.15"'
1090
+ )
1094
1091
  if [[ "$framework_choice" == "Axum" ]]; then
1095
- cat >>Cargo.toml <<EOF
1096
- axum = "0.7"
1097
- EOF
1092
+ deps+=('axum = "0.7"')
1098
1093
  else
1099
- cat >>Cargo.toml <<EOF
1100
- actix-web = "4.0"
1101
- EOF
1094
+ deps+=('actix-web = "4.0"')
1102
1095
  fi
1103
1096
  if [[ "$db_choice" == "SQLx (PostgreSQL)" ]]; then
1104
- cat >>Cargo.toml <<EOF
1105
- sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "macros"] }
1106
- EOF
1097
+ deps+=('sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "macros"] }')
1107
1098
  fi
1099
+ for dep in "${deps[@]}"; do
1100
+ name="${dep%% =*}"
1101
+ name="${name%%[[:space:]]*}"
1102
+ if grep -q "^${name} =" Cargo.toml; then
1103
+ log_info "Dependency already present: ${name}"
1104
+ else
1105
+ sed -i "/^\[dependencies\]/a ${dep}" Cargo.toml
1106
+ fi
1107
+ done
1108
1108
  log_success "Configured Cargo.toml"
1109
1109
  fi
1110
1110
 
@@ -15,6 +15,13 @@ install_netlify() {
15
15
  if command -v netlify &>/dev/null && netlify --version &>/dev/null; then
16
16
  log_info "Netlify CLI is already installed"
17
17
  return 2
18
+ fi
19
+ if ! command -v node &>/dev/null || ! command -v npm &>/dev/null; then
20
+ log_info "Installing Node.js..."
21
+ if ! pkg install -y nodejs-lts &>>"$LOG_FILE"; then
22
+ log_error "Failed to install Node.js"
23
+ return 1
24
+ fi
18
25
  fi
19
26
  if ! _netlify_node_supported; then
20
27
  log_error "Netlify CLI requires Node.js 22.13.0 or newer. Update Node.js and retry."
@@ -185,6 +185,15 @@ uninstall_railway() {
185
185
  }
186
186
 
187
187
  update_railway() {
188
+ if _railway_proot_wrapper_owned; then
189
+ log_info "Railway was installed via Ubuntu PRoot; updating inside the container..."
190
+ if proot-distro login ubuntu -- npm update -g @railway/cli &>>"$LOG_FILE"; then
191
+ log_success "Railway CLI updated through Ubuntu Proot"
192
+ return 0
193
+ fi
194
+ log_warn "Railway CLI update failed inside Ubuntu Proot"
195
+ return 1
196
+ fi
188
197
  _check_update_needed "Railway CLI" "$(_get_installed_npm_version @railway/cli)" "$(_get_remote_npm_version @railway/cli)" _do_update_railway
189
198
  }
190
199
 
@@ -10,6 +10,13 @@ install_vercel() {
10
10
  log_info "Vercel CLI is already installed"
11
11
  return 2
12
12
  fi
13
+ if ! command -v node &>/dev/null || ! command -v npm &>/dev/null; then
14
+ log_info "Installing Node.js..."
15
+ if ! pkg install -y nodejs-lts &>>"$LOG_FILE"; then
16
+ log_error "Failed to install Node.js"
17
+ return 1
18
+ fi
19
+ fi
13
20
  log_info "Installing Vercel CLI..."
14
21
  npm install -g vercel &>/dev/null || {
15
22
  log_error "Failed to install Vercel CLI"
@@ -296,6 +296,7 @@ _install_bun_proot_impl() {
296
296
  fi
297
297
  sed "s|__UBUNTU_ROOTFS__|$ubuntu_root|g" "$wrapper_src" >"$PREFIX/bin/bun"
298
298
  chmod +x "$PREFIX/bin/bun"
299
+ mkdir -p "$BUN_DATA_DIR" && : >"$BUN_DATA_DIR/.karnel-proot"
299
300
  return 0
300
301
  }
301
302
 
@@ -339,7 +340,12 @@ _uninstall_bun_impl() {
339
340
  _uninstall_bun_native
340
341
  return $?
341
342
  fi
342
- _uninstall_bun_proot
343
+ if [ -f "$BUN_DATA_DIR/.karnel-proot" ]; then
344
+ _uninstall_bun_proot
345
+ return $?
346
+ fi
347
+ log_error "Refusing to remove unowned bun command: $PREFIX/bin/bun"
348
+ return 1
343
349
  }
344
350
 
345
351
  uninstall_bun() {
@@ -178,8 +178,8 @@ install_turbopack() {
178
178
 
179
179
  uninstall_turbopack() {
180
180
  if ! _has_glibc_node; then
181
- log_warn "Turbopack is not installed"
182
- return 1
181
+ log_info "Turbopack is not installed"
182
+ return 2
183
183
  fi
184
184
 
185
185
  loading "Removing CLI wrappers" _uninstall_wrappers
@@ -60,7 +60,7 @@ install_zsh_defer() {
60
60
  _uninstall_zsh_defer_impl() {
61
61
  if [[ ! -d "$ZSH_PLUGINS_DIR/zsh-defer" ]]; then
62
62
  log_info "zsh-defer is not installed"
63
- return 2
63
+ return 0
64
64
  fi
65
65
 
66
66
  local remove_rc=0
@@ -269,8 +269,14 @@ managed_file_matches() {
269
269
 
270
270
  github_download_and_extract() {
271
271
  local repo="$1" version="$2" asset="$3" outdir="$4"
272
- local tarball
272
+ local tarball expected
273
273
  tarball=$(github_download_release "$repo" "$version" "$asset" "$outdir") || return 1
274
+ expected=$(github_release_asset_sha256 "$repo" "$version" "$asset") || expected=""
275
+ if [[ "$expected" =~ ^[0-9a-f]{64}$ ]]; then
276
+ verify_sha256 "$tarball" "$expected" || return 1
277
+ else
278
+ log_warn "No published SHA-256 digest for $repo/$asset; skipping integrity verification"
279
+ fi
274
280
  extract_tarball "$tarball" "$outdir" || return 1
275
281
  return 0
276
282
  }
@@ -106,6 +106,10 @@ _batch_tool_action() {
106
106
  local failed_count=0
107
107
  local skipped_count=0
108
108
 
109
+ # An explicit uninstall should actually remove owned data, even when no TTY
110
+ # is attached (piped/non-interactive). Ownership is still guarded upstream.
111
+ [[ "$action" == "uninstall" ]] && export KARNEL_REMOVE_DEFAULT=y
112
+
109
113
  import "@/tools/$module/all"
110
114
 
111
115
  for tool in "${tools[@]}"; do
@@ -3,6 +3,7 @@
3
3
  confirm_remove_paths() {
4
4
  local label="$1"
5
5
  shift
6
+ local default="${KARNEL_REMOVE_DEFAULT:-n}"
6
7
  local answer path
7
8
  local -a existing=()
8
9
 
@@ -11,7 +12,7 @@ confirm_remove_paths() {
11
12
  done
12
13
  (( ${#existing[@]} > 0 )) || return 0
13
14
 
14
- read_confirm_default "Remove $label configuration and data?" "n" answer || return 2
15
+ read_confirm_default "Remove $label configuration and data?" "$default" answer || return 2
15
16
  [[ "$answer" == "y" ]] || return 2
16
17
 
17
18
  rm -rf -- "${existing[@]}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karnel-termux",
3
- "version": "4.17.0",
3
+ "version": "4.17.1",
4
4
  "description": "Modular Dev Environment for Termux — install languages, databases, AI agents, editors, and more with one command",
5
5
  "bin": {
6
6
  "karnel": "karnel/bin/karnel"